-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
73 lines (64 loc) · 2.47 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
cmake_minimum_required(VERSION 3.20)
project(musicvis C CXX)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_C_STANDARD 11) # C11
set(CMAKE_CXX_STANDARD 20) # C++20
Set(FETCHCONTENT_QUIET FALSE)
# cap'n proto
# based on https://github.com/capnproto/capnproto/blob/v2/c%2B%2B/samples/CMakeLists.txt
find_package(CapnProto CONFIG REQUIRED)
capnp_generate_cpp(musicVisProtoSources musicVisProtoHeaders proto/MusicVis.capnp)
add_executable(musicvis
src/main.cpp
src/lib/gl.c
src/util.cpp
src/mesh.cpp
src/shader.cpp
src/model.cpp
src/lib/dr_flac.c
src/song_data.cpp
src/animation.cpp
src/lib/stb_image.c
src/cubemap.cpp
src/camera.cpp
src/intro.cpp
src/framebuffer.cpp
${musicVisProtoSources}
)
target_include_directories(musicvis PRIVATE include ${CMAKE_CURRENT_BINARY_DIR})
target_link_libraries(musicvis CapnProto::capnp)
target_compile_definitions(musicvis PRIVATE "-DSPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_TRACE")
message(STATUS "Music vis headers: ${musicVisProtoHeaders}")
# SDL2
find_package(SDL2 REQUIRED)
target_include_directories(musicvis PRIVATE ${SDL2_INCLUDE_DIRS})
target_link_libraries(musicvis ${SDL2_LIBRARIES})
# spdlog
find_package(spdlog REQUIRED)
target_link_libraries(musicvis spdlog::spdlog)
# assimp
find_package(assimp REQUIRED)
target_link_libraries(musicvis assimp::assimp)
target_include_directories(musicvis PRIVATE ${ASSIMP_INCLUDE_DIRS})
# glm
find_package(glm REQUIRED)
target_link_libraries(musicvis glm::glm)
target_include_directories(musicvis PRIVATE ${GLM_INCLUDE_DIRS})
target_compile_options(musicvis PRIVATE "-Wall" "-Wextra" "-Wno-unused-parameter" "-ggdb")
target_compile_options(musicvis PRIVATE "-DSPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_TRACE")
if ("${CMAKE_BUILD_TYPE}" STREQUAL Release)
message(STATUS "Release build")
target_compile_options(musicvis PRIVATE "-O3" "-march=native" "-mtune=native")
target_link_options(musicvis PRIVATE "-flto=thin")
elseif ("${CMAKE_BUILD_TYPE}" STREQUAL Debug)
message(STATUS "Debug build, adding sanitizers")
target_compile_options(musicvis PRIVATE "-fsanitize=address" "-fsanitize=undefined"
"-fno-omit-frame-pointer")
target_link_options(musicvis PRIVATE "-fsanitize=address" "-fsanitize=undefined")
endif()
# Force LLD
add_link_options("-fuse-ld=lld")
set(CMAKE_EXE_LINKER_FLAGS_INIT "-fuse-ld=lld")
set(CMAKE_MODULE_LINKER_FLAGS_INIT "-fuse-ld=lld")
set(CMAKE_SHARED_LINKER_FLAGS_INIT "-fuse-ld=lld")
target_link_options(musicvis PRIVATE "-fuse-ld=lld")