From 8e228952ac1535897f768e68bfc5f32a35b9eb4c Mon Sep 17 00:00:00 2001 From: Kai Blaschke Date: Fri, 5 Dec 2025 09:08:03 +0100 Subject: [PATCH] Use PUBLIC_HEADER CMake target property to install API headers --- src/api/CMakeLists.txt | 44 ++++++++++++++++--------------------- src/playlist/CMakeLists.txt | 39 ++++++++++++++------------------ 2 files changed, 36 insertions(+), 47 deletions(-) diff --git a/src/api/CMakeLists.txt b/src/api/CMakeLists.txt index 1674d9aa6..84f14c597 100644 --- a/src/api/CMakeLists.txt +++ b/src/api/CMakeLists.txt @@ -1,8 +1,19 @@ add_library(projectM_api INTERFACE) -target_sources(projectM_api - PRIVATE +configure_file(version.h.in "${CMAKE_CURRENT_BINARY_DIR}/include/projectM-4/version.h" @ONLY) + +include(GenerateExportHeader) + +set(PROJECTM_EXPORT_HEADER "${CMAKE_CURRENT_BINARY_DIR}/include/projectM-4/projectM_export.h") + +generate_export_header(projectM_api + BASE_NAME projectM + EXPORT_FILE_NAME "${PROJECTM_EXPORT_HEADER}" + ) + +set(PROJECTM_PUBLIC_HEADERS "${PROJECTM_EXPORT_HEADER}" + "${CMAKE_CURRENT_BINARY_DIR}/include/projectM-4/version.h" include/projectM-4/audio.h include/projectM-4/callbacks.h include/projectM-4/core.h @@ -15,9 +26,15 @@ target_sources(projectM_api include/projectM-4/user_sprites.h ) +target_sources(projectM_api + PRIVATE + ${PROJECTM_PUBLIC_HEADERS} + ) + set_target_properties(projectM_api PROPERTIES EXPORT_NAME API FOLDER libprojectM + PUBLIC_HEADER "${PROJECTM_PUBLIC_HEADERS}" ) target_include_directories(projectM_api @@ -27,17 +44,6 @@ target_include_directories(projectM_api "$" ) -configure_file(version.h.in "${CMAKE_CURRENT_BINARY_DIR}/include/projectM-4/version.h" @ONLY) - -include(GenerateExportHeader) - -set(PROJECTM_EXPORT_HEADER "${CMAKE_CURRENT_BINARY_DIR}/include/projectM-4/projectM_export.h") - -generate_export_header(projectM_api - BASE_NAME projectM - EXPORT_FILE_NAME "${PROJECTM_EXPORT_HEADER}" - ) - add_library(libprojectM::API ALIAS projectM_api) @@ -51,16 +57,4 @@ if(ENABLE_INSTALL) PUBLIC_HEADER DESTINATION "${PROJECTM_INCLUDE_DIR}/projectM-4" COMPONENT Devel ) - install(FILES - "${CMAKE_CURRENT_BINARY_DIR}/include/projectM-4/projectM_export.h" - "${CMAKE_CURRENT_BINARY_DIR}/include/projectM-4/version.h" - DESTINATION "${PROJECTM_INCLUDE_DIR}/projectM-4" - COMPONENT Devel - ) - - install(DIRECTORY include/projectM-4 - DESTINATION "${PROJECTM_INCLUDE_DIR}" - COMPONENT Devel - ) - endif() \ No newline at end of file diff --git a/src/playlist/CMakeLists.txt b/src/playlist/CMakeLists.txt index 05ff116b9..bcd50540a 100644 --- a/src/playlist/CMakeLists.txt +++ b/src/playlist/CMakeLists.txt @@ -2,15 +2,10 @@ if(NOT ENABLE_PLAYLIST) return() endif() -add_library(projectM_playlist_main OBJECT - Filter.cpp - Filter.hpp - Item.cpp - Item.hpp - Playlist.cpp - Playlist.hpp - PlaylistCWrapper.cpp - PlaylistCWrapper.hpp +set(PROJECTM_PLAYLIST_EXPORT_HEADER "${CMAKE_CURRENT_BINARY_DIR}/include/projectM-4/projectM_playlist_export.h") + +set(PROJECTM_PLAYLIST_PUBLIC_HEADERS + "${PROJECTM_PLAYLIST_EXPORT_HEADER}" api/projectM-4/playlist.h api/projectM-4/playlist_callbacks.h api/projectM-4/playlist_core.h @@ -21,6 +16,18 @@ add_library(projectM_playlist_main OBJECT api/projectM-4/playlist_types.h ) +add_library(projectM_playlist_main OBJECT + ${PROJECTM_PLAYLIST_PUBLIC_HEADERS} + Filter.cpp + Filter.hpp + Item.cpp + Item.hpp + Playlist.cpp + Playlist.hpp + PlaylistCWrapper.cpp + PlaylistCWrapper.hpp + ) + target_include_directories(projectM_playlist_main PUBLIC $ @@ -45,6 +52,7 @@ set_target_properties(projectM_playlist PROPERTIES EXPORT_NAME playlist FOLDER libprojectM OUTPUT_NAME ${PROJECTM_LIBRARY_BASE_OUTPUT_NAME}-playlist + PUBLIC_HEADER "${PROJECTM_PLAYLIST_PUBLIC_HEADERS}" ) target_include_directories(projectM_playlist @@ -88,8 +96,6 @@ endif() include(GenerateExportHeader) -set(PROJECTM_PLAYLIST_EXPORT_HEADER "${CMAKE_CURRENT_BINARY_DIR}/include/projectM-4/projectM_playlist_export.h") - generate_export_header(projectM_playlist BASE_NAME projectM_playlist EXPORT_FILE_NAME "${PROJECTM_PLAYLIST_EXPORT_HEADER}" @@ -107,17 +113,6 @@ if(ENABLE_INSTALL) PUBLIC_HEADER DESTINATION "${PROJECTM_INCLUDE_DIR}/projectM-4" COMPONENT Devel ) - install(FILES - "${CMAKE_CURRENT_BINARY_DIR}/include/projectM-4/projectM_playlist_export.h" - DESTINATION "${PROJECTM_INCLUDE_DIR}/projectM-4" - COMPONENT Devel - ) - - install(DIRECTORY api/projectM-4 - DESTINATION "${PROJECTM_INCLUDE_DIR}" - COMPONENT Devel - ) - # For use from an installed package (system install, vcpkg, homebrew etc.) include(CMakePackageConfigHelpers)