source: trunk/CMakeLists.txt @ 1822

Revision 1818, 9.1 KB checked in by Freddie Akeroyd, 3 months ago (diff)

Packaging mods. 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) 2010 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
29# The name of our project is "NeXus". CMakeLists files in this project can
30# refer to the root source directory of the project as ${NeXus_SOURCE_DIR} and
31# to the root binary directory of the project as ${NeXus_BINARY_DIR}.
32if(WIN32)
33cmake_minimum_required (VERSION 2.8.7)
34else()
35cmake_minimum_required (VERSION 2.8.3)
36set(CMAKE_LEGACY_CYGWIN_WIN32 0) # Remove this line when CMake >= 2.8.4 is required
37endif()
38
39#The name of our project
40project (NeXus)
41
42set (NeXus_VERSION_MAJOR 1)
43set (NeXus_VERSION_MINOR 0)
44set (NXLTVERSINFO '4:3:4')
45
46#Packages to find that are required for the build
47
48set(HDF5_SEARCH "" CACHE PATH "Where to search for HDF5")
49
50set(HDF4_SEARCH "" CACHE PATH "Where to search for HDF4")
51
52set(MXML_SEARCH "" CACHE PATH "Where to search for MXML")
53
54set(SZIP_SEARCH "" CACHE PATH "Where to search for SZIP")
55
56set(ZLIB_SEARCH "" CACHE PATH "Where to search for ZLIB")
57
58#CMake includes
59
60include(CheckCCompilerFlag)
61include(CheckCXXCompilerFlag)
62include(CheckTypeSize)
63include(CheckFunctionExists)
64include(CheckIncludeFile)
65include(CheckIncludeFiles)
66include(CheckLibraryExists)
67
68if(WIN32)
69include(InstallRequiredSystemLibraries)
70endif()
71
72include(cmake_include/Utilities.cmake)
73include(cmake_include/FindPython.cmake)
74include(cmake_include/FindCBFLib.cmake)
75#include(cmake_include/FindJava.cmake)
76#include(cmake_include/FindJNI.cmake)
77include(cmake_include/FindGuile.cmake)
78include(cmake_include/FindMZScheme.cmake)
79include(cmake_include/FindHDF4.cmake)
80include(cmake_include/FindHDF5.cmake)
81include(cmake_include/FindIDL.cmake)
82include(cmake_include/FindMXML.cmake)
83include(cmake_include/FindOpenGenie.cmake)
84include(cmake_include/FindDocbookUtils.cmake)
85include(cmake_include/FindSZIP.cmake)
86include(cmake_include/FindAnt.cmake)
87
88CHECK_TYPE_SIZE("int" SIZEOF_INT)
89set(HAVE_INT ${HAVE_SIZEOF_INT})
90CHECK_TYPE_SIZE("long int" SIZEOF_LONG_INT)
91set(HAVE_LONG_INT ${HAVE_SIZEOF_LONG_INT})
92CHECK_TYPE_SIZE("long long int" SIZEOF_LONG_LONG_INT)
93set(HAVE_LONG_LONG_INT ${HAVE_SIZEOF_LONG_LONG_INT})
94CHECK_TYPE_SIZE("unsigned long long int" SIZEOF_UNSIGNED_LONG_LONG_INT)
95set(HAVE_UNSIGNED_LONG_LONG_INT ${HAVE_SIZEOF_UNSIGNED_LONG_LONG_INT})
96CHECK_TYPE_SIZE("size_t" SIZEOF_SIZE_T)
97set(HAVE_SIZE_T ${HAVE_SIZEOF_SIZE_T})
98
99CHECK_FUNCTION_EXISTS(ftime HAVE_FTIME)
100CHECK_FUNCTION_EXISTS(tzset HAVE_TZSET)
101CHECK_FUNCTION_EXISTS(strdup HAVE_STRDUP)
102
103CHECK_INCLUDE_FILE(inttypes.h HAVE_INTTYPES_H)
104CHECK_INCLUDE_FILE(stdint.h HAVE_STDINT_H)
105CHECK_INCLUDE_FILE(dlfcn.h HAVE_DLFCN_H)
106
107if (SIZEOF_LONG_LONG_INT EQUAL 8)
108        set(PRINTF_INT64 "lld")
109        set(PRINTF_UINT64 "llu")
110elseif (WIN32)
111        set(PRINTF_INT64 "I64d")
112        set(PRINTF_UINT64 "I64u")
113else()
114        message(SEND_ERROR "Cannot printf int64 and uint64")
115endif()
116
117if(UNIX)
118    CHECK_LIBRARY_EXISTS(dl dlopen "" HAVE_LIBDL)
119    CHECK_LIBRARY_EXISTS(pthread pthread_open "" HAVE_LIBPTHREAD)
120endif(UNIX)
121
122#find_package(HDF5 REQUIRED)
123#find_package(HDF5)
124find_package(JPEG)
125find_package(XMLRPC)
126#find_package(ZLIB)
127find_package(LibXml2)
128find_package(Doxygen)
129find_package(SWIG)
130find_package(TCL)
131find_package(LATEX)
132
133#Find the java runtime and sdk
134find_package(Java 1.6)
135find_package(JNI)
136
137# set ZLIB_ROOT as hint to find_package
138if (ZLIB_SEARCH)
139    set(ZLIB_ROOT ${ZLIB_SEARCH})
140elseif($ENV{ZLIB_ROOT})
141    set(ZLIB_ROOT $ENV{ZLIB_ROOT})
142else()
143    set(ZLIB_ROOT $HDF5_ROOT_DIR $HDF4_ROOT_DIR $SZIP_ROOT_DIR)
144endif()
145find_package(ZLIB)
146
147#Find the libraries for the build.
148
149find_library(M m)
150#find_library(RPC rpc)
151find_library(DL dl)
152find_library(PTHREAD pthread)
153find_library(TERMCAP termcap)
154find_library(READLINE readline)
155find_library(HISTORY history)
156
157if(M)
158   set(M_LINK "-lm")
159endif(M)
160
161if(DL)
162   set(DL_LINK "-ldl")
163endif(DL)
164
165if(PTHREAD)
166   set(PTHREAD_LINK "-lpthread")
167endif(PTHREAD)
168
169if(SZIPLIB_FOUND)
170   set(SZIP_LINK "-lsz")
171else(SZIPLIB_FOUND)
172   set(SZIP_LIB "")
173endif(SZIPLIB_FOUND)
174
175if(TERMCAP)
176   set(TERMCAP_LINK "")
177endif(TERMCAP)
178
179if(READLINE)
180   set(READLINE_LINK "")
181endif(READLINE)
182
183if(HISTORY)
184   set(HISTORY_LINK "")
185endif(HISTORY)
186
187if (HDF5_FOUND)
188#   set (HDF5_CPP "-DHDF5 -DH5_USE_16_API")
189#   these are needed if HDF5 1.8 has been instaleld with H5_USE_16_API_DEFAULT
190  set(HDF5_API_DEFS "-DH5Acreate_vers=2 -DH5Aiterate_vers=2 -DH5Dcreate_vers=2 -DH5Dopen_vers=2 -DH5Eclear_vers=2 -DH5Eprint_vers=2 -DH5Epush_vers=2 -DH5Eset_auto_vers=2 -DH5Eget_auto_vers=2 -DH5Ewalk_vers=2 -DH5Gcreate_vers=2 -DH5Gopen_vers=2 -DH5Pget_filter_vers=2 -DH5Pget_filter_by_id_vers=2 -DH5Pinsert_vers=2 -DH5Pregister_vers=2 -DH5Rget_obj_type_vers=2 -DH5Tarray_create_vers=2 -DH5Tcommit_vers=2 -DH5Tget_array_dims_vers=2 -DH5Topen_vers=2")
191  set (HDF5_CPP "-DHDF5 -DH5_NO_DEPRECATED_SYMBOLS ${HDF5_API_DEFS}")
192endif (HDF5_FOUND)
193
194#Options
195
196#Build user contributions
197option (BUILD_CONTRIB
198        "Should I build the user contributions?" OFF)
199
200#Build user contributions
201option (BUILD_FORTRAN_BINDINGS
202        "Should I build the fortran bindings?" OFF)
203
204#Use HDF4 in build
205option (BUILD_HDF4
206        "Should I build HDF4 bindings if libraries available?" OFF)
207
208option (BUILD_HDF5
209        "Should I build HDF4 bindings if libraries available?" ON)
210
211#Use XML in build
212option (BUILD_XML
213        "Should I build XML bindings if libraries available?" ON)
214set(BUILD_MXML ${BUILD_XML})
215
216#This is a MINGW build
217option (MINGW_MSYS
218        "We are building under MINGW." OFF)
219
220#This if we have the MS Libraries
221option (HAVE_MS_LIB
222        "We are building under MINGW." OFF)
223
224if (HAVE_MS_LIB)
225    set (MS_LIB LIB)
226endif (HAVE_MS_LIB)
227
228create_have_vars(HDF4 HDF5 MXML)
229
230#Include source files.
231include_directories(${PROJECT_SOURCE_DIR}/include ${HDF5_INCLUDE_DIRS} ${HDF5_INCLUDE_DIR})
232
233if (UNIX)
234    check_add_c_compiler_flags("-Wall -Wno-unused-variable -Wno-sign-compare -Wno-comment")
235    check_add_cxx_compiler_flags("-Wall -Wno-unused-variable -Wno-sign-compare -Wno-comment")
236endif(UNIX)
237
238if (BUILD_FORTRAN_BINDINGS)
239    enable_language(Fortran)
240endif (BUILD_FORTRAN_BINDINGS)
241
242#We need a NXDOCDIR as a place to install the docs for various packages.
243set(NXDOCDIR "share/nexus/doc")
244
245#We need a NXEXAMPLEDIR as a place to install the examples.
246set(NXEXAMPLEDIR  "share/nexus/examples")
247
248#We need a NXINCLUDE and NX_INCLUDE as a place to install the include files.
249set(NXINCLUDE  "include")
250set(NX_INCLUDE "include/nexus")
251
252configure_file("${CMAKE_SOURCE_DIR}/include/nxconfig_h_cmake.in" "${CMAKE_BINARY_DIR}/include/nxconfig.h" @ONLY)
253include_directories("${CMAKE_BINARY_DIR}/include")
254
255if(WIN32)
256# warning 4820 is byte padding in structures
257# warning 4996 is about using _strdup ratherthan strdup etc
258# /W4 rather than /Wall
259# /Zi to get pdb file in all configurations
260    set(NX_CFLAGS "/W4 /wd4820 /wd4996 /Zi")
261    set(NX_CPP -D_CRT_SECURE_NO_WARNINGS)
262        set(CMAKE_DEBUG_POSTFIX "D")
263
264endif(WIN32)
265
266set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${NX_CFLAGS}")
267set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${NX_CFLAGS}")
268
269if (CMAKE_SIZEOF_VOID_P MATCHES "8")
270    set(ARCH64 1)
271else()
272    set(ARCH64 0)
273endif()
274
275# Recurse into the subdirectories.
276add_subdirectory (src)
277add_subdirectory (bindings)
278add_subdirectory (applications)
279#add_subdirectory (config)
280#add_subdirectory (contrib)
281#add_subdirectory (definitions)
282add_subdirectory (doc)
283add_subdirectory (examples)
284add_subdirectory (include)
285#add_subdirectory (InstallerBits)
286#add_subdirectory (macosx_install_kit)
287#add_subdirectory (scripts)
288add_subdirectory (test)
289#add_subdirectory (third_party)
290#add_subdirectory (vms)
291#add_subdirectory (windows)
292#add_subdirectory (Windows_extra)
293
294#
295# set CPack packaging options
296#
297configure_file("${PROJECT_SOURCE_DIR}/CPackOptions.cmake.in" "${PROJECT_BINARY_DIRECTORY}CPackOptions.cmake"  @ONLY)
298set(CPACK_PROJECT_CONFIG_FILE "${PROJECT_BINARY_DIRECTORY}CPackOptions.cmake")
299set (CPACK_GENERATOR TGZ) # not use ZIP on UNIX as problem with symlinks
300if(UNIX)
301    set (CPACK_GENERATOR ${CPACK_GENERATOR};DEB;RPM)
302    #set (CPACK_RPM_PACKAGE_PROVIDES "")
303endif(UNIX)
304if(WIN32)
305    set (CPACK_GENERATOR ${CPACK_GENERATOR};ZIP;NSIS)
306endif(WIN32)
307if(APPLE)
308    set (CPACK_GENERATOR ${CPACK_GENERATOR};PackageMaker)
309endif(APPLE)
310if(CYGWIN)
311endif(CYGWIN)
312# include of CPack must be last
313include(CPack)
Note: See TracBrowser for help on using the repository browser.