Skip to content

Commit 2f9877f

Browse files
Trying specific handling for CMake examples
1 parent 74418dc commit 2f9877f

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

cmake/CPackSetup.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ if (WIN32)
1818
ARCHIVE DESTINATION ${DPP_INSTALL_LIBRARY_DIR}
1919
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
2020
INCLUDES DESTINATION ${DPP_INSTALL_INCLUDE_DIR}
21-
FILE_SET CXX_MODULES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dpp/include)
21+
FILE_SET CXX_MODULES DESTINATION ${CMAKE_INSTALL_INCLUDE_DIR}/dpp/include)
2222
else()
2323
install(TARGETS dpp
2424
EXPORT ${DPP_EXPORT_NAME}
@@ -36,7 +36,7 @@ else()
3636
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBRARY_DIR}
3737
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
3838
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDE_DIR}
39-
FILE_SET CXX_MODULES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dpp/include)
39+
FILE_SET CXX_MODULES DESTINATION ${CMAKE_INSTALL_INCLUDE_DIR}/dpp/include)
4040
else()
4141
install(TARGETS dpp
4242
EXPORT ${DPP_EXPORT_NAME}

docpages/example_code/CMakeLists.txt

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,31 @@
2828
# libmpg123-dev
2929
# dpp latest master with -DDPP_CORO=ON installed sytemwide
3030

31-
cmake_minimum_required (VERSION 3.16)
31+
cmake_minimum_required (VERSION 3.28)
3232
project(documentation_tests)
3333

3434
string(ASCII 27 Esc)
3535

36-
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DDPP_CORO -DDPP_MODULES -std=c++20 -pthread -O0 -fPIC -DFMT_HEADER_ONLY -Wall -Wextra -Wpedantic -Werror -Wno-unused-parameter -Wno-deprecated-declarations")
36+
option(DPP_MODULES "Build examples with C++20 modules support" ON)
37+
38+
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")
3739
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0")
3840

3941
file(GLOB example_list ./*.cpp)
4042
foreach (example ${example_list})
4143
get_filename_component(examplename ${example} NAME)
44+
4245
message(STATUS "Found example '${Esc}[1;34m${examplename}${Esc}[m'")
4346
add_executable(${examplename}_out ${example})
4447
target_link_libraries(${examplename}_out dl dpp mpg123 oggz ogg opusfile opus)
4548
include_directories(/usr/include/opus)
49+
50+
target_compile_definitions(${examplename}_out PRIVATE DPP_MODULES)
51+
set_target_properties(${examplename}_out PROPERTIES CXX_SCAN_FOR_MODULES ON)
52+
53+
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
54+
target_compile_options(${examplename}_out PRIVATE -fmodules-ts)
55+
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
56+
target_compile_options(${examplename}_out PRIVATE -fmodules)
57+
endif()
4658
endforeach(example)

0 commit comments

Comments
 (0)