-
Notifications
You must be signed in to change notification settings - Fork 64
/
CMakeLists.txt
80 lines (63 loc) · 2.39 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
cmake_minimum_required(VERSION 3.24)
project(CoACD LANGUAGES C CXX)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
option(WITH_3RD_PARTY_LIBS "Include 3rd party libraries" ON)
if(WITH_3RD_PARTY_LIBS)
add_compile_definitions(WITH_3RD_PARTY_LIBS=1)
else()
set(DISABLE_SPDLOG ON)
add_compile_definitions(WITH_3RD_PARTY_LIBS=0)
endif()
if (MSVC)
add_compile_options("/bigobj")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -W0 -fpermissive -D_USE_MATH_DEFINES")
set(CMAKE_SHARED_LIBRARY_PREFIX "lib")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fpermissive -D_USE_MATH_DEFINES")
endif()
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -O3")
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=address")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wno-int-in-bool-context -Wsign-compare")
set(CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fsanitize=address")
endif()
if(WITH_3RD_PARTY_LIBS)
include(zlib)
include(boost)
include(openvdb)
include(spdlog)
endif()
file(GLOB_RECURSE COACD_SRC "src/*.cc" "src/*.cpp")
if(NOT WITH_3RD_PARTY_LIBS)
# Exclude files that match the pattern "preprocess*"
list(FILTER COACD_SRC EXCLUDE REGEX ".*preprocess.*")
endif()
add_library(coacd STATIC ${COACD_SRC})
target_include_directories(coacd PUBLIC public)
target_include_directories(coacd PRIVATE 3rd/cdt/CDT)
if(WITH_3RD_PARTY_LIBS)
target_link_libraries(coacd PRIVATE openvdb_static spdlog::spdlog)
endif()
find_package(OpenMP)
if (OpenMP_CXX_FOUND)
target_link_libraries(coacd PUBLIC OpenMP::OpenMP_CXX)
endif()
find_package(Threads)
target_link_libraries(coacd PRIVATE Threads::Threads)
set_target_properties(coacd PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
add_library(_coacd SHARED "public/coacd.cpp")
if(WITH_3RD_PARTY_LIBS)
target_link_libraries(_coacd PRIVATE coacd spdlog::spdlog openvdb_static)
else()
target_link_libraries(_coacd PRIVATE coacd)
endif()
add_executable(main main.cpp)
if(WITH_3RD_PARTY_LIBS)
target_link_libraries(main coacd spdlog::spdlog openvdb_static)
else()
target_link_libraries(main coacd)
endif()