-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
155 lines (124 loc) · 4.75 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
cmake_minimum_required(VERSION 3.1)
project(xgandalf VERSION 1.0)
include(GNUInstallDirs)
option(XGANDALF_BUILD_EXECUTABLE "Build the test executable for xgandalf" OFF)
option(USE_INSTALLED_PRECOMUTED_DATA "Use the installation path for getting the precomputed data
(as oposite to the source location)" ON)
if(USE_INSTALLED_PRECOMUTED_DATA)
add_definitions(-DPRECOMPUTED_DATA_DIR=${CMAKE_INSTALL_FULL_DATADIR}/xgandalf/precomputedSamplePoints)
else(USE_INSTALLED_PRECOMUTED_DATA)
add_definitions(-DPRECOMPUTED_DATA_DIR=${PROJECT_SOURCE_DIR}/precomputedSamplePoints)
endif(USE_INSTALLED_PRECOMUTED_DATA)
# Set a default build type if none was specified
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to 'Release' as none was specified.")
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
"MinSizeRel" "RelWithDebInfo")
endif()
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
# user defined options for MKL
option(MKL_USE_parallel "Use MKL parallel" False)
option(MKL_USE_sdl "Single Dynamic Library or static/dynamic" False)
set(BLA_STATIC True CACHE STRING "Use static linking instead of dynamic linking for MKL")
set(MKL_USE_interface "lp64" CACHE STRING "for Intel(R)64 compatible arch: ilp64/lp64 or for ia32 arch: cdecl/stdcall")
set(BOOST_ALL_NO_LIB 1)
find_package(Boost 1.60.0)
find_package(Eigen3 3.3.7 NO_MODULE)
find_package(MKL)
include_directories(include)
set(SOURCES src/Dbscan.cpp
src/DetectorToReciprocalSpaceTransform.cpp
src/ExperimentSettings.cpp
src/HillClimbingOptimizer.cpp
src/IndexerAutocorrPrefit.cpp
src/IndexerBase.cpp
src/IndexerPlain.cpp
src/InverseSpaceTransform.cpp
src/Lattice.cpp
src/LatticeAssembler.cpp
src/pointAutocorrelation.cpp
src/refinement.cpp
src/samplePointsFiltering.cpp
src/SamplePointsGenerator.cpp
src/SparsePeakFinder.cpp
src/ReciprocalToRealProjection.cpp
src/SimpleMonochromaticDiffractionPatternPrediction.cpp
src/SimpleMonochromaticProjection.cpp
src/adaptions/crystfel/IndexerPlain.cpp
src/adaptions/crystfel/ExperimentSettings.cpp
src/adaptions/crystfel/indexerData.cpp
src/adaptions/crystfel/lattice.cpp
src/adaptions/crystfel/projectionData.cpp
src/adaptions/crystfel/SimpleMonochromaticDiffractionPatternPrediction.cpp
)
set(SOURCES_test src/main.cpp
src/tests.cpp
)
if(XGANDALF_BUILD_EXECUTABLE)
add_executable(xgandalf ${SOURCES} ${SOURCES_test})
else(XGANDALF_BUILD_EXECUTABLE)
add_library(xgandalf SHARED ${SOURCES})
endif(XGANDALF_BUILD_EXECUTABLE)
if(Boost_FOUND)
target_include_directories(xgandalf SYSTEM PUBLIC ${Boost_INCLUDE_DIRS})
else(Boost_FOUND)
message("Boost not found, using internal Boost.")
target_include_directories(xgandalf SYSTEM PUBLIC include/Boost)
install(
DIRECTORY include/Boost/
DESTINATION include/boost
)
endif(Boost_FOUND)
if(EIGEN3_FOUND)
target_link_libraries (xgandalf PUBLIC Eigen3::Eigen)
else()
message("Eigen not found, using internal Eigen.")
target_include_directories(xgandalf SYSTEM PUBLIC include/Eigen)
install(
DIRECTORY include/Eigen/
DESTINATION include/eigen3
)
endif()
if (MKL_FOUND)
target_compile_definitions(xgandalf PUBLIC ${MKL_DEFINITIONS} USE_MKL EIGEN_USE_MKL_ALL)
target_link_libraries(xgandalf PRIVATE ${MKL_LIBRARIES})
target_include_directories(xgandalf PRIVATE ${MKL_INCLUDE_DIR})
endif(MKL_FOUND)
# Test whether the compiler is Microsoft Visual C(++).
if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
target_compile_options(xgandalf PUBLIC /W2 /wd4305 /wd4244 /wd4099)
else(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
target_compile_options(xgandalf PUBLIC -Wall)
endif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
set_target_properties(xgandalf PROPERTIES
CXX_STANDARD 11
CXX_STANDARD_REQUIRED ON
CXX_EXTENSIONS OFF
)
install(TARGETS xgandalf
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
install(
DIRECTORY include/
DESTINATION include/xgandalf
FILES_MATCHING
PATTERN "*.h"
PATTERN "Eigen/*" EXCLUDE
PATTERN "Eigen" EXCLUDE
PATTERN "Boost" EXCLUDE
PATTERN "Boost/*" EXCLUDE
)
install(
DIRECTORY precomputedSamplePoints/
DESTINATION share/xgandalf/precomputedSamplePoints
FILES_MATCHING
PATTERN "*"
PATTERN "*.m" EXCLUDE
)
# xgandalf.pc
configure_file(xgandalf.pc.in xgandalf.pc)
install(FILES ${CMAKE_BINARY_DIR}/xgandalf.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)