forked from codac-team/codac
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
169 lines (130 loc) · 6.2 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
# ==================================================================
# tubex-lib - cmake configuration file
# ==================================================================
cmake_minimum_required(VERSION 3.0.2)
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(tubex-lib 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
"Tubex is a library providing tools for constraint programming over reals and trajectories.")
set(PROJECT_LONG_DESCRIPTION
"${PROJECT_DESCRIPTION}")
set(PROJECT_HOMEPAGE_URL "http://simon-rohou.fr/research/tubex-lib")
message(STATUS "Configuring build for ${PROJECT_NAME} ${PROJECT_VERSION}")
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug)
message(STATUS "Configuring ${PROJECT_NAME} in DEBUG mode as none was specified.")
endif()
################################################################################
# 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/tubex/cmake" CACHE PATH "cmake files (share/tubex/cmake)")
################################################################################
# Compilation configuration
################################################################################
# # Check that the compiler supports c++11
# include(CheckCXXCompilerFlag)
# check_cxx_compiler_flag("-std=c++11" COMPILER_SUPPORTS_CXX11)
#
# if(COMPILER_SUPPORTS_CXX11)
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
# else()
# message(FATAL_ERROR "Tubex needs a compiler with C++11 support")
# endif()
#
# if(WIN32)
# # We need this for strdup under Windows (see issue #287 of ibex-lib repo)
# add_definitions(-U__STRICT_ANSI__)
# endif()
# add_compile_options(-O3 -Wall)
if(MSVC)
add_compile_options(/D _CRT_SECURE_NO_WARNINGS)
else()
add_compile_options(-Wall)
endif()
################################################################################
# Optional binary tree activation for all tubes (for tests purposes mainly)
################################################################################
# Binary trees allow to speed up some computations. They can be activated
# upon request according to the application. For tests purposes, the following
# forces the use of binary trees for all computations.
option(WITH_TUBE_TREE "Binary trees for fast tube evaluations" OFF)
if(WITH_TUBE_TREE)
message(STATUS "[binary trees] Using binary trees for fast tube evaluations")
add_definitions(-DUSE_TUBE_TREE)
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 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 "[capd2tubex] PKG_CAPD_INCLUDE_DIRS = ${PKG_CAPD_INCLUDE_DIRS}")
message(STATUS "[capd2tubex] PKG_CAPD_LDFLAGS = ${PKG_CAPD_LDFLAGS}")
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(BUILD_TESTS)
include(CTest)
add_custom_target(check
COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure $(ARGS)
DEPENDS tubex COMMENT "Running the tests")
add_subdirectory(tests)
endif()
option(TEST_EXAMPLES "Testing examples" OFF)
add_subdirectory(examples) # examples are tested as integration tests
################################################################################
# Compile sources
################################################################################
add_subdirectory(src) # C++ sources
add_subdirectory(doc) # documentation (Doxygen + Sphinx manual)
# Python binding:
option(WITH_PYTHON "Build Python binding" OFF)
if(WITH_PYTHON)
if(NOT MSVC)
add_compile_options(-fPIC) # is it necessary for python binding?
endif()
add_subdirectory(python)
endif()
################################################################################
# Archives and packages
################################################################################
set(CPACK_GENERATOR "TGZ" "ZIP" "DEB")
string(TOLOWER "${CMAKE_PROJECT_NAME}" CPACK_PACKAGE_NAME)
set(CPACK_PACKAGE_VENDOR "TubexTeam")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY ${TUBEX_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 ${TUBEX_URL})
# todo: finish deb package
include(CPack)