-
Notifications
You must be signed in to change notification settings - Fork 161
/
CMakeLists.txt
129 lines (99 loc) · 2.73 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
# dependencies
find_package(Threads REQUIRED)
if (GGWAVE_SUPPORT_SDL2)
# SDL2
if (EMSCRIPTEN)
set(CMAKE_CXX_FLAGS " \
-s USE_SDL=2 \
-s DISABLE_EXCEPTION_CATCHING=0 \
")
set(CMAKE_CXX_LINK_FLAGS " \
--bind \
-s TOTAL_MEMORY=67108864 \
-s ASSERTIONS=1 \
-s 'EXPORTED_RUNTIME_METHODS=[\"writeArrayToMemory\"]' \
")
unset(SDL2_INCLUDE_DIRS)
unset(SDL2_LIBRARIES)
endif()
if (NOT EMSCRIPTEN)
find_package(SDL2)
if (NOT USE_FINDSDL2 AND NOT SDL2_FOUND)
message(WARNING "Unable to find SDL2 library. It is either not installed or CMake cannot find it."
" In the latter case, setting the USE_FINDSDL2 variable might help:\n"
" $ cmake -D USE_FINDSDL2 .."
)
message(FATAL_ERROR "Aborting")
endif()
string(STRIP "${SDL2_LIBRARIES}" SDL2_LIBRARIES)
message(STATUS "SDL2_INCLUDE_DIRS = ${SDL2_INCLUDE_DIRS}")
message(STATUS "SDL2_LIBRARIES = ${SDL2_LIBRARIES}")
endif()
endif()
# third-party
add_subdirectory(third-party)
# helper libraries
add_library(ggwave-common
ggwave-common.cpp
)
target_link_libraries(ggwave-common PRIVATE
${CMAKE_DL_LIBS}
)
if (MINGW)
target_link_libraries(ggwave-common PUBLIC
stdc++
)
endif()
if (GGWAVE_SUPPORT_SDL2)
# ggwave-common-sdl2
add_library(ggwave-common-sdl2
ggwave-common-sdl2.cpp
)
target_include_directories(ggwave-common-sdl2 PUBLIC
${SDL2_INCLUDE_DIRS}
)
target_link_libraries(ggwave-common-sdl2 PRIVATE
ggwave
imgui-sdl2
${SDL2_LIBRARIES}
)
endif()
# examples
if (EMSCRIPTEN)
add_subdirectory(ggwave-js)
add_subdirectory(buttons)
else()
add_subdirectory(ggwave-to-file)
add_subdirectory(ggwave-from-file)
add_subdirectory(arduino-rx)
add_subdirectory(arduino-tx)
add_subdirectory(arduino-tx-obsolete)
add_subdirectory(esp32-rx)
add_subdirectory(rp2040-rx)
endif()
if (GGWAVE_SUPPORT_SDL2)
if (UNIX AND NOT APPLE)
add_subdirectory(r2t2)
endif()
add_subdirectory(arduino-rx-web)
if (EMSCRIPTEN)
# emscripten sdl2 examples
add_subdirectory(ggwave-wasm)
else()
# non-emscripten sdl2 examples
add_subdirectory(ggwave-rx)
add_subdirectory(ggwave-cli)
endif()
add_subdirectory(waver)
add_subdirectory(spectrogram)
endif()
install(TARGETS ggwave-common
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib/static
)
if (GGWAVE_SUPPORT_SDL2)
install(TARGETS ggwave-common-sdl2
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib/static
)
endif()