-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
194 lines (163 loc) · 7.46 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
cmake_minimum_required(VERSION 2.8)
set(project_policies
CMP0001 # NEW: CMAKE_BACKWARDS_COMPATIBILITY should no longer be used.
CMP0002 # NEW: Logical target names must be globally unique.
CMP0003 # NEW: Libraries linked via full path no longer produce linker search paths.
CMP0004 # NEW: Libraries linked may NOT have leading or trailing whitespace.
CMP0005 # NEW: Preprocessor definition values are now escaped automatically.
CMP0006 # NEW: Installing MACOSX_BUNDLE targets requires a BUNDLE DESTINATION.
CMP0007 # NEW: List command no longer ignores empty elements.
CMP0008 # NEW: Libraries linked by full-path must have a valid library file name.
CMP0009 # NEW: FILE GLOB_RECURSE calls should not follow symlinks by default.
CMP0010 # NEW: Bad variable reference syntax is an error.
CMP0011 # NEW: Included scripts do automatic cmake_policy PUSH and POP.
CMP0012 # NEW: if() recognizes numbers and boolean constants.
CMP0013 # NEW: Duplicate binary directories are not allowed.
CMP0014 # NEW: Input directories must have CMakeLists.txt
CMP0042
CMP0048)
foreach(policy ${project_policies})
if(POLICY ${policy})
cmake_policy(SET ${policy} NEW)
endif()
endforeach()
cmake_policy(SET CMP0048 NEW)
PROJECT(cmic_dev_jc
VERSION 1.0)
set(GIF_VERSION_MAJOR 3)
set(GIF_VERSION_MINOR 0)
set(GIF_VERSION_PATCH 0)
include(ExternalProject)
set(${PROJECT_NAME}_ARCHIVE_OUTPUT_DIRECTORY lib)
set(${PROJECT_NAME}_RUNTIME_OUTPUT_DIRECTORY bin)
set(${PROJECT_NAME}_LIBRARY_OUTPUT_DIRECTORY lib)
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/${${PROJECT_NAME}_LIBRARY_OUTPUT_DIRECTORY})
set(ARCHIVE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/${${PROJECT_NAME}_ARCHIVE_OUTPUT_DIRECTORY})
set(RUNTIME_OUTPUT_PATH ${CMAKE_BINARY_DIR}/${${PROJECT_NAME}_RUNTIME_OUTPUT_DIRECTORY})
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/${${PROJECT_NAME}_RUNTIME_OUTPUT_DIRECTORY})
set(LIBRARY_INSTALL_OUTPUT_PATH ${CMAKE_INSTALL_PREFIX}/${${PROJECT_NAME}_LIBRARY_OUTPUT_DIRECTORY})
set(ARCHIVE_INSTALL_OUTPUT_PATH ${CMAKE_INSTALL_PREFIX}/${${PROJECT_NAME}_ARCHIVE_OUTPUT_DIRECTORY})
set(RUNTIME_INSTALL_OUTPUT_PATH ${CMAKE_INSTALL_PREFIX}/${${PROJECT_NAME}_RUNTIME_OUTPUT_DIRECTORY})
set(EXECUTABLE_INSTALL_OUTPUT_PATH ${CMAKE_INSTALL_PREFIX}/${${PROJECT_NAME}_RUNTIME_OUTPUT_DIRECTORY})
set(${PROJECT_NAME}_VERSION_MAJOR 1 CACHE STRING "${PROJECT_NAME} major version number.")
set(${PROJECT_NAME}_VERSION_MINOR 0 CACHE STRING "${PROJECT_NAME} minor version number.")
set(${PROJECT_NAME}_VERSION_BUILD 0 CACHE STRING "${PROJECT_NAME} build version number.")
set(${PROJECT_NAME}_VERSION
"${${PROJECT_NAME}_VERSION_MAJOR}.${${PROJECT_NAME}_VERSION_MINOR}.${${PROJECT_NAME}_VERSION_BUILD}")
mark_as_advanced(${PROJECT_NAME}_VERSION_MAJOR)
mark_as_advanced(${PROJECT_NAME}_VERSION_MINOR)
mark_as_advanced(${PROJECT_NAME}_VERSION_BUILD)
#-----------------------------------------------------------------------------
# Add compiler flags ${PROJECT_NAME} needs to work on this platform. This must be
# done AFTER the call to CMAKE_EXPORT_BUILD_SETTINGS.
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(${PROJECT_NAME}_REQUIRED_C_FLAGS)
set(${PROJECT_NAME}_REQUIRED_CXX_FLAGS)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${${PROJECT_NAME}_REQUIRED_C_FLAGS}")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${${PROJECT_NAME}_REQUIRED_CXX_FLAGS}")
set(CMAKE_MODULE_PATH
${CMAKE_BINARY_DIR}
${CMAKE_SOURCE_DIR}/CMake
${CMAKE_SOURCE_DIR}/CMake/CMakeExternals
${CMAKE_MODULE_PATH}
)
set(${PROJECT_NAME}_INCLUDE_DIRS
${PROJECT_SOURCE_DIR}/Utilities
${PROJECT_SOURCE_DIR}/Utilities/rapidxml
${PROJECT_SOURCE_DIR}/Code
${PROJECT_SOURCE_DIR}/Code/Libraries
${PROJECT_SOURCE_DIR}/Code/Applications
)
include_directories(
${${PROJECT_NAME}_INCLUDE_DIRS}
)
option(BUILD_SHARED_LIBS "Build with shared libraries." OFF)
if(BUILD_SHARED_LIBS)
set(${PROJECT_NAME}_BUILD_TYPE
SHARED
)
endif()
find_package(NIFTYREG REQUIRED)
find_package(NIFTYSEG REQUIRED)
#-----------------------------------------------------------------------------
# Search for Eigen. Download and install if not found
#-----------------------------------------------------------------------------
option(USE_SYSTEM_EIGEN "Use an already installed version of the Eigen library" OFF)
if(USE_SYSTEM_EIGEN)
find_package(EIGEN REQUIRED)
else()
set(${PROJECT_NAME}_VERSION_EIGEN "ffa86ffb5570" CACHE STRING "Version of EIGEN" FORCE)
set(${PROJECT_NAME}_MD5_SUM_EIGEN a77de843845c4805b5fc18f64c74a2e6 CACHE STRING "MD5 check sum for EIGEN" FORCE)
set(${PROJECT_NAME}_LOCATION_EIGEN
"https://gitlab.com/libeigen/eigen/-/archive/3.3-beta1/eigen-3.3-beta1.tar.gz"
CACHE STRING "Location of Eigen" FORCE)
mark_as_advanced(FORCE ${PROJECT_NAME}_VERSION_EIGEN)
mark_as_advanced(FORCE ${PROJECT_NAME}_MD5_SUM_EIGEN)
mark_as_advanced(FORCE ${PROJECT_NAME}_LOCATION_EIGEN)
ExternalProject_Add(Eigen
URL ${${PROJECT_NAME}_LOCATION_EIGEN}
URL_MD5 ${${PROJECT_NAME}_MD5_SUM_EIGEN}
PREFIX ${PROJECT_BINARY_DIR}/Eigen
DOWNLOAD_DIR ${PROJECT_BINARY_DIR}/Eigen/download
SOURCE_DIR ${PROJECT_BINARY_DIR}/Eigen/source
STAMP_DIR ${PROJECT_BINARY_DIR}/Eigen/stamps
TMP_DIR ${PROJECT_BINARY_DIR}/Eigen/tmp
BINARY_DIR ${PROJECT_BINARY_DIR}/Eigen/build
CONFIGURE_COMMAND ""
UPDATE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
)
set(EIGEN_INCLUDE_DIR ${PROJECT_BINARY_DIR}/Eigen/source)
install(DIRECTORY ${EIGEN_INCLUDE_DIR}/Eigen DESTINATION include)
endif()
include_directories(${EIGEN_INCLUDE_DIR})
if(NIFTYREG_FOUND AND NIFTYSEG_FOUND)
include_directories(
${${PROJECT_NAME}_INCLUDE_DIRS}
${NIFTYREG_INCLUDE_DIR}
${NIFTYSEG_INCLUDE_DIR}
)
set(CMAKE_LIBRARY_PATH
${CMAKE_LIBRARY_PATH}
${NIFTYREG_LIBRARY_DIR}
${NIFTYSEG_LIBRARY_DIR}
)
link_directories(
${CMAKE_LIBRARY_PATH}
)
option(USE_OPENMP "To use openMP for multi-CPU processing" OFF)
if(USE_OPENMP)
find_package(OpenMP)
if(NOT OPENMP_FOUND)
set(USE_OPENMP OFF CACHE BOOL "To use openMP for multi-CPU processing" FORCE)
message(WARNING "OpenMP does not appear to be supported by your compiler, forcing USE_OPENMP to OFF")
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
endif()
endif()
option(USE_SSE "To use SSE for some computations" OFF)
find_package(Git)
if(GIT_FOUND)
execute_process(
COMMAND git rev-parse HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_COMMIT_HASH
RESULT_VARIABLE GIT_FAILED
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(NOT GIT_FAILED)
add_definitions(-D_GIT_HASH=\"${GIT_COMMIT_HASH}\")
message(STATUS "Found Git - the hash is added to the source.")
else(NOT GIT_FAILED)
add_definitions(-D_GIT_HASH="${GIF_VERSION_MAJOR}.${GIF_VERSION_MINOR}.${GIF_VERSION_PATCH}")
endif(NOT GIT_FAILED)
else(GIT_FOUND)
add_definitions(-D_GIT_HASH="${GIF_VERSION_MAJOR}.${GIF_VERSION_MINOR}.${GIF_VERSION_PATCH}")
endif(GIT_FOUND)
add_subdirectory(Utilities)
add_subdirectory(Code)
endif()