-
Notifications
You must be signed in to change notification settings - Fork 25
/
CMakeLists.txt
136 lines (116 loc) · 4.38 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
132
133
134
135
cmake_minimum_required(VERSION 3.22)
project(SimLOD)
include(FetchContent)
set(CMAKE_CXX_STANDARD 20)
option(SimLOD_CreateCUDASymlinks "Create symbolic links instead of copying CUDA files." OFF)
# Target SimLOD
add_executable(${PROJECT_NAME}
src/GLRenderer.cpp
include/unsuck_platform_specific.cpp
modules/progressive_octree/LasLoader.cpp
modules/progressive_octree/SimlodLoader.cpp
modules/progressive_octree/main_progressive_octree.cpp)
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT ${PROJECT_NAME})
set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "$<TARGET_FILE_DIR:${PROJECT_NAME}>"
VS_DEBUGGER_COMMAND "$<TARGET_FILE:${PROJECT_NAME}>"
VS_DEBUGGER_ENVIRONMENT "PATH=%PATH%;${CMAKE_PREFIX_PATH}")
# Build options based on CMAKE_BUILD_TYPE
function(configure_build_type)
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
target_compile_options(${PROJECT_NAME} PRIVATE -O0 -g)
elseif (CMAKE_BUILD_TYPE STREQUAL "Release")
target_compile_options(${PROJECT_NAME} PRIVATE -O3)
else()
message(WARNING "No CMAKE_BUILD_TYPE specified, defaulting to Release settings.")
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Default build type: Release" FORCE)
target_compile_options(${PROJECT_NAME} PRIVATE -O3)
endif ()
endfunction()
configure_build_type()
target_include_directories(${PROJECT_NAME} PRIVATE
include
modules/CudaPrint
modules/progressive_octree)
# Dependencies
## CUDA toolkit
find_package(CUDAToolkit 11.8 REQUIRED)
target_include_directories(${PROJECT_NAME} PRIVATE
CUDAToolkit_INCLUDE_DIRS)
target_link_libraries(${PROJECT_NAME}
CUDA::cuda_driver
CUDA::nvrtc)
## OpenGL
find_package(OpenGL REQUIRED)
target_link_libraries(${PROJECT_NAME} ${OPENGL_LIBRARY})
## fmt
add_subdirectory(libs/fmt)
target_link_libraries(${PROJECT_NAME} fmt::fmt)
## glew
target_include_directories(${PROJECT_NAME} PRIVATE
libs/glew/include)
target_sources(${PROJECT_NAME} PRIVATE
libs/glew/glew.c)
## GLFW
include(cmake/glfw.cmake)
target_include_directories(${PROJECT_NAME} PRIVATE
${glfw_SOURCE_DIR}/include)
target_link_libraries(${PROJECT_NAME} glfw)
## glm
target_include_directories(${PROJECT_NAME} PRIVATE
libs/glm)
## imgui
target_include_directories(${PROJECT_NAME} PRIVATE
libs/imgui
libs/imgui/backends)
target_sources(${PROJECT_NAME} PRIVATE
libs/imgui/imgui.cpp
libs/imgui/imgui_demo.cpp
libs/imgui/imgui_draw.cpp
libs/imgui/imgui_tables.cpp
libs/imgui/imgui_widgets.cpp
libs/imgui/backends/imgui_impl_glfw.cpp
libs/imgui/backends/imgui_impl_opengl3.cpp)
## implot
target_include_directories(${PROJECT_NAME} PRIVATE
libs/implot)
target_sources(${PROJECT_NAME} PRIVATE
libs/implot/implot_items.cpp
libs/implot/implot.cpp)
## laszip
add_subdirectory(libs/laszip)
target_link_libraries(${PROJECT_NAME} laszip)
target_include_directories(${PROJECT_NAME} PRIVATE
libs/laszip)
## TODO: disable copying of cuda source files
## - developer builds should use the project root dir as the working directory and directly load from ./modules
## - public release builds should be shipped with the precompiled cuda programs (cached in temp/cuda_programs)
# Post-Build
if (SimLOD_CreateCUDASymlinks)
execute_process(
COMMAND ${CMAKE_COMMAND} -E create_symlink
"${PROJECT_SOURCE_DIR}/CMakelists.txt"
"${CMAKE_BINARY_DIR}/.symlinktest.txt"
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
RESULT_VARIABLE symlinksSupported)
if (symlinksSupported)
message(STATUS "Cannot create symbolic links - missing user privileges. Falling back to copying.")
else ()
execute_process(
COMMAND ${CMAKE_COMMAND} -E remove
"${CMAKE_BINARY_DIR}/.symlinktest.txt"
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
endif (symlinksSupported)
endif (SimLOD_CreateCUDASymlinks)
if (symlinksSupported OR NOT SimLOD_CreateCUDASymlinks)
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
"${PROJECT_SOURCE_DIR}/modules"
"$<TARGET_FILE_DIR:${PROJECT_NAME}>/modules"
COMMENT "POST BUILD: copying modules folder")
else ()
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E create_symlink
"${PROJECT_SOURCE_DIR}/modules"
"$<TARGET_FILE_DIR:${PROJECT_NAME}>/modules"
COMMENT "POST BUILD: creating symlink for modules folder")
endif (symlinksSupported OR NOT SimLOD_CreateCUDASymlinks)