forked from Slicer/SlicerExecutionModel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
170 lines (146 loc) · 7.9 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
project(SlicerExecutionModel)
#-----------------------------------------------------------------------------
cmake_minimum_required(VERSION 2.8.2)
#-----------------------------------------------------------------------------
set(CMAKE_MODULE_PATH ${SlicerExecutionModel_SOURCE_DIR}/CMake ${CMAKE_MODULE_PATH})
if(DEFINED SlicerExecutionModel_INSTALL_BIN_DIR)
set(GenerateCLP_INSTALL_BIN_DIR ${SlicerExecutionModel_INSTALL_BIN_DIR})
set(ModuleDescriptionParser_INSTALL_BIN_DIR ${SlicerExecutionModel_INSTALL_BIN_DIR})
set(tclap_INSTALL_BIN_DIR ${SlicerExecutionModel_INSTALL_BIN_DIR})
endif()
if(DEFINED SlicerExecutionModel_INSTALL_LIB_DIR)
set(GenerateCLP_INSTALL_LIB_DIR ${SlicerExecutionModel_INSTALL_LIB_DIR})
set(ModuleDescriptionParser_INSTALL_LIB_DIR ${SlicerExecutionModel_INSTALL_LIB_DIR})
set(tclap_INSTALL_LIB_DIR ${SlicerExecutionModel_INSTALL_LIB_DIR})
endif()
if(DEFINED SlicerExecutionModel_INSTALL_NO_DEVELOPMENT)
set(GenerateCLP_INSTALL_NO_DEVELOPMENT ${SlicerExecutionModel_INSTALL_NO_DEVELOPMENT})
set(ModuleDescriptionParser_INSTALL_NO_DEVELOPMENT ${SlicerExecutionModel_INSTALL_NO_DEVELOPMENT})
set(tclap_INSTALL_NO_DEVELOPMENT ${SlicerExecutionModel_INSTALL_NO_DEVELOPMENT})
endif()
if(NOT DEFINED SlicerExecutionModel_EXPORT_FILE)
set(SlicerExecutionModel_EXPORT_FILE ${CMAKE_CURRENT_BINARY_DIR}/SlicerExecutionModelTargets.cmake)
# Clear SlicerExecutionModel.cmake
file(WRITE ${SlicerExecutionModel_EXPORT_FILE} "# Generated by CMake, do not edit!")
endif()
if(DEFINED SlicerExecutionModel_LIBRARY_PROPERTIES)
set(ModuleDescriptionParser_LIBRARY_PROPERTIES ${SlicerExecutionModel_LIBRARY_PROPERTIES})
endif()
#-----------------------------------------------------------------------------
# Output directories associated with ModuleDescriptionParser and GenerateCLP subprojects
#-----------------------------------------------------------------------------
foreach(type LIBRARY RUNTIME ARCHIVE)
# Make sure the directory exists
if(DEFINED SlicerExecutionModel_CMAKE_${type}_OUTPUT_DIRECTORY
AND NOT EXISTS ${SlicerExecutionModel_CMAKE_${type}_OUTPUT_DIRECTORY})
message(FATAL_ERROR "SlicerExecutionModel_CMAKE_${type}_OUTPUT_DIRECTORY is set to a non-existing directory [${SlicerExecutionModel_CMAKE_${type}_OUTPUT_DIRECTORY}]")
endif()
if(DEFINED SlicerExecutionModel_CMAKE_${type}_OUTPUT_DIRECTORY)
set(ModuleDescriptionParser_CMAKE_${type}_OUTPUT_DIRECTORY ${SlicerExecutionModel_CMAKE_${type}_OUTPUT_DIRECTORY})
set(GenerateCLP_CMAKE_${type}_OUTPUT_DIRECTORY ${GenerateCLP_CMAKE_${type}_OUTPUT_DIRECTORY})
endif()
endforeach()
#-----------------------------------------------------------------------------
# ParameterSerializer support for ModuleDescriptionParser and GenerateCLP subprojects
#-----------------------------------------------------------------------------
option(SlicerExecutionModel_USE_SERIALIZER "Enable ParameterSerializer support for ModuleDescriptionParser and GenerateCLP." OFF)
if(SlicerExecutionModel_USE_SERIALIZER)
find_package(JsonCpp REQUIRED)
set(ModuleDescriptionParser_USE_SERIALIZER ON)
set(GenerateCLP_USE_SERIALIZER ON)
endif()
#-----------------------------------------------------------------------------
# Note: The default values defined below could be overwritten if passed when configuring
# SlicerExecutionModel project.
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# Define default "output directories" used by SEMMacroBuildCLI.cmake
#-----------------------------------------------------------------------------
if(NOT DEFINED SlicerExecutionModel_DEFAULT_CLI_RUNTIME_OUTPUT_DIRECTORY)
set(SlicerExecutionModel_DEFAULT_CLI_RUNTIME_OUTPUT_DIRECTORY bin)
endif()
if(NOT DEFINED SlicerExecutionModel_DEFAULT_CLI_LIBRARY_OUTPUT_DIRECTORY)
set(SlicerExecutionModel_DEFAULT_CLI_LIBRARY_OUTPUT_DIRECTORY lib)
endif()
if(NOT DEFINED SlicerExecutionModel_DEFAULT_CLI_ARCHIVE_OUTPUT_DIRECTORY)
set(SlicerExecutionModel_DEFAULT_CLI_ARCHIVE_OUTPUT_DIRECTORY lib)
endif()
#-----------------------------------------------------------------------------
# Define default "install destination" used by SEMMacroBuildCLI.cmake
#-----------------------------------------------------------------------------
if(NOT DEFINED SlicerExecutionModel_DEFAULT_CLI_INSTALL_RUNTIME_DESTINATION)
set(SlicerExecutionModel_DEFAULT_CLI_INSTALL_RUNTIME_DESTINATION bin)
endif()
if(NOT DEFINED SlicerExecutionModel_DEFAULT_CLI_INSTALL_LIBRARY_DESTINATION)
set(SlicerExecutionModel_DEFAULT_CLI_INSTALL_LIBRARY_DESTINATION lib)
endif()
if(NOT DEFINED SlicerExecutionModel_DEFAULT_CLI_INSTALL_ARCHIVE_DESTINATION)
set(SlicerExecutionModel_DEFAULT_CLI_INSTALL_ARCHIVE_DESTINATION lib)
endif()
#-----------------------------------------------------------------------------
# Define default "cli library wrapper" used by SEMMacroBuildCLI.cmake
#-----------------------------------------------------------------------------
if(NOT DEFINED SlicerExecutionModel_DEFAULT_CLI_LIBRARY_WRAPPER_CXX)
set(SlicerExecutionModel_DEFAULT_CLI_LIBRARY_WRAPPER_CXX
${CMAKE_CURRENT_SOURCE_DIR}/CMake/SEMCommandLineLibraryWrapper.cxx)
endif()
#-----------------------------------------------------------------------------
# Testing
#-----------------------------------------------------------------------------
include(CTest)
# --------------------------------------------------------------------------
# SETIFEMPTY
# --------------------------------------------------------------------------
## A simple macro to set variables ONLY if it has not been set
## This is needed when stand-alone packages are combined into
## a larger package, and the desired behavior is that all the
## binary results end up in the combined directory.
## The signature has the same signature as the set, it just checks if the
## value is already set before executing.
if(NOT SETIFEMPTY)
macro(SETIFEMPTY)
set(KEY ${ARGV0})
set(VALUE ${ARGV1})
if(NOT ${KEY})
set(${ARGV})
endif(NOT ${KEY})
endmacro()
endif(NOT SETIFEMPTY)
###
SETIFEMPTY(TCLAP_DIR ${CMAKE_CURRENT_BINARY_DIR}/tclap CACHE PATH "Location of TCLAPConfig.cmake" FORCE)
add_subdirectory(tclap)
SETIFEMPTY(ModuleDescriptionParser_DIR ${CMAKE_CURRENT_BINARY_DIR}/ModuleDescriptionParser CACHE PATH "Location of ModuleDescriptionParserConfig.cmake" FORCE)
add_subdirectory(ModuleDescriptionParser)
SETIFEMPTY(GenerateCLP_DIR ${CMAKE_CURRENT_BINARY_DIR}/GenerateCLP CACHE PATH "Location of GenerateCLPConfig.cmake" FORCE)
add_subdirectory(GenerateCLP)
# --------------------------------------------------------------------------
# Set INCLUDE_DIRS variable
# --------------------------------------------------------------------------
set(_additional_include_dirs )
if(SlicerExecutionModel_USE_SERIALIZER)
set(_additional_include_dirs ${ParameterSerializer_INCLUDE_DIRS} ${JsonCpp_INCLUDE_DIRS} )
endif()
set(${PROJECT_NAME}_INCLUDE_DIRS
${ModuleDescriptionParser_INCLUDE_DIRS}
${GenerateCLP_INCLUDE_DIRS}
${TCLAP_INCLUDE_DIRS}
${_additional_include_dirs}
CACHE INTERNAL "${PROJECT_NAME} include dirs" FORCE
)
# --------------------------------------------------------------------------
# Export target
# --------------------------------------------------------------------------
export(TARGETS ${ModuleDescriptionParser_TARGETS} ${GenerateCLP_TARGETS}
FILE ${SlicerExecutionModel_EXPORT_FILE})
# --------------------------------------------------------------------------
# Configure support files
# --------------------------------------------------------------------------
include(GenerateSlicerExecutionModelConfig.cmake)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/UseSlicerExecutionModel.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/UseSlicerExecutionModel.cmake COPYONLY)
file(GLOB allscripts "CMake/*")
foreach(SCRIPT ${allscripts})
get_filename_component(_fileName ${SCRIPT} NAME)
configure_file(${SCRIPT}
${CMAKE_CURRENT_BINARY_DIR}/CMake/${_fileName} COPYONLY IMMEDIATE)
endforeach()