-
Notifications
You must be signed in to change notification settings - Fork 308
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
154 lines (130 loc) · 4.04 KB
/
CMakeLists.txt
File metadata and controls
154 lines (130 loc) · 4.04 KB
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
cmake_minimum_required(VERSION 3.20)
# VS hot reload policy (safe-guarded)
if (POLICY CMP0141)
cmake_policy(SET CMP0141 NEW)
if (MSVC)
set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT
"$<$<CONFIG:Debug,RelWithDebInfo>:ProgramDatabase>")
endif()
endif()
project(CppSdk LANGUAGES CXX)
# -----------------------------
# Windows-only + compiler guard
# -----------------------------
if (NOT WIN32)
message(FATAL_ERROR "CppSdk is Windows-only for now (uses Win32/WIL headers).")
endif()
# Accept MSVC OR clang-cl (Clang in MSVC compatibility mode).
# VS CMake Open-Folder often uses clang-cl by default.
if (NOT (MSVC OR (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC")))
message(STATUS "CMAKE_CXX_COMPILER_ID = ${CMAKE_CXX_COMPILER_ID}")
message(STATUS "CMAKE_CXX_COMPILER = ${CMAKE_CXX_COMPILER}")
message(STATUS "CMAKE_CXX_SIMULATE_ID = ${CMAKE_CXX_SIMULATE_ID}")
message(FATAL_ERROR "Need MSVC or clang-cl (MSVC-compatible toolchain).")
endif()
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# Optional: target Windows 10+ APIs (adjust if you need older)
add_compile_definitions(_WIN32_WINNT=0x0A00 WINVER=0x0A00)
# -----------------------------
# Dependencies (installed via vcpkg)
# -----------------------------
find_package(nlohmann_json CONFIG REQUIRED)
find_package(wil CONFIG REQUIRED)
find_package(Microsoft.GSL CONFIG REQUIRED)
option(BUILD_TESTING "Build unit and end-to-end tests" ON)
if (BUILD_TESTING)
find_package(GTest CONFIG REQUIRED)
endif()
# -----------------------------
# SDK library (STATIC)
# List ONLY .cpp files here.
# -----------------------------
add_library(CppSdk STATIC
src/model.cpp
src/catalog.cpp
src/chat_client.cpp
src/audio_client.cpp
src/live_audio_types.cpp
src/live_audio_session.cpp
src/foundry_local_manager.cpp
)
target_include_directories(CppSdk
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/include
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src
)
target_link_libraries(CppSdk
PUBLIC
nlohmann_json::nlohmann_json
Microsoft.GSL::GSL
WIL::WIL
)
# -----------------------------
# Sample executable
# -----------------------------
add_executable(CppSdkSample
sample/main.cpp
)
target_link_libraries(CppSdkSample PRIVATE CppSdk)
# -----------------------------
# Unit tests
# -----------------------------
if (BUILD_TESTING)
enable_testing()
add_executable(CppSdkTests
test/parser_and_types_test.cpp
test/model_variant_test.cpp
test/catalog_test.cpp
test/client_test.cpp
test/live_audio_test.cpp
)
target_include_directories(CppSdkTests
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/test
${CMAKE_CURRENT_SOURCE_DIR}/src
)
target_compile_definitions(CppSdkTests PRIVATE FL_TESTS)
target_link_libraries(CppSdkTests
PRIVATE
CppSdk
GTest::gtest_main
)
# Copy testdata files next to the test executable so file-based tests can find them.
add_custom_command(TARGET CppSdkTests POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_CURRENT_SOURCE_DIR}/test/testdata
$<TARGET_FILE_DIR:CppSdkTests>/testdata
)
include(GoogleTest)
gtest_discover_tests(CppSdkTests
WORKING_DIRECTORY $<TARGET_FILE_DIR:CppSdkTests>
)
# -----------------------------
# End-to-end tests (separate executable, requires Core DLL)
# Exercises the full public API against the real catalog.
# Tests that need model download are DISABLED by default;
# run with --gtest_also_run_disabled_tests locally.
# -----------------------------
add_executable(CppSdkE2ETests
test/e2e_test.cpp
)
target_include_directories(CppSdkE2ETests
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/test
${CMAKE_CURRENT_SOURCE_DIR}/src
)
target_link_libraries(CppSdkE2ETests
PRIVATE
CppSdk
GTest::gtest_main
)
gtest_discover_tests(CppSdkE2ETests
WORKING_DIRECTORY $<TARGET_FILE_DIR:CppSdkE2ETests>
)
endif()
# Make Visual Studio start/debug this target by default
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
PROPERTY VS_STARTUP_PROJECT CppSdkSample)