source: trunk/src/CMakeLists.txt @ 1822

Revision 1816, 4.8 KB checked in by Freddie Akeroyd, 4 months ago (diff)

More mods for NXvalidate building. Refs #327

Line 
1## Process this file with cmake
2#====================================================================
3#  NeXus - Neutron & X-ray Common Data Format
4#
5#  CMakeLists for building the NeXus library and applications.
6#
7#  Copyright (C) 2011 Stephen Rankin
8#
9#  This library is free software; you can redistribute it and/or
10#  modify it under the terms of the GNU Lesser General Public
11#  License as published by the Free Software Foundation; either
12#  version 2 of the License, or (at your option) any later version.
13#
14#  This library is distributed in the hope that it will be useful,
15#  but WITHOUT ANY WARRANTY; without even the implied warranty of
16#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17#  Lesser General Public License for more details.
18#
19#  You should have received a copy of the GNU Lesser General Public
20#  License along with this library; if not, write to the Free
21#  Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
22#  MA  02111-1307  USA
23#
24#  For further information, see <http://www.nexusformat.org>
25#
26#
27#====================================================================
28
29add_definitions(-DIN_NEXUS_LIBRARY ${NX_CPP})
30
31set (NAPISRC napi.c napiu.c nxstack.c nxstack.h stptok.c  nxdataset.c nxdataset.h nx_stptok.h)
32
33if (HAVE_HDF4)
34  set (NAPISRC ${NAPISRC} napi4.c)
35  add_definitions(-DHDF4 ${HDF4_DEFINITIONS} ${HDF4_CPP})
36  include_directories(${HDF4_INCLUDE_DIRS})
37endif (HAVE_HDF4)
38
39if (HAVE_HDF5)
40  set (NAPISRC ${NAPISRC} napi5.c)
41  add_definitions(-DHDF5 ${HDF5_DEFINITIONS} ${HDF5_CPP})
42  include_directories(${HDF5_INCLUDE_DIRS})
43endif (HAVE_HDF5)
44
45if(HAVE_MXML)
46    set (NAPISRC ${NAPISRC} nxxml.c nxio.c nxio.h)
47    add_definitions(-DNXXML ${MXML_DEFINITIONS} ${MXML_CPP})
48        include_directories(${MXML_INCLUDE_DIRS})
49endif(HAVE_MXML)
50
51# need napi_exports2.c  on win32 but not win64
52if (WIN32)
53    if (CMAKE_CL_64)
54        set(NAPISRC ${NAPISRC} napi_exports2.c napi_exports.h)
55    else()
56        set(NAPISRC ${NAPISRC} napi_exports.c napi_exports2.c napi_exports.h)
57        endif()
58endif (WIN32)
59
60set_property(SOURCE ${NAPISRC} APPEND PROPERTY COMPILE_FLAGS ${NX_CFLAGS})
61
62file(STRINGS ${PROJECT_SOURCE_DIR}/src/nexus_symbols.txt NEXUS_SYMBOLS)
63
64set (NX_LIBS  ${HDF4_LINK} ${READLINE_LINK} ${M_LINK} ${DL_LINK} ${PTHREAD_LINK} ${DF_LINK}
65                      ${TERMCAP_LINK} ${HISTORY_LINK} ${JPEG_LIBRARIES} ${SZIP_LIBRARIES} ${ZLIB_LIBRARIES}  )
66#if (MINGW_MSYS)
67#  set (MINGW_SRC napi_exports.c napi_exports2.c napi_exports.h)
68#  file(STRINGS ${PROJECT_SOURCE_DIR}/src/nexus_symbols_win.txt
69#       NEXUS_SYMBOLS_WIN)
70#  file(WRITE ${PROJECT_SOURCE_DIR}/src/nexus_symbols.sym ${NEXUS_SYMBOLS}
71#       ${NEXUS_SYMBOLS_WIN})
72#
73#  if (HAVE_MS_LIB)
74#    file(REMOVE libNeXus.dll.lib libNeXus.dll.exp)
75#    execute_process(
76#      COMMAND ${MS_LIB} /MACHINE:I386 /DEF:libNeXus.def /OUT:libNeXus.dll.lib)
77#  endif (HAVE_MS_LIB)
78#
79#else (MINGW_MSYS)
80#  file(WRITE ${PROJECT_SOURCE_DIR}/src/nexus_symbols.sym ${NEXUS_SYMBOLS})
81#endif (MINGW_MSYS)
82
83#Make NeXus Static Library
84add_library (NeXus_Static_Library STATIC ${NAPISRC})
85
86set_target_properties(NeXus_Static_Library PROPERTIES OUTPUT_NAME NeXusStatic)
87
88target_link_libraries(NeXus_Static_Library ${HDF5_STATIC_LIBRARIES} ${HDF4_STATIC_LIBRARIES} ${MXML_STATIC_LIBRARIES}  ${NX_LIBS})
89
90#Make NeXus Shared Library
91
92add_library (NeXus_Shared_Library SHARED ${NAPISRC})
93
94set_property(TARGET NeXus_Shared_Library APPEND PROPERTY COMPILE_DEFINITIONS _HDF5USEDLL_)
95
96if (CMAKE_CL_64)
97   set(DEF_FILE ${PROJECT_SOURCE_DIR}/Windows_extra/libNeXus-0-x64.def)
98else()
99   set(DEF_FILE ${PROJECT_SOURCE_DIR}/Windows_extra/libNeXus-0-Win32.def)
100endif()
101
102#Note - library version needs to be got from somewhere?
103if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
104    set_target_properties(NeXus_Shared_Library PROPERTIES OUTPUT_NAME libNeXus-0
105                      VERSION 1.0 SOVERSION 4 )
106        set_property(TARGET NeXus_Shared_Library APPEND PROPERTY LINK_FLAGS /def:${DEF_FILE})
107else(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
108    set_target_properties(NeXus_Shared_Library PROPERTIES OUTPUT_NAME NeXus
109                      VERSION 1.0 SOVERSION 4)
110endif (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
111
112target_link_libraries(NeXus_Shared_Library ${HDF5_SHARED_LIBRARIES} ${HDF4_SHARED_LIBRARIES} ${MXML_SHARED_LIBRARIES} ${NX_LIBS})
113
114#if(HAVE_MXML)
115#if(MXMLLIB_FOUND)
116#    target_link_libraries(NeXus_Static_Library ${MXML})
117#    target_link_libraries(NeXus_Shared_Library ${MXML})
118#else()
119#    target_link_libraries(NeXus_Static_Library MXML_Static_Library)
120#    target_link_libraries(NeXus_Shared_Library MXML_Shared_Library)
121#endif(MXMLLIB_FOUND)
122#endif(HAVE_MXML)
123
124install (TARGETS NeXus_Static_Library NeXus_Shared_Library
125         RUNTIME DESTINATION bin COMPONENT Runtime
126         LIBRARY DESTINATION lib COMPONENT Runtime
127         ARCHIVE DESTINATION lib/nexus COMPONENT Development)
128
129if(WIN32)
130install_pdb (NeXus_Shared_Library)
131endif()
Note: See TracBrowser for help on using the repository browser.