forked from tataratat/splinepy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
131 lines (116 loc) · 4.17 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
cmake_minimum_required(VERSION 3.12.0)
project(
splinepy
VERSION 0.0.2
LANGUAGES CXX)
# build options
option(SPLINEPY_COMPILE_BSPLINELIB "Compile bsplinelib together." ON)
option(SPLINEPY_VERBOSE_MAKE
"Verbose `make` output. Alias to CMAKE_VERBOSE_MAKEFILE" OFF)
option(SPLINEPY_MORE "Compile a full set of splines." OFF)
option(SPLINEPY_BUILD_SHARED "build shared library for splinepy" OFF)
option(SPLINEPY_COMPILE_PYTHON "Compile python module." ON)
option(SPLINEPY_ENABLE_WARNINGS "Add warning flags" OFF)
option(SPLINEPY_BUILD_EXPLICIT
"Explicit instantiation of (mainly third party) template classes" ON)
# config
set(exe_dest "bin")
set(incl_dest "include")
set(lib_dest "lib")
set(cfg_dest "${lib_dest}/cmake/${PROJECT_NAME}")
set(gen_dir "${CMAKE_CURRENT_BINARY_DIR}/generated")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
set(version_config "${gen_dir}/${PROJECT_NAME}ConfigVersion.cmake")
set(project_config "${gen_dir}/${PROJECT_NAME}Config.cmake")
set(TARGETS_EXPORT_NAME "${PROJECT_NAME}Targets")
set(namespace "${PROJECT_NAME}::")
# default build type id debug
if(NOT CMAKE_BUILD_TYPE)
message("CMAKE_BUILD_TYPE undefined. Setting Debug.")
set(CMAKE_BUILD_TYPE Debug)
endif()
# global flags
set(CMAKE_CXX_VISIBILITY_PRESET "hidden")
set(SPLINEPY_DEFS $<$<NOT:$<CONFIG:Debug>>:NDEBUG>)
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(SPLINEPY_FLAGS -fPIC)
set(SPLINEPY_OPTIMIZATION_FLAGS $<$<NOT:$<CONFIG:Debug>>:-O3>)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
set(SPLINEPY_OPTIMIZATION_FLAGS $<$<NOT:$<CONFIG:Debug>>:/O2>
$<$<NOT:$<CONFIG:Debug>>:/w>)
set(SPLINEPY_FLAGS /bigobj)
endif()
# compiler specific flags
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
set(SPLINEPY_WARNING_FLAGS -Wall -Wextra -Wpedantic
-Wzero-as-null-pointer-constant -Wno-unused)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(SPLINEPY_WARNING_FLAGS
-Wall
-Wextra
-Wmost
-Wextra
-Wpedantic
-Wunreachable-code
-Wshadow
-Wfloat-equal
-Weffc++
-Wno-unused-parameter
-Wno-unused-variable
-Wzero-as-null-pointer-constant)
else()
message(WARNING "Unsupported compiler."
"splinepy is tested with GNU and Clang.")
endif()
if(SPLINEPY_ENABLE_WARNINGS)
set(SPLINEPY_FLAGS ${SPLINEPY_FLAGS} ${SPLINEPY_WARNING_FLAGS})
endif()
if(CMAKE_BUILD_TYPE MATCHES Release)
set(SPLINEPY_FLAGS ${SPLINEPY_FLAGS} ${SPLINEPY_OPTIMIZATION_FLAGS})
endif()
if(SPLINEPY_VERBOSE_MAKE)
set(CMAKE_VERBOSE_MAKEFILE ON)
endif()
if(SPLINEPY_MORE)
set(SPLINEPY_DEFS ${SPLINEPY_DEFS} SPLINEPY_MORE)
endif(SPLINEPY_MORE)
if(SPLINEPY_BUILD_EXPLICIT)
set(SPLINEPY_DEFS ${SPLINEPY_DEFS} SPLINEPY_BUILD_EXPLICIT)
endif(SPLINEPY_BUILD_EXPLICIT)
# try to avoid re-build of splinepy if possible
if(SPLINEPY_COMPILE_PYTHON)
find_package(SplineLib QUIET)
find_package(bezman QUIET)
find_package(napf QUIET)
find_package(splinepy QUIET)
if(splinepy_FOUND)
message("Found installed splinepy, building only python module")
add_subdirectory(third_party/pybind11)
add_subdirectory(src/py)
return()
endif()
endif()
message("")
message(
" %%\\ %%\\ ")
message(" %% |\\__| ")
message(
" %%%%%%%\\ %%%%%%\\ %% |%%\\ %%%%%%%\\ %%%%%%\\ %%%%%%\\ %%\\ %%\\ "
)
message(
"%% _____|%% __%%\\ %% |%% |%% __%%\\ %% __%%\\ %% __%%\\ %% | %% |")
message(
"\\%%%%%%\\ %% / %% |%% |%% |%% | %% |%%%%%%%% |%% / %% |%% | %% |")
message(
" \\____%%\\ %% | %% |%% |%% |%% | %% |%% ____|%% | %% |%% | %% |")
message(
"%%%%%%% |%%%%%%% |%% |%% |%% | %% |\\%%%%%%%\\ %%%%%%% |\\%%%%%%% |")
message(
"\\_______/ %% ____/ \\__|\\__|\\__| \\__| \\_______|%% ____/ \\____%% |")
message(" %% | %% | %%\\ %% |")
message(" %% | %% | \\%%%%%% |")
message(
" \\__| \\__| \\______/")
message("")
add_subdirectory(third_party)
add_subdirectory(src)