-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCMakeLists.txt
110 lines (95 loc) · 4.16 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
cmake_minimum_required(VERSION 3.20)
project(FlowGrid LANGUAGES C CXX)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_EXTENSIONS OFF)
# Manually set `export ASAN_OPTIONS=halt_on_error=0` to not stop after first sanitize issue.
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++ -fexperimental-library -fsanitize=address")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++ -fexperimental-library")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L/opt/homebrew/opt/llvm/lib/c++ -L/opt/homebrew/opt/llvm/lib -lc++abi")
set(STATIC_FAUST on CACHE BOOL "Build Static Faust library" FORCE) # Dynamic Faust library causes a bus error on macOS.
set(TRACY_ENABLED off CACHE BOOL "Enable Tracy profiling" FORCE)
add_subdirectory(lib)
# Ignore lib warnings
target_compile_options(staticlib PRIVATE -w) # Faust (can't use alias target)
target_compile_options(SDL3-shared PRIVATE -w)
file(GLOB_RECURSE LIB_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/lib/*.c ${CMAKE_CURRENT_SOURCE_DIR}/lib/*.cpp)
set_source_files_properties(${LIB_SOURCES} PROPERTIES COMPILE_FLAGS "-w")
find_package(Freetype REQUIRED)
find_package(Vulkan REQUIRED)
find_package(PkgConfig REQUIRED)
pkg_search_module(FFTW3F REQUIRED fftw3f IMPORTED_TARGET)
file(GLOB_RECURSE FlowGridSourceFiles CONFIGURE_DEPENDS src/*.cpp)
set(ImGuiDir lib/imgui)
set(ImPlotDir lib/implot)
set(ImGuiFileDialogDir lib/ImGuiFileDialog)
set(MaDir lib/miniaudio)
set(TreeSitterDir lib/tree-sitter)
set(TreeSitterGrammarsDir lib/tree-sitter-grammars)
add_executable(${PROJECT_NAME}
${ImGuiDir}/imgui_demo.cpp
${ImGuiDir}/imgui_draw.cpp
${ImGuiDir}/imgui_tables.cpp
${ImGuiDir}/imgui_widgets.cpp
${ImGuiDir}/imgui.cpp
${ImGuiDir}/backends/imgui_impl_vulkan.cpp
${ImGuiDir}/backends/imgui_impl_sdl3.cpp
${ImGuiDir}/misc/freetype/imgui_freetype.cpp
${ImPlotDir}/implot.cpp
${ImPlotDir}/implot_items.cpp
${ImPlotDir}/implot_demo.cpp
${ImGuiFileDialogDir}/ImGuiFileDialog.cpp
${MaDir}/extras/miniaudio_split/miniaudio.c
${TreeSitterDir}/lib/src/lib.c
${TreeSitterGrammarsDir}/tree-sitter-cpp/src/parser.c
${TreeSitterGrammarsDir}/tree-sitter-cpp/src/scanner.c
${TreeSitterGrammarsDir}/tree-sitter-faust/src/parser.c
${TreeSitterGrammarsDir}/tree-sitter-json/src/parser.c
${FlowGridSourceFiles}
src/main.cpp
)
include_directories(
src
${SDL3_DIR}/include
${FREETYPE_INCLUDE_DIRS}
${Vulkan_INCLUDE_DIRS}
${ImGuiDir}
${ImGuiDir}/backends
${ImPlotDir}
${ImGuiFileDialogDir}
${MaDir}/extras/miniaudio_split
SYSTEM lib/faust/architecture
SYSTEM lib/immer
lib/concurrentqueue
${TreeSitterDir}/lib/include
${TreeSitterDir}/lib/src
${TreeSitterGrammarsDir}/tree-sitter-cpp/src
${TreeSitterGrammarsDir}/tree-sitter-faust/src
${TreeSitterGrammarsDir}/tree-sitter-json/src
PkgConfig::FFTW3F
)
set(RESOURCE_DIR "${CMAKE_SOURCE_DIR}/res")
set(RESOURCE_DEST "${CMAKE_BINARY_DIR}/res")
# Copy resources after building the project target.
add_custom_command(
TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${RESOURCE_DIR} ${RESOURCE_DEST}
COMMENT "Copying resources to build directory"
)
option(TRACING_ENABLED "Enable Tracy profiling" off)
if(TRACING_ENABLED)
set(TracyDir lib/tracy)
set(TRACY_ENABLE on CACHE BOOL "Enable profiling" FORCE)
set(TRACY_ON_DEMAND off CACHE BOOL "On-demand profiling" FORCE)
add_subdirectory(${TracyDir})
include_directories(${TracyDir}/public/tracy)
target_link_libraries(${PROJECT_NAME} PRIVATE Tracy::TracyClient)
target_compile_definitions(${PROJECT_NAME} PRIVATE TRACING_ENABLED)
endif()
target_link_libraries(${PROJECT_NAME} PRIVATE ${FREETYPE_LIBRARIES} ${Vulkan_LIBRARIES} SDL3::SDL3 nlohmann_json::nlohmann_json faustlib PkgConfig::FFTW3F)
set_target_properties(${PROJECT_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra)
add_definitions(-DIMGUI_DEFINE_MATH_OPERATORS) # ImVec2 & ImVec4 math operators
add_definitions(-DIMGUI_ENABLE_FREETYPE)
add_definitions(-DCUSTOM_IMGUIFILEDIALOG_CONFIG="Core/FileDialog/Config.h")
add_definitions(-DMA_NO_ENGINE -DMA_NO_ENCODING -DMA_NO_DECODING)