-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathCMakeLists.txt
89 lines (76 loc) · 2.36 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
cmake_minimum_required(VERSION 3.13.0)
project(dmsc-visualizer VERSION 0.1.0)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# GLM library
find_package(glm REQUIRED)
# GLFW library
find_package(glfw3 REQUIRED)
add_library(dmsc STATIC)
set_target_properties(dmsc PROPERTIES PROJECT_SOURCE_DIR ${PROJECT_SOURCE_DIR})
# Debug flags
if(MSVC)
target_compile_options(dmsc PRIVATE /W4
/wd4458 # declaration of 'identifier' hides class member
/wd4100 # 'identifier' : unreferenced formal parameter
)
target_link_options(dmsc PUBLIC /NODEFAULTLIB:MSVCRT)
else()
target_compile_options(dmsc PRIVATE -Wall -Wextra -pedantic)
endif()
# Macro for copying resource files
macro(copy_resources target)
get_target_property(source_dir dmsc PROJECT_SOURCE_DIR) # to be independent of the calling target/project
add_custom_command(
TARGET ${target} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory ${source_dir}/resources/shader $<TARGET_FILE_DIR:${target}>/shader
COMMAND ${CMAKE_COMMAND} -E copy_directory ${source_dir}/resources/textures $<TARGET_FILE_DIR:${target}>/textures
VERBATIM)
endmacro()
# Examples
OPTION(BUILD_SAMPLES
"If the examples are built as well." ON)
if(BUILD_SAMPLES)
add_subdirectory(./examples)
endif()
# external source files
set(external_files
external/imgui/imgui.cpp
external/imgui/imgui_draw.cpp
external/imgui/imgui_widgets.cpp
external/imgui/imgui_tables.cpp
external/imgui/backends/imgui_impl_glfw.cpp
external/imgui/backends/imgui_impl_opengl3.cpp
external/glad/src/glad.c
)
# solver source files
set(solver_files
src/solver.cpp
src/solver/greedy_next.cpp
src/solver/greedy_next_khop.cpp
)
# source files
target_sources(dmsc
PRIVATE
src/visuals.cpp
src/instance.cpp
src/opengl_widgets.cpp
src/opengl_primitives.cpp
${solver_files}
${external_files}
)
target_include_directories(dmsc
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src
external/imgui
external/imgui/backends
external/stb
external/glad/include
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/include
)
target_link_libraries(dmsc glm::glm glfw)
if(UNIX)
set_target_properties(dmsc PROPERTIES COMPILE_FLAGS -pthread LINK_FLAGS -pthread)
target_link_libraries(dmsc ${CMAKE_DL_LIBS})
endif()