-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
executable file
·119 lines (102 loc) · 4.67 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
cmake_minimum_required(VERSION 3.25.2)
#-------------------------------------------------------------------------------
# Project Definitions
#-------------------------------------------------------------------------------
project(OPENFDCM
DESCRIPTION "Fast Directional Chamfer Matching"
LANGUAGES CXX C)
#-------------------------------------------------------------------------------
# VERSIONING
#-------------------------------------------------------------------------------
add_subdirectory(cmake)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
set(PYPROJECT_PATH "${CMAKE_CURRENT_BINARY_DIR}/pyproject.toml")
configure_file("${PROJECT_SOURCE_DIR}/pyproject.toml" ${PYPROJECT_PATH})
ReadVersion(${PYPROJECT_PATH})
#-------------------------------------------------------------------------------
# COMPILATION
#-------------------------------------------------------------------------------
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_CXX_EXTENSIONS OFF)
# Compiler-specific flags
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -Wall -pthread")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -fno-math-errno")
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /EHsc")
set(CMAKE_CXX_FLAGS_RELEASE "/O2")
set(CMAKE_CXX_FLAGS_DEBUG "/Od /Zi")
endif()
# Do not allow to build in main repo
file(TO_CMAKE_PATH "${PROJECT_BINARY_DIR}/CMakeLists.txt" LOC_PATH)
if(EXISTS "${LOC_PATH}")
message(FATAL_ERROR "You cannot build in a source directory (or any directory with a CMakeLists.txt file).
Please make a build subdirectory. Feel free to remove CMakeCache.txt and CMakeFiles.")
endif()
# Set the default build type
set(default_build_type "Release")
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to '${default_build_type}' as none was specified.")
set(CMAKE_BUILD_TYPE "${default_build_type}" 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")
endif()
#-------------------------------------------------------------------------------
# CMAKE OPTIONS
#-------------------------------------------------------------------------------
option(OPENFDCM_BUILD_PYTHON "Enable the compilation of the python bindings." OFF)
option(OPENFDCM_BUILD_TESTS "Enable the compilation of the test files." OFF)
option(OPENFDCM_BUILD_DOCS "Enable the build of the documentation and website." OFF)
if (CMAKE_BUILD_TYPE MATCHES Debug)
add_definitions(-DDEBUG)
endif()
#-------------------------------------------------------------------------------
# Add external components
#-------------------------------------------------------------------------------
ReadDependencyVersion(threadpool ${PYPROJECT_PATH})
ReadDependencyVersion(eigen3 ${PYPROJECT_PATH})
ReadDependencyVersion(packio ${PYPROJECT_PATH})
add_subdirectory(extern/threadpool)
add_subdirectory(extern/eigen3)
add_subdirectory(extern/packio)
#-------------------------------------------------------------------------------
# CONFIGURATIONS
#-------------------------------------------------------------------------------
# No config yet
#-------------------------------------------------------------------------------
# Add components
#-------------------------------------------------------------------------------
set(OPENFDCM_MODULES core matching)
foreach(module ${OPENFDCM_MODULES})
add_subdirectory(modules/${module})
endforeach()
#-------------------------------------------------------------------------------
# Python binding
#-------------------------------------------------------------------------------
if(OPENFDCM_BUILD_PYTHON)
ReadDependencyVersion(pybind11 ${PYPROJECT_PATH})
add_subdirectory(extern/pybind11)
add_subdirectory(modules/python)
endif()
#-------------------------------------------------------------------------------
# Tests
#-------------------------------------------------------------------------------
if(OPENFDCM_BUILD_TESTS)
ReadDependencyVersion(catch2 ${PYPROJECT_PATH})
add_subdirectory(extern/catch2)
# Configure automatic test registration
list(APPEND CMAKE_MODULE_PATH ${Catch2_SOURCE_DIR}/extras)
include(CTest)
include(Catch)
add_subdirectory(tests)
endif()
#-------------------------------------------------------------------------------
# Docs
#-------------------------------------------------------------------------------
if(OPENFDCM_BUILD_DOCS)
add_subdirectory(docs)
endif()