-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathCMakeLists.txt
154 lines (126 loc) · 5.37 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
# Build a debug or release version
# Debug:
# cmake -DCMAKE_BUILD_TYPE=Debug .
# Release:
# cmake -DCMAKE_BUILD_TYPE=Release .
cmake_minimum_required (VERSION 3.1.0 FATAL_ERROR) # Required for C++11 support
set(VERSION "2.0.0")
project (CRAAM)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED)
# enable colors in the output
SET(CMAKE_COLOR_MAKEFILE ON)
# And optionally
#SET(CMAKE_VERBOSE_MAKEFILE ON)
# **** Build type ****
if(NOT CMAKE_BUILD_TYPE)
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()
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(IS_DEBUG TRUE)
endif()
# **** Find packages ****
find_package(OpenMP)
find_package(Boost COMPONENTS unit_test_framework )
find_package(Doxygen)
if(${Boost_FOUND} LESS 1)
message(WARNING "Unit tests (testit) require Boost unit test library and may not compile otherwise." )
endif()
# DEBUG
# Prints all variables (for debugging)
#get_cmake_property(_variableNames VARIABLES)
#foreach (_variableName ${_variableNames})
# message(STATUS "${_variableName}=${${_variableName}}")
#endforeach()
# DEBUG
#set(CMAKE_VERBOSE_MAKEFILE on) - just run make
# **** TURN FEATURES ON AND OFF ****
option (BUILD_TESTS "Build tests (requires Boost)" ON)
option (BUILD_DOCUMENTATION "Build source code documentation" ${DOXYGEN_FOUND})
# **** CONFIGURATION ****
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin)
# use position-independent code
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
# use OpenMP if possible
if (OPENMP_FOUND)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif()
# set gcc-specific parameters
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "4.9.0")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wpedantic -Wuninitialized")
endif()
set(CMAKE_CXX_FLAGS_DEBUG "-g -rdynamic") # -D_GLIBCXX_DEBUG -- incompatible with boost :(
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -march=native -mtune=native")
endif()
# **** PROCESS CONFIGURATION FILE ****
# configure a header file to pass some of the CMake settings
# to the source code
configure_file (
${CMAKE_CURRENT_SOURCE_DIR}/craam/config.hpp.in
${CMAKE_CURRENT_SOURCE_DIR}/craam/config.hpp
)
# **** SOURCE FILES ****
include_directories (. )
# do not report warnings from included libraries
include_directories (SYSTEM include)
set (SRCS
${CMAKE_CURRENT_SOURCE_DIR}/craam/Action.hpp
${CMAKE_CURRENT_SOURCE_DIR}/craam/definitions.hpp
${CMAKE_CURRENT_SOURCE_DIR}/craam/RMDP.hpp
${CMAKE_CURRENT_SOURCE_DIR}/craam/State.hpp
${CMAKE_CURRENT_SOURCE_DIR}/craam/Transition.hpp
${CMAKE_CURRENT_SOURCE_DIR}/craam/modeltools.hpp
${CMAKE_CURRENT_SOURCE_DIR}/craam/algorithms/values.hpp
${CMAKE_CURRENT_SOURCE_DIR}/craam/algorithms/robust_values.hpp
${CMAKE_CURRENT_SOURCE_DIR}/craam/algorithms/occupancies.hpp
${CMAKE_CURRENT_SOURCE_DIR}/craam/Simulation.hpp
${CMAKE_CURRENT_SOURCE_DIR}/craam/Samples.hpp
${CMAKE_CURRENT_SOURCE_DIR}/craam/ImMDP.hpp)
set (TSTS ${CMAKE_CURRENT_SOURCE_DIR}/test/test.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test/core_tests.hpp
${CMAKE_CURRENT_SOURCE_DIR}/test/implementable_tests.hpp
${CMAKE_CURRENT_SOURCE_DIR}/test/simulation_tests.hpp
)
set (DEV ${CMAKE_CURRENT_SOURCE_DIR}/test/dev.cpp)
set (BENCH ${CMAKE_CURRENT_SOURCE_DIR}/test/benchmark.cpp)
# **** LIBRARY ****
#add_library (craam STATIC ${SRCS} )
# **** DEVELOPMENT EXECUTABLE ****
add_executable (develop_exe ${DEV} ${SRCS})
target_link_libraries(develop_exe)
add_custom_target (develop COMMAND develop_exe
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin
COMMENT "Running executable")
# **** TEST ****
if (BUILD_TESTS)
add_executable (unit_tests ${TSTS} ${SRCS} )
target_link_libraries(unit_tests ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
#cotire(unit_tests)
add_custom_target (testit COMMAND unit_tests --detect_memory_leaks --detect_fp_exceptions --color-output -l unit_scope
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin
COMMENT "Running unit tests")
endif (BUILD_TESTS)
# **** COMMAND-LINE EXECUTABLE ****
add_executable(craam-cli EXCLUDE_FROM_ALL ${BENCH} ${SRCS} )
# **** DOCUMENTATION ****
if(BUILD_DOCUMENTATION)
if(NOT DOXYGEN_FOUND)
message(FATAL_ERROR "Needs Doxygen to build the documentation.")
endif()
set(doxyfile_in ${CMAKE_CURRENT_SOURCE_DIR}/doc/doxygen.config.in)
set(doxyfile ${CMAKE_CURRENT_SOURCE_DIR}/doc/doxyfile.config)
configure_file(${doxyfile_in} ${doxyfile} @ONLY)
add_custom_target(docs
COMMAND ${DOXYGEN_EXECUTABLE} ${doxyfile}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Generating API documentation with Doxygen"
VERBATIM)
#install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html DESTINATION share/doc)
endif()