forked from duburcqa/jiminy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
86 lines (72 loc) · 3.05 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
# Minimum version required
cmake_minimum_required(VERSION 3.10)
# Set the build version
set(BUILD_VERSION 1.6.21)
# Set compatibility
if(CMAKE_VERSION VERSION_GREATER "3.11.0")
set(COMPATIBILITY_VERSION SameMinorVersion)
else()
set(COMPATIBILITY_VERSION ExactVersion)
endif()
# Extract major, minor and patch version
string(REPLACE "." ";" _VERSION "${BUILD_VERSION}")
list(GET _VERSION 0 BUILD_VERSION_MAJOR)
list(GET _VERSION 1 BUILD_VERSION_MINOR)
list(GET _VERSION 2 BUILD_VERSION_PATCH)
# Add definition of Jiminy version for C++ headers
add_definitions("-DJIMINY_VERSION=\"${BUILD_VERSION}\"")
# Enable C++ language
enable_language(CXX)
# Project and library name
project(jiminy VERSION ${BUILD_VERSION})
set(LIBRARY_NAME ${PROJECT_NAME})
set(PYTHON_LIBRARY_NAME "core")
# Set build environment and standard dependencies
include(${CMAKE_SOURCE_DIR}/build_tools/cmake/base.cmake)
include(${CMAKE_SOURCE_DIR}/build_tools/cmake/docs.cmake)
include(${CMAKE_SOURCE_DIR}/build_tools/cmake/boostPythonDocstring.cmake)
include(${CMAKE_SOURCE_DIR}/build_tools/cmake/exportCmakeConfigFiles.cmake)
include(${CMAKE_SOURCE_DIR}/build_tools/cmake/buildPythonWheel.cmake)
# Set the compilation flags
if(NOT WIN32)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -O0 -g -ftemplate-backtrace-limit=0 ${WARN_FULL}")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -DNDEBUG -O3 -Wfatal-errors -Werror ${WARN_FULL}")
else()
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} /EHsc /bigobj -g /Wall")
# It would be great to have the same quality standard for Windows but
# system inlcude of dependencies is not working properly so far.
# - Disabling warning 4820 generated by std time.h, which is included by std chrono
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} /EHsc /bigobj /permissive- -DNDEBUG -DNOMINMAX /O2 /W2 \
/wd4068 /wd4715 /wd4820 /wd4244 /wd4005 /WX")
endif()
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELEASE} -g")
# Sub-projects
add_subdirectory(soup)
add_subdirectory(core)
option(BUILD_PYTHON_INTERFACE "Build the Python bindings" ON)
if(BUILD_PYTHON_INTERFACE)
include(${CMAKE_SOURCE_DIR}/build_tools/cmake/setupPython.cmake)
add_subdirectory(python)
endif()
option(BUILD_EXAMPLES "Build the C++ examples" ON)
if(BUILD_EXAMPLES)
add_subdirectory(examples)
endif()
option(BUILD_TESTING "Build the C++ unit tests." ON)
if(BUILD_TESTING)
add_subdirectory(unit)
endif()
# Create 'docs' optional cmake component to generate documentation.
create_component_docs()
# Install the source cmake files
file(GLOB_RECURSE SOURCE_CMAKE_FILES "${CMAKE_SOURCE_DIR}/build_tools/cmake/Find*.cmake")
install(FILES ${SOURCE_CMAKE_FILES}
DESTINATION "${CMAKE_INSTALL_DATADIR}/${LIBRARY_NAME}/cmake"
)
install(FILES ${CMAKE_SOURCE_DIR}/build_tools/cmake/base.cmake
DESTINATION "${CMAKE_INSTALL_DATADIR}/${LIBRARY_NAME}/cmake"
RENAME ${LIBRARY_NAME}_base.cmake
)
install(FILES ${CMAKE_SOURCE_DIR}/build_tools/cmake/boostPythonDocstring.cmake
DESTINATION "${CMAKE_INSTALL_DATADIR}/${LIBRARY_NAME}/cmake"
)