-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
229 lines (197 loc) · 6.66 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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
# define minimum cmake version
cmake_minimum_required(VERSION 3.16 FATAL_ERROR)
#if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
#message(FATAL_ERROR “In-source_build_detected!_Create_a_build_folder_and_call_CMake_there”)
#endif()
execute_process(
COMMAND git describe --tags --abbrev=0 | cut -d'v' -f 2
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
OUTPUT_VARIABLE KIPTOOL_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
)
project(nGItool VERSION 1.0 LANGUAGES CXX)
# require C++17
if(NOT DEFINED CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 20)
endif(NOT DEFINED CMAKE_CXX_STANDARD)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE
"Release"
CACHE
STRING
"Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel."
FORCE
)
endif(NOT CMAKE_BUILD_TYPE)
#set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake" )
set(CMAKE_MODULE_PATH "lib" )
# for testing we will need the python interpreter
find_package(PythonInterp REQUIRED)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/applications)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
if("${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}" VERSION_LESS "3.5")
message(
FATAL_ERROR
"Python v3 interpreter must be greater than or equal to 3.5. Found ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}"
)
endif()
if (WIN32)
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/../build-kiptool) # needs to be fixed
find_package(PythonInterp REQUIRED)
find_package(LibXml2 REQUIRED)
find_package(armadillo REQUIRED)
find_package(ZLIB REQUIRED)
find_package(TIFF REQUIRED)
find_package(FFTW3 REQUIRED)
find_package(OpenBLAS REQUIRED)
find_package(pybind11 REQUIRED)
find_package(cfitsio REQUIRED)
# find_package(Nexus REQUIRED)
else()
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
# for testing we will need the python interpreter
find_package(PythonInterp REQUIRED)
find_package(LibXml2 REQUIRED)
find_package(Armadillo REQUIRED)
find_package(ZLIB REQUIRED)
find_package(TIFF REQUIRED)
find_package(FFTW REQUIRED)
find_package(LAPACK REQUIRED)
find_package(BLAS REQUIRED)
find_package(pybind11 REQUIRED)
find_package(CFITSIO REQUIRED)
find_package(Nexus REQUIRED)
endif()
if(NOT WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer")
add_compile_options(
-Wall
-Wextra
-Wpedantic
-Wunused
-Wshadow
-Winit-self
-Wpointer-arith
-Woverloaded-virtual
-Wold-style-cast
-Wcast-qual
-Wcast-align
)
add_compile_options(
$<$<COMPILE_LANGUAGE:CXX>:-Woverloaded-virtual>
$<$<COMPILE_LANGUAGE:CXX>:-fno-operator-names>
)
endif(NOT WIN32)
set(PYTHONDIR kipl)
set(INCLUDEDIR ${CMAKE_INSTALL_INCLUDEDIR})
set(EXPORT_NAME ${PROJECT_NAME}-targets)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
if(NOT APPLE)
set(CMAKE_INSTALL_RPATH $ORIGIN/../lib)
else()
set(CMAKE_INSTALL_RPATH @loader_path/../Frameworks)
endif()
## modules
add_subdirectory(frameworks/ngi/nGIFramework)
add_subdirectory(frameworks/ngi/nGIEstimators)
add_subdirectory(frameworks/ngi/nGIPreprocessing)
## applications
add_subdirectory(applications/nGItool)
if(DYNAMIC_LIB)
# install(
# EXPORT ${EXPORT_NAME}
# DESTINATION "lib/cmake/kipl"
# NAMESPACE kipl::
# )
# include(CMakePackageConfigHelpers)
# configure_package_config_file(
# ${CMAKE_CURRENT_SOURCE_DIR}/cmake/${PROJECT_NAME}-config.cmake.in
# "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake"
# INSTALL_DESTINATION lib/cmake/kipl
# )
# write_basic_package_version_file(
# "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake"
# VERSION "${CMAKE_PROJECT_VERSION}"
# COMPATIBILITY SameMinorVersion # switch to SameMajorVersion after 1.0
# # release
# )
# install(
# FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake"
# "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake"
# DESTINATION lib/cmake/kipl
# )
if (LINUX)
print('Linux')
install(FILES
../lib/libkipl.so.1.0.0
../lib/libModuleConfig.so.1.0.0
../lib/libReconFramework.so.1.0.0
../lib/libStdBackProjectors.so.1.0.0
../lib/libFDKBackProjectors.so.1.0.0
../lib/libImagingAlgorithms.so.1.0.0
../lib/libReaderConfig.so.1.0.0
../lib/libNeXus.so.1.0.0
../lib/libhdf5_cpp.so.11
../lib/libNeXusCPP.so.1.0.0
../lib/libhdf5_hl.so.10
../lib/libhdf5.so.10
../lib/libsz.so.2
# /opt/local/lib/libxml2.2.dylib
# /opt/local/lib/libtiff.5.dylib
DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
execute_process(
COMMAND for f in `ls *.so.1.0.0`; do ln -s $f `basename $f .so.1.0.0`.so.1; done
WORKING_DIRECTORY "${CMAKE_INSTALL_PREFIX}/lib"
)
endif()
if (APPLE)
install(FILES
# ../lib/libkipl.1.0.0.dylib
# ../lib/libModuleConfig.1.0.0.dylib
# ../lib/libReconFramework.1.0.0.dylib
# ../lib/libStdBackProjectors.1.0.0.dylib
# ../lib/libFDKBackProjectors.1.0.0.dylib
# ../lib/libImagingAlgorithms.1.0.0.dylib
# ../lib/libReaderConfig.1.0.0.dylib
# ../imagingsuite/external/mac/lib/libNeXus.1.0.0.dylib
# ../imagingsuite/external/mac/lib//libhdf5_cpp.11.dylib
# ../imagingsuite/external/mac/lib//libNeXusCPP.1.0.0.dylib
# ../imagingsuite/external/mac/lib//libhdf5_hl.10.dylib
# ../imagingsuite/external/mac/lib//libhdf5.10.dylib
# ../imagingsuite/external/mac/lib//libsz.2.dylib
# /opt/local/lib/libxml2.2.dylib
# /opt/local/lib/libtiff.5.dylib
# /opt/local/lib/libfftw3.3.dylib
# /opt/local/lib/libfftw3f.3.dylib
# /opt/local/lib/libcfitsio.dylib
# /opt/local/lib/libarmadillo.10.dylib
DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
execute_process(
COMMAND for f in `ls *.1.0.0.*`; do ln -s $f `basename $f .1.0.0.dylib`.1.dylib; done
WORKING_DIRECTORY "${CMAKE_INSTALL_PREFIX}/lib"
)
endif()
endif(DYNAMIC_LIB)
# turn on testing
#enable_testing()
message(${CMAKE_CURRENT_SOURCE_DIR})
## define test
#add_test(
# NAME
# testBindAverageImage
# COMMAND
# ${CMAKE_COMMAND} -E env IMAGALG_MODULE_PATH=$<TARGET_FILE_DIR:imagalg>
# ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/UnitTests/python/testBindAverageImage.py
# ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/UnitTests/python/testBindAverageImage.py
#)
#
#add_test(
# NAME
# testBindPolynomialCorrection
# COMMAND
# ${CMAKE_COMMAND} -E env IMAGALG_MODULE_PATH=$<TARGET_FILE_DIR:imagalg>
# ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/UnitTests/python/testBindPolynomialCorrection.py
#)