forked from mimesis-inria/caribou
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
84 lines (68 loc) · 2.69 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
cmake_minimum_required(VERSION 3.5)
project(Caribou)
# Manually define VERSION
set(Caribou_VERSION_MAJOR 1)
set(Caribou_VERSION_MINOR 0)
set(Caribou_VERSION_PATCH 0)
set(Caribou_VERSION ${Caribou_VERSION_MAJOR}.${Caribou_VERSION_MINOR}.${Caribou_VERSION_PATCH})
## Default build type
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "RelWithDebInfo")
endif()
# CMAKE TOOLS
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/CMake")
include(caribouTools)
# OPTIONS
option(CARIBOU_USE_DOUBLE "Use double precision for floating point values." ON)
option(CARIBOU_BUILD_TESTS "Compile the automatic tests for Caribou." OFF)
option(CARIBOU_WITH_SOFA "Compile the SofaCaribou library" ON)
find_package(pybind11 CONFIG QUIET)
# Python 2 option
find_package(PythonLibs 2 QUIET)
if (${PYTHONLIBS_FOUND} AND ${pybind11_FOUND})
option(CARIBOU_WITH_PYTHON_2 "Compile the plugin with python 2 support" ON)
else()
option(CARIBOU_WITH_PYTHON_2 "Compile the plugin with python 2 support" OFF)
endif()
# Python 3 option
find_package(Python3 QUIET)
if (${Python3_FOUND} AND ${pybind11_FOUND})
option(CARIBOU_WITH_PYTHON_3 "Compile the plugin with python 3 support" ON)
else()
option(CARIBOU_WITH_PYTHON_3 "Compile the plugin with python 3 support" OFF)
endif()
# OpenMP option
find_package(OpenMP)
if (OPENMP_FOUND)
OPTION(CARIBOU_WITH_OPENMP "Use OpenMP support" ON)
else()
OPTION(CARIBOU_WITH_OPENMP "Use OpenMP support" OFF)
endif()
if (CARIBOU_WITH_OPENMP)
find_package(OpenMP REQUIRED)
endif()
## Change default install prefix
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/install CACHE PATH "Install path prefix, prepended onto install directories." FORCE)
endif()
message(STATUS "Install prefix: ${CMAKE_INSTALL_PREFIX}")
include(CMakePackageConfigHelpers)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
message(STATUS "Build prefix: ${CMAKE_BINARY_DIR}")
message(STATUS "Archive prefix: ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}")
message(STATUS "Library prefix: ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
message(STATUS "Runtime prefix: ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
# Compiler options
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
if ("${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1}" MATCHES ".*[cC][lL][aA][nN][gG]")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcolor-diagnostics")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic")
add_subdirectory(src/Caribou)
if (CARIBOU_WITH_SOFA)
add_subdirectory(src/SofaCaribou)
endif()