-
-
Notifications
You must be signed in to change notification settings - Fork 197
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
69 lines (59 loc) · 2.62 KB
/
CMakeLists.txt
File metadata and controls
69 lines (59 loc) · 2.62 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
#
# D++ (DPP), The Lightweight C++ Discord Library
#
# Copyright 2021 Craig Edwards <support@brainbox.cc>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Example programs test compilation
# This build script is executed by a GitHub action to ensure all example
# programs compile correctly. It does not attempt to run them, as there
# is no way to know if the program successfully did its thing, plus
# examples do not have a valid token. This build script assumes the
# following system dependencies are available:
#
# g++-12 or later
# liboggz-dev
# libmpg123-dev
# dpp latest master with -DDPP_CORO=ON installed sytemwide
cmake_minimum_required (VERSION 3.28)
project(documentation_tests)
string(ASCII 27 Esc)
option(DPP_MODULES "Build examples with C++20 modules support" ON)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DDPP_CORO -std=c++20 -pthread -O0 -fPIC -DFMT_HEADER_ONLY -Wall -Wextra -Wpedantic -Werror -Wno-unused-parameter -Wno-deprecated-declarations")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0")
# Create gcm.cache directory and symlink to the main build's dpp.gcm
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/gcm.cache")
file(CREATE_LINK "${CMAKE_SOURCE_DIR}/../../build/library/CMakeFiles/dpp.dir/dpp.gcm"
"${CMAKE_BINARY_DIR}/gcm.cache/dpp.gcm" SYMBOLIC)
endif()
file(GLOB example_list ./*.cpp)
foreach (example ${example_list})
get_filename_component(examplename ${example} NAME)
message(STATUS "Found example '${Esc}[1;34m${examplename}${Esc}[m'")
add_executable(${examplename}_out ${example})
target_link_libraries(${examplename}_out dl dpp mpg123 oggz ogg opusfile opus)
include_directories(/usr/include/opus)
target_compile_definitions(${examplename}_out PRIVATE DPP_MODULES)
set_target_properties(${examplename}_out PROPERTIES CXX_SCAN_FOR_MODULES ON)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
target_compile_options(${examplename}_out PRIVATE -fmodules-ts)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
target_compile_options(${examplename}_out PRIVATE
-fmodules
-mavx2
-fprebuilt-module-path=${CMAKE_SOURCE_DIR}/../../build/library/CMakeFiles/dpp.dir
)
endif()
endforeach(example)