-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
215 lines (169 loc) · 8.43 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
#/*============================================================================
#
# CMAKECATCHOPENMP: Demo project for OpenMP examples.
#
# Copyright (c) University College London (UCL). All rights reserved.
#
# This software is distributed WITHOUT ANY WARRANTY; without even
# the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE.
#
# See LICENSE.txt in the top level directory for details.
#
#============================================================================*/
######################################################################
# Set the minimum CMake version.
######################################################################
set(CMAKECATCHOPENMP_CMAKE_MINIMUM_REQUIRED_VERSION 3.5)
cmake_minimum_required(VERSION ${CMAKECATCHOPENMP_CMAKE_MINIMUM_REQUIRED_VERSION})
###################################################################################
# Set some CMake Policies.
# See http://cmake.org/cmake/help/cmake-2-8-docs.html#section_Policies for details.
###################################################################################
set(project_policies )
foreach(policy ${project_policies})
if(POLICY ${policy})
cmake_policy(SET ${policy} NEW)
endif()
endforeach()
###############################################################################
# Setup project name, and version.
###############################################################################
project(CMAKECATCHOPENMP VERSION 0.0.0)
######################################################################
# Setup the path to load CMake macros, and extra CMake files.
# This means cmake can 'see' or 'use' files in the CMake folder.
######################################################################
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/CMake)
######################################################################
# Include extra CMake stuff for configuring this project.
######################################################################
include(mitkFunctionCheckCompilerFlags)
include(mitkFunctionGetGccVersion)
######################################################################
# Set main build options.
######################################################################
option(BUILD_TESTING "Build Unit tests." OFF)
option(BUILD_SHARED_LIBS "Build Shared Libraries" OFF)
option(CMAKECATCHMPI_USE_OPENMP "Use OpenMP." ON)
######################################################################
# Setup Testing (dashboards etc.).
######################################################################
include(mjcSetupTesting)
######################################################################
# Setting supported build types. Should ONLY be Release or Debug.
######################################################################
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Valid options are Release or Debug" FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Release" "Debug")
endif()
if (NOT (CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "Debug"))
message(FATAL_ERROR "Build type \"${CMAKE_BUILD_TYPE}\" is not supported.")
endif()
if(WIN32)
# Restrict the generated configuration to be what we configured above.
# No point creating project files for build types that will not compile.
# Note: it's set to FORCE so that both CMAKE_BUILD_TYPE and CMAKE_CONFIGURATION_TYPES match up.
set(CMAKE_CONFIGURATION_TYPES ${CMAKE_BUILD_TYPE} CACHE STRING "Build configurations to generate." FORCE)
mark_as_advanced(CMAKE_CONFIGURATION_TYPES)
endif()
######################################################################
# Choose C++ standard. Currently 11, as we try to support VS2013.
######################################################################
set(CMAKECATCHOPENMP_CXX_STANDARD 11)
set(CMAKE_CXX_EXTENSIONS 0)
set(CMAKE_CXX_STANDARD ${CMAKECATCHOPENMP_CXX_STANDARD})
set(CMAKE_CXX_STANDARD_REQUIRED 1)
if(CMAKE_COMPILER_IS_GNUCXX)
mitkFunctionGetGccVersion(${CMAKE_CXX_COMPILER} GCC_VERSION)
else()
set(GCC_VERSION 0)
endif()
# This is necessary to avoid problems with compile feature checks.
# CMAKE_CXX_STANDARD seems to only set the -std=c++11 flag for targets.
# However, compile flag checks also need to be done with -std=c++11.
# The CMAKECATCHOPENMP_CXX11_FLAG variable is also used for external projects
# build during the CMAKECATCHOPENMP super-build.
mitkFunctionCheckCompilerFlags("-std=c++11" CMAKECATCHOPENMP_CXX11_FLAG)
if(NOT CMAKECATCHOPENMP_CXX11_FLAG)
# Older gcc compilers use -std=c++0x
mitkFunctionCheckCompilerFlags("-std=c++0x" CMAKECATCHOPENMP_CXX11_FLAG)
endif()
######################################################################
# Force MSVC runtime. Depends on BUILD_SHARED_LIBS.
######################################################################
include(mjcSetupMSVCRuntime)
######################################################################
# Print out where the source and binary folders
# are, just to make it really explicit.
######################################################################
message("CMAKE_SOURCE_DIR=${CMAKE_SOURCE_DIR}")
message("CMAKE_BINARY_DIR=${CMAKE_BINARY_DIR}")
######################################################################
# Additionally add the build folder, now we are building main project.
######################################################################
list(APPEND CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR})
######################################################################
# Copy some reference files to output.
######################################################################
configure_file(${CMAKE_SOURCE_DIR}/LICENSE.txt ${CMAKE_BINARY_DIR}/LICENSE.txt @ONLY)
install(FILES ${CMAKE_BINARY_DIR}/LICENSE.txt DESTINATION . COMPONENT CONFIG)
configure_file(${CMAKE_SOURCE_DIR}/README.md ${CMAKE_BINARY_DIR}/README.md @ONLY)
######################################################################
# Organise module/plugin/etc projects better within the IDE.
######################################################################
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
######################################################################
# Add Optional Requirements
######################################################################
if(WIN32)
set(_library_sub_dir "bin")
else()
set(_library_sub_dir "lib")
endif()
######################################################################
# Compilation specific stuff, like flags etc.
######################################################################
if(WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNOMINMAX /W2")
set(CMAKE_CXX_WARNING_LEVEL 2)
endif(WIN32)
if(WIN32 AND NOT BUILD_SHARED_LIBS)
add_definitions(-DCMAKECATCHOPENMP_STATIC)
endif()
if(UNIX)
mitkFunctionCheckCompilerFlags("-Wno-deprecated-declarations" CMAKECATCHOPENMP_NO_DEPRECATED_FLAG)
if(CMAKECATCHOPENMP_NO_DEPRECATED_FLAG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKECATCHOPENMP_NO_DEPRECATED_FLAG}" CACHE STRING "FLags used by the compiler during all build types." FORCE)
endif()
endif()
include(ccmpiIncludeOpenMP)
######################################################################
# A few shortcuts for lists of libraries.
######################################################################
set(CMAKECATCHOPENMP_LIBRARIES cmakecatchopenmp)
set(ALL_LIBRARIES ${CMAKECATCHOPENMP_LIBRARIES})
######################################################################
# Set up a few paths.
######################################################################
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
set(CMAKECATCHOPENMP_INSTALL_LIB_DIR lib)
set(CMAKECATCHOPENMP_INSTALL_INC_DIR include)
set(CMAKECATCHOPENMP_INSTALL_BIN_DIR bin)
foreach(type LIBRARY RUNTIME ARCHIVE)
set(output_dir ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_${type}_OUTPUT_DIRECTORY ${output_dir} CACHE INTERNAL "Single output directory for building all libraries.")
mark_as_advanced(CMAKE_${type}_OUTPUT_DIRECTORY)
endforeach()
include_directories(${CMAKE_SOURCE_DIR}/Code/3rdParty/Eigen-3.2.2.1)
include_directories(${CMAKE_SOURCE_DIR}/Code/Lib)
include_directories(${CMAKE_BINARY_DIR})
######################################################################
# Add our main code folders. This is where all our functionality is.
######################################################################
add_subdirectory(Code)
if(BUILD_TESTING)
set(TEMP_DIR ${CMAKE_BINARY_DIR}/Testing/Temporary)
include_directories(${CMAKE_SOURCE_DIR}/Testing/)
add_subdirectory(Testing)
endif()