-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
100 lines (82 loc) · 3.19 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
cmake_minimum_required(VERSION 2.8)
PROJECT(sHDR)
#Set output paths
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
set(TEST_EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/testbin)
set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
set(LIBRARY_INCLUDE_PATH ${PROJECT_SOURCE_DIR}/include)
set(CMAKE_MODULE_PATH "${sHDR_SOURCE_DIR}/CMake" ${CMAKE_MODULE_PATH})
#load modules
#-----------------------------------------------------------------------------
include(zlib)
include(find) #also Finds SMILI
include(macros)
include(version)
#Add compiler flags
#GCC
if(CMAKE_COMPILER_IS_GNUCC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -fwrapv")
endif(CMAKE_COMPILER_IS_GNUCC)
#MSVC
if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP /bigobj")
endif(MSVC)
# Enable/Disable Build the testing
OPTION(BUILD_SHARED_LIBS "Build the Libraries as shared libraries" ON)
OPTION(BUILD_PROJECTS "Build the projects." ON)
OPTION(BUILD_APPLICATIONS "Build the applications." ON)
OPTION(BUILD_TESTS "Build the tests" OFF)
#dependent options, triggered if another option is set
DEPENDENT_OPTION(USE_ITK "Build all the ITK components" ON "ITK_LIBRARIES" OFF)
DEPENDENT_OPTION(USE_VTK "Build all the VTK components" ON "VTK_USE_FILE_INCLUDED" OFF)
#Check ITK/VTK statuses
IF(USE_ITK AND NOT USE_VTK)
add_definitions(-DITK_ONLY)
message("Disabling non-ITK components. Enable USE_VTK to enable VTK components.")
ENDIF(USE_ITK AND NOT USE_VTK)
IF(USE_VTK AND NOT USE_ITK)
add_definitions(-DVTK_ONLY)
message("Disabling non-VTK components. Enable USE_ITK to enable ITK components.")
ENDIF(USE_VTK AND NOT USE_ITK)
IF(USE_VTK)
message("VTK Version: ${VTK_VERSION}")
ENDIF(USE_VTK)
IF(USE_ITK)
message("ITK Version: ${ITK_VERSION_MAJOR}.${ITK_VERSION_MINOR}")
ENDIF(USE_ITK)
#advanced options
#Important variables for configurations
set(sHDR_INCLUDE_DIRS ${LIBRARY_INCLUDE_PATH} ${LIBRARY_INCLUDE_PATH}/itk-ext)
IF(APPLE)
#Release RPATH handling for MAC OSX
# use, i.e. don't skip the full RPATH for the build tree
SET(CMAKE_MACOSX_RPATH OFF)
MESSAGE("MAC OSX RPATH STUFF")
cmake_policy(SET CMP0042 NEW)
SET(CMAKE_SKIP_BUILD_RPATH FALSE)
# when building, don't use the install RPATH already
# (but later on when installing)
SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
#SET(CMAKE_SKIP_RPATH TRUE)
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
# add the automatically determined parts of the RPATH
# which point to directories outside the build tree to the install RPATH
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
# the RPATH to be used when installing, but only if it's not a system directory
LIST(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
IF("${isSystemDir}" STREQUAL "-1")
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
ENDIF("${isSystemDir}" STREQUAL "-1")
ENDIF(APPLE)
# Recurse into the "apps" subdirectory. This does not actually
# cause another cmake executable to run.
#~ add_subdirectory (src)
IF(BUILD_PROJECTS)
add_subdirectory (projects)
ENDIF(BUILD_PROJECTS)
IF(BUILD_APPLICATIONS)
#~ add_subdirectory (apps)
ENDIF(BUILD_APPLICATIONS)
IF(BUILD_TESTS)
add_subdirectory (tests)
ENDIF(BUILD_TESTS)