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