-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
80 lines (65 loc) · 1.9 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.2.0)
project (decomp)
set(CMAKE_CXX_STANDARD 11)
set(TARGET_NAME ${PROJECT_NAME})
option(${PROJECT_NAME}_USE_CONAN "Use conan" ON)
option(${PROJECT_NAME}_BUILD_TESTS "Build tests" ON)
option(${PROJECT_NAME}_PIC "Use position independent code" ON)
if (${PROJECT_NAME}_BUILD_TESTS AND NOT ${PROJECT_NAME}_USE_CONAN)
find_package(Catch2 REQUIRED)
endif()
if (${PROJECT_NAME}_USE_CONAN)
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)
endif()
set(HEADERS
source/decomp/convex_decomposition.hpp
source/decomp/triangulation.hpp
source/decomp/operations.hpp
source/decomp/output.hpp)
# Build the main library
add_library(${TARGET_NAME}
${HEADERS}
source/decomp/convex_decomposition.cpp
source/decomp/triangulation.cpp
source/decomp/operations.cpp
source/decomp/output.cpp)
set_property(TARGET ${TARGET_NAME}
PROPERTY POSITION_INDEPENDENT_CODE ${${PROJECT_NAME}_PIC})
target_include_directories(${TARGET_NAME}
INTERFACE source)
install(TARGETS ${TARGET_NAME}
ARCHIVE DESTINATION lib)
install(FILES
${HEADERS}
DESTINATION
include/decomp/)
# Only enable tests for top-level projects
if(${PROJECT_NAME}_BUILD_TESTS)
set(TEST_NAME test_${PROJECT_NAME})
add_executable(${TEST_NAME}
test/test_main.cpp
test/remapper.cpp
test/remove_holes.cpp
test/ear_clipping.cpp
test/half_edge.cpp
test/edge_flip.cpp
test/decomposition.cpp
test/winding.cpp)
if (${PROJECT_NAME}_USE_CONAN)
target_link_libraries(${TEST_NAME}
PUBLIC decomp CONAN_PKG::catch2)
else()
target_link_libraries(${TEST_NAME}
PUBLIC decomp Catch2::Catch2)
endif()
include(CTest)
enable_testing()
add_test(NAME test_${PROJECT_NAME} COMMAND test_${PROJECT_NAME})
endif()
add_executable(decomp_demo
demo/demo.cpp)
target_link_libraries(decomp_demo
PUBLIC decomp)
install(TARGETS decomp_demo
RUNTIME DESTINATION bin)