-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
179 lines (155 loc) · 6.79 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
#
# Dectris Ltd.
# Neuenhoferstrasses 107, CH - 5400 Baden, Switzerland.
# All rights reserved. Copyright(C) 2012 - 2014
#
#
cmake_minimum_required (VERSION 2.8.11)
project (dectris-hdf5)
if(NOT CMAKE_BUILD_TYPE)
set ( CMAKE_BUILD_TYPE Release )
endif()
set (VERSION_MAJOR 1)
set (VERSION_MINOR 8)
set (VERSION_PATCH 11)
set (VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})
option (CPP11 "Compile with c++11" ON)
if(CPP11)
MESSAGE(STATUS "Compiling with c++11 ON")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
else()
MESSAGE(STATUS "Compiling with c++11 OFF")
endif()
if (APPLE)
set (CMAKE_CXX_FLAGS_RELEASE "-O3 -mmacosx-version-min=10.7")
set (CMAKE_EXE_LINKER_FLAGS "-O3 -mmacosx-version-min=10.7")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
endif()
# Tell hdf5 that we are manually overriding certain settings
set(HDF5_EXTERNALLY_CONFIGURED 1)
# Avoid duplicating names of installed libraries
set(HDF5_EXTERNAL_LIB_PREFIX "dectris")
# set options for bulding hdf5
set (BUILD_SHARED_LIBS ON CACHE BOOL "Build Shared Libraries")
set (HDF5_BUILD_TOOLS ON CACHE BOOL "Build HDF5 Tools")
set (HDF5_BUILD_HL_LIB ON CACHE BOOL "Build HIGH Level HDF5 Library")
set (HDF5_BUILD_CPP_LIB ON CACHE BOOL "Build c++ API")
set (HDF5_ENABLE_Z_LIB_SUPPORT ON CACHE BOOL "Enable zlib")
set (HDF5_INSTALL_INCLUDE_DIR include/dectrishdf5)
if(WIN32)
### INSTALL ZLIB ON WINDOWS
#
# Download from http://zlib.net/zlib128.zip and extract to zlib128
# cd zlib128
# mk build
# cd build
# cmake -G "MinGW Makefiles" -DCMAKE_INSTALL_PREFIX=zlib128 ..\zlib-1.2.8
# mingw32-make -j8
# mingw32-make install
# cp -r zlib128 C:\
#
# change path variable (as administrator)
# $oldPath=(Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH).Path
# $newPath=$oldPath+';C:\zlib128\bin'
# Set-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH -Value $newPath
#
#
set(CMAKE_PREFIX_PATH C:/zlib128 )
endif()
# Add the sub project
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
add_subdirectory (hdf5-${VERSION})
# add_subdirectory(playground)
set (INCLUDE_INSTALL_DIR ${HDF5_INSTALL_INCLUDE_DIR})
if (WIN32)
set (LIB_INSTALL_DIR bin/ )
set (STATIC_INSTALL_DIR lib/ )
set (CMAKE_INSTALL_DIR cmake/)
else ()
IF (CMAKE_BUILD_TYPE MATCHES Debug)
set (CMAKE_INSTALL_DIR lib/DectrisHdf5Debug/cmake/)
ELSE()
set (CMAKE_INSTALL_DIR lib/DectrisHdf5/cmake/)
ENDIF()
set (LIB_INSTALL_DIR lib/ )
set (STATIC_INSTALL_DIR lib/ )
endif ()
include (CMakePackageConfigHelpers)
IF (CMAKE_BUILD_TYPE MATCHES Debug)
configure_package_config_file (cmake/DectrisHdf5DebugConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/DectrisHdf5DebugConfig.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_DIR}
PATH_VARS INCLUDE_INSTALL_DIR LIB_INSTALL_DIR STATIC_INSTALL_DIR)
write_basic_package_version_file (${CMAKE_CURRENT_BINARY_DIR}/DectrisHdf5DebugConfig-version.cmake
VERSION ${VERSION}
COMPATIBILITY ExactVersion )
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/DectrisHdf5DebugConfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/DectrisHdf5DebugConfig-version.cmake
DESTINATION ${CMAKE_INSTALL_DIR} )
ELSE()
configure_package_config_file (cmake/DectrisHdf5Config.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/DectrisHdf5Config.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_DIR}
PATH_VARS INCLUDE_INSTALL_DIR LIB_INSTALL_DIR STATIC_INSTALL_DIR)
write_basic_package_version_file (${CMAKE_CURRENT_BINARY_DIR}/DectrisHdf5Config-version.cmake
VERSION ${VERSION}
COMPATIBILITY ExactVersion )
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/DectrisHdf5Config.cmake ${CMAKE_CURRENT_BINARY_DIR}/DectrisHdf5Config-version.cmake
DESTINATION ${CMAKE_INSTALL_DIR} )
ENDIF()
#
# Generic Package Information
#
set (CPACK_PACKAGE_VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})
set (CPACK_PACKAGE_VENDOR "Dectris Ltd.")
#
# Linux
if (UNIX)
set (CPACK_RPM_PACKAGE_ARCH "x86_64")
set (CPACK_RPM_PACKAGE_ARCHITECTURE "x86_64")
set (CPACK_RPM_PACKAGE_VENDOR ${CPACK_PACKAGE_VENDOR})
set (CPACK_PACKAGE_NAME "dectris-hdf5")
set (CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-$ENV{BUILD_NUMBER}.${CPACK_RPM_PACKAGE_ARCHITECTURE}")
set (CPACK_PACKAGE_DESCRIPTION "${CPACK_PACKAGE_NAME} build $ENV{BUILD_NUMBER}")
set (CPACK_RPM_PACKAGE_SUMMARY "${CPACK_PACKAGE_NAME} build $ENV{BUILD_NUMBER}")
set (CPACK_PACKAGE_RELEASE $ENV{BUILD_NUMBER})
set (CPACK_RPM_PACKAGE_RELEASE $ENV{BUILD_NUMBER})
set (CPACK_RPM_PACKAGE_REQUIRES "zlib")
# This is not actually used by cmake but enlists the packages needed for building (in addition to the ones
# listed above) but not used for running. This information is processes by the "satiate.sh" script
set (CPACK_BUILD_RPM_PACKAGE_REQUIRES "make, zlib-devel")
message (STATUS "> Creating RPM ${CPACK_PACKAGE_FILE_NAME}")
message (STATUS "> DIST_TAG ${DIST_TAG}")
message (STATUS "> ENV{DIST_TAG} $ENV{DIST_TAG}")
message (STATUS "> BUILD_NUMBER ${BUILD_NUMBER}")
message (STATUS "> ENV{BUILD_NUMBER} $ENV{BUILD_NUMBER}")
set (CPACK_GENERATOR RPM)
set (CPACK_PACKAGING_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
set (CPACK_PACKAGE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
set (CPACK_PACKAGE_INSTALL_DIRECTORY "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")
# Exclude system folders to fix problem with CPack >2.8.11 and RPM 4.11.1
# which are by default taking over control of system folders....
set (CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST "/usr/local" "/usr/local/lib" "/usr/local/include")
endif ()
#
# Windows
if (WIN32)
# Only VolP is allowed to change anything in this section
set (CPACK_PACKAGE_NAME "DectrisHdf5")
set (CPACK_PACKAGE_INSTALL_DIRECTORY "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")
# Generate guid for every major release
execute_process (COMMAND
python -c "import uuid; print uuid.uuid5(uuid.NAMESPACE_DNS,\"DectrisHdf5-${VERSION}.dectris.com\")"
OUTPUT_VARIABLE CPACK_WIX_UPGRADE_GUID
OUTPUT_STRIP_TRAILING_WHITESPACE
)
message (STATUS "WIX Upgrade GUID ${CPACK_WIX_UPGRADE_GUID}" )
set (CPACK_GENERATOR WIX)
endif()
include (CPack)
#
# Uninstall Target
#
configure_file(
"cmake/cmake_uninstall.cmake.in"
"cmake/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P cmake/cmake_uninstall.cmake)