blob: 6b4543f72ec7372904e2ad3e372d4c9e790215b9 (
plain)
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
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin")
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
add_library(common INTERFACE)
# -----------------------------------------------------------------------------
# Language options
# -----------------------------------------------------------------------------
target_compile_features(common INTERFACE cxx_std_20)
target_compile_features(common INTERFACE c_std_17)
# -----------------------------------------------------------------------------
# Compiler flags for maximum debuggage
# -----------------------------------------------------------------------------
if(MSVC)
target_compile_options(common INTERFACE /W3)
else()
target_compile_options(common INTERFACE -Wall -Wextra -Wpedantic)
endif()
# @@ should do a test compile to see if asan is actually available
if(NOT MINGW)
target_compile_options(common INTERFACE -fsanitize=address)
target_link_options(common INTERFACE -fsanitize=address)
endif()
# -----------------------------------------------------------------------------
# Dependency: FFmpeg
# -----------------------------------------------------------------------------
if(DEMO_NEEDS_FFMPEG)
if(WIN32 AND MSVC)
message(FATAL_ERROR "FFmpeg is not available for msvc")
else()
find_package(PkgConfig REQUIRED)
pkg_check_modules(AVCODEC REQUIRED IMPORTED_TARGET libavcodec)
pkg_check_modules(AVFORMAT REQUIRED IMPORTED_TARGET libavformat)
pkg_check_modules(AVUTIL REQUIRED IMPORTED_TARGET libavutil)
pkg_check_modules(SWRESAMPLE REQUIRED IMPORTED_TARGET libswresample)
pkg_check_modules(SWSCALE REQUIRED IMPORTED_TARGET libswscale)
target_link_libraries(common INTERFACE
PkgConfig::AVCODEC
PkgConfig::AVFORMAT
PkgConfig::AVUTIL
PkgConfig::SWRESAMPLE
PkgConfig::SWSCALE
)
endif()
endif()
# -----------------------------------------------------------------------------
# Dependency: SDL3
# -----------------------------------------------------------------------------
if(DEMO_NEEDS_SDL3)
if(WIN32 AND MSVC)
FetchContent_Declare(
SDL
GIT_REPOSITORY https://github.com/libsdl-org/SDL.git
GIT_TAG release-3.2.18
GIT_PROGRESS TRUE
GIT_SHALLOW TRUE
)
FetchContent_MakeAvailable(SDL)
target_link_libraries(common INTERFACE SDL3::SDL3)
else()
find_package(PkgConfig REQUIRED)
pkg_check_modules(SDL3 REQUIRED IMPORTED_TARGET SDL3)
target_link_libraries(common INTERFACE PkgConfig::SDL3)
endif()
endif()
|