-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathCMakeLists.txt
174 lines (134 loc) · 6.21 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
# ==================================================================
# Codac - cmake configuration file
# ==================================================================
cmake_minimum_required(VERSION 3.14...3.25)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/scripts/CMakeModules/)
include(version_from_git)
version_from_git() # Obtains the version number from Git tags
# To use a specific compiler:
#set(CMAKE_C_COMPILER "gcc-7")
#set(CMAKE_CXX_COMPILER "/usr/bin/g++-7")
project(codac VERSION ${VERSION} LANGUAGES CXX)
if(NOT VERSION_ID)
set(PROJECT_VERSION_FULL ${PROJECT_VERSION})
else()
set(PROJECT_VERSION_FULL "${PROJECT_VERSION}${VERSION_ID}")
endif()
message(STATUS "Full project version is ${PROJECT_VERSION_FULL}")
set(PROJECT_DESCRIPTION
"Codac is a library providing tools for constraint programming over reals and trajectories.")
set(PROJECT_LONG_DESCRIPTION
"${PROJECT_DESCRIPTION}")
set(PROJECT_HOMEPAGE_URL "http://codac.io")
message(STATUS "Configuring build for ${PROJECT_NAME} ${PROJECT_VERSION}")
################################################################################
# Options for directories
################################################################################
# Install directories
set(CMAKE_INSTALL_INCLUDEDIR "include" CACHE PATH "C++ header files (include)")
set(CMAKE_INSTALL_LIBDIR "lib" CACHE PATH "object code libraries (lib)")
set(CMAKE_INSTALL_BINDIR "bin" CACHE PATH "user executables (bin)")
set(CMAKE_INSTALL_PKGCONFIG "share/pkgconfig" CACHE PATH "pkg files (share/pkgconfig)")
set(CMAKE_INSTALL_CMAKE "share/codac/cmake" CACHE PATH "cmake files (share/codac/cmake)")
################################################################################
# Compilation configuration
################################################################################
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug)
message(STATUS "Configuring ${PROJECT_NAME} in DEBUG mode as none was specified.")
if(MSVC)
add_compile_options(/MD) # Temporary fix to avoid debug vs release inconsistencies...
else()
add_compile_options(-O3)
endif()
endif()
if(MSVC)
add_compile_options(/W4)
else()
add_compile_options(-Wall -Wextra -Wpedantic)
endif()
# # Check that the compiler supports c++20
# include(CheckCXXCompilerFlag)
# check_cxx_compiler_flag("-std=c++2a" COMPILER_SUPPORTS_CXX20)
#
# if(COMPILER_SUPPORTS_CXX20)
# add_compile_options(-std=c++2a)
# else()
# message(FATAL_ERROR "Codac needs a compiler with C++20 support")
# endif()
#if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
#endif()
################################################################################
# Looking for IBEX
################################################################################
find_package(IBEX REQUIRED)
ibex_init_common() # IBEX should have installed this function
message(STATUS "Found IBEX version ${IBEX_VERSION}")
################################################################################
# Looking for Eigen3
################################################################################
add_subdirectory(3rd/eigen)
message(STATUS "Found Eigen3 version ${Eigen3_VERSION}")
add_definitions(${EIGEN3_DEFINITIONS})
################################################################################
# Looking for CAPD (if needed)
################################################################################
option(WITH_CAPD "Using CAPD for accurate integration of ODEs" OFF)
if(WITH_CAPD)
# This looks for capd.pc file
include(FindPkgConfig)
pkg_search_module(PKG_CAPD REQUIRED capd capd-gui mpcapd mpcapd-gui)
include_directories(${PKG_CAPD_INCLUDE_DIRS})
#message(STATUS "[capd2codac] PKG_CAPD_INCLUDE_DIRS = ${PKG_CAPD_INCLUDE_DIRS}")
#message(STATUS "[capd2codac] PKG_CAPD_LDFLAGS = ${PKG_CAPD_LDFLAGS}")
endif()
################################################################################
# Compile sources
################################################################################
if(FAST_RELEASE)
add_compile_definitions(FAST_RELEASE)
message(STATUS "You are running Codac in fast release mode. (option -DCMAKE_BUILD_TYPE=Release is required)")
endif()
add_subdirectory(src) # C++ sources
add_subdirectory(doc) # documentation (Doxygen + Sphinx manual)
# Python binding:
option(WITH_PYTHON "Build Python binding" OFF)
if(WITH_PYTHON)
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
add_subdirectory(python)
endif()
################################################################################
# Tests
################################################################################
# Note: place this tests block before the add_subdirectory(python),
# otherwise python tests will not be taken into account.
option(BUILD_TESTS "Build test" OFF)
if(${CMAKE_VERSION} VERSION_LESS "3.14.0")
# Disable tests due to FetchContent_MakeAvailable which needs CMake >= 3.14.
set(BUILD_TESTS OFF CACHE BOOL "Build test" FORCE)
endif()
if(BUILD_TESTS)
include(CTest)
add_custom_target(check
COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure $(ARGS)
DEPENDS ${PROJECT_NAME} COMMENT "Running the tests")
add_subdirectory(tests)
endif()
option(TEST_EXAMPLES "Testing examples" OFF)
add_subdirectory(examples) # examples are tested as integration tests
################################################################################
# Archives and packages
################################################################################
set(CPACK_GENERATOR "TGZ" "ZIP" "DEB")
string(TOLOWER "${CMAKE_PROJECT_NAME}" CPACK_PACKAGE_NAME)
set(CPACK_PACKAGE_VENDOR "Codac Team")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY ${CODAC_DESCRIPTION})
set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Maintainer <[email protected]>")
set(CPACK_DEBIAN_PACKAGE_HOMEPAGE ${CODAC_URL})
# todo: finish deb package
include(CPack)