-
Notifications
You must be signed in to change notification settings - Fork 25
/
CMakeLists.txt
114 lines (93 loc) · 4.06 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
cmake_minimum_required(VERSION 3.21)
# Set the target architecture.
# All modern x86/x64 processors support AVX2.
# Older x86/x64 processors may support SSE2 but not AVX2.
# Very old x86/x64 processors, or non x86/x64
# processors, do not support any of the two.
set(ENABLE_SSE2 True)
set(ENABLE_AVX2 True)
# set the project name
project(mesh_arrangement)
# specify the C++ standard
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(TBB_TEST OFF CACHE BOOL " " FORCE)
set(TBB_EXAMPLES OFF CACHE BOOL " " FORCE)
set(CINOLIB_USES_OPENGL_GLFW_IMGUI ON)
add_subdirectory(external/oneTBB)
# add the executable
add_executable(${PROJECT_NAME}
main.cpp
)
target_include_directories(${PROJECT_NAME} PUBLIC
./
code/
)
target_compile_definitions(${PROJECT_NAME} PUBLIC TBB_PARALLEL=1)
include(FetchContent)
message("Fetch Indirect Predicates")
FetchContent_Declare(indirect_predicates
GIT_REPOSITORY "https://github.com/MarcoAttene/Indirect_Predicates.git"
GIT_TAG 142e3fbd922e45ade8b02c836a6b0386209a7ab2) # Jan 30, 2024 "Bigfux in lessThan functions"
FetchContent_MakeAvailable(indirect_predicates)
target_include_directories(${PROJECT_NAME} PUBLIC ${indirect_predicates_SOURCE_DIR}/include/)
message("Fetch Cinolib")
FetchContent_Declare(cinolib
GIT_REPOSITORY "https://github.com/mlivesu/cinolib.git"
GIT_TAG e2bc38c3ad8fc2ea2b487b2a3802f6bc2cdfeede) # Jan 18, 2024 "Update color.h"
FetchContent_MakeAvailable(cinolib)
target_include_directories(${PROJECT_NAME} PUBLIC ${cinolib_SOURCE_DIR}/external/eigen)
target_include_directories(${PROJECT_NAME} PUBLIC ${cinolib_SOURCE_DIR}/include/)
add_subdirectory(${cinolib_SOURCE_DIR}/external/shewchuk_predicates shewchuk_predicates)
target_compile_definitions(${PROJECT_NAME} PUBLIC CINOLIB_USES_SHEWCHUK_PREDICATES)
if(CINOLIB_USES_OPENGL_GLFW_IMGUI)
message("CINOLIB OPTIONAL MODULES: OpenGL, GLFW, ImGui")
find_package(OpenGL)
if(OpenGL_FOUND)
target_link_libraries(${PROJECT_NAME} PUBLIC OpenGL::GL)
add_subdirectory(${cinolib_SOURCE_DIR}/external/imgui imgui)
target_link_libraries(${PROJECT_NAME} PUBLIC imgui)
target_compile_definitions(${PROJECT_NAME} PUBLIC CINOLIB_USES_OPENGL_GLFW_IMGUI GL_SILENCE_DEPRECATION)
# https://github.com/ocornut/imgui/issues/4301 (ImGui errors : undefined reference to `ImmGetContext')
target_compile_definitions(${PROJECT_NAME} PUBLIC IMGUI_ENABLE_WIN32_DEFAULT_IME_FUNCTIONS)
# compile stb separately, so that it does not duplicate symbols when used in a header only environment
add_subdirectory(${cinolib_SOURCE_DIR}/external/stb STB)
target_link_libraries(${PROJECT_NAME} PUBLIC STB)
else()
message("Could not find OpenGL!")
set(CINOLIB_USES_OPENGL_GLFW_IMGUI OFF)
endif()
endif()
target_link_libraries(${PROJECT_NAME} PUBLIC shewchuk_predicates tbb)
target_include_directories(${PROJECT_NAME} PUBLIC ${PROJECT_SOURCE_DIR}/external/abseil-cpp/)
# Compiler-specific options
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
# grant IEEE 754 compliance
target_compile_options(${PROJECT_NAME} PUBLIC "/fp:strict")
# use intrinsic functions
target_compile_options(${PROJECT_NAME} PUBLIC "/Oi")
# set target architecture
if(ENABLE_AVX2)
target_compile_options(${PROJECT_NAME} PUBLIC "/arch:AVX2")
elseif(ENABLE_SSE2)
target_compile_options(${PROJECT_NAME} PUBLIC "/arch:SSE2")
endif()
# reserve enough stack size
target_link_options(${PROJECT_NAME} PUBLIC "/STACK:8421376")
# turn off annoying warnings
target_compile_options(${PROJECT_NAME} PUBLIC "/D _CRT_SECURE_NO_WARNINGS")
else()
# set standard optimization level
target_compile_options(${PROJECT_NAME} PUBLIC -O2)
# reserve enough stack size
target_compile_options(${PROJECT_NAME} PUBLIC -Wl,-z,stacksize=8421376)
# grant IEEE 754 compliance
target_compile_options(${PROJECT_NAME} PUBLIC -frounding-math)
# set target architecture
if(ENABLE_AVX2)
target_compile_options(${PROJECT_NAME} PUBLIC "-mavx2")
target_compile_options(${PROJECT_NAME} PUBLIC "-mfma")
elseif(ENABLE_SSE2)
target_compile_options(${PROJECT_NAME} PUBLIC "-msse2")
endif()
endif()