Skip to content

Commit 8e22895

Browse files
committed
Use PUBLIC_HEADER CMake target property to install API headers
1 parent ccd606d commit 8e22895

File tree

2 files changed

+35
-46
lines changed

2 files changed

+35
-46
lines changed

src/api/CMakeLists.txt

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
11
add_library(projectM_api INTERFACE)
22

3-
target_sources(projectM_api
4-
PRIVATE
3+
configure_file(version.h.in "${CMAKE_CURRENT_BINARY_DIR}/include/projectM-4/version.h" @ONLY)
4+
5+
include(GenerateExportHeader)
6+
7+
set(PROJECTM_EXPORT_HEADER "${CMAKE_CURRENT_BINARY_DIR}/include/projectM-4/projectM_export.h")
8+
9+
generate_export_header(projectM_api
10+
BASE_NAME projectM
11+
EXPORT_FILE_NAME "${PROJECTM_EXPORT_HEADER}"
12+
)
13+
14+
set(PROJECTM_PUBLIC_HEADERS
515
"${PROJECTM_EXPORT_HEADER}"
16+
"${CMAKE_CURRENT_BINARY_DIR}/include/projectM-4/version.h"
617
include/projectM-4/audio.h
718
include/projectM-4/callbacks.h
819
include/projectM-4/core.h
@@ -15,9 +26,15 @@ target_sources(projectM_api
1526
include/projectM-4/user_sprites.h
1627
)
1728

29+
target_sources(projectM_api
30+
PRIVATE
31+
${PROJECTM_PUBLIC_HEADERS}
32+
)
33+
1834
set_target_properties(projectM_api PROPERTIES
1935
EXPORT_NAME API
2036
FOLDER libprojectM
37+
PUBLIC_HEADER "${PROJECTM_PUBLIC_HEADERS}"
2138
)
2239

2340
target_include_directories(projectM_api
@@ -27,17 +44,6 @@ target_include_directories(projectM_api
2744
"$<INSTALL_INTERFACE:${PROJECTM_INCLUDE_DIR}>"
2845
)
2946

30-
configure_file(version.h.in "${CMAKE_CURRENT_BINARY_DIR}/include/projectM-4/version.h" @ONLY)
31-
32-
include(GenerateExportHeader)
33-
34-
set(PROJECTM_EXPORT_HEADER "${CMAKE_CURRENT_BINARY_DIR}/include/projectM-4/projectM_export.h")
35-
36-
generate_export_header(projectM_api
37-
BASE_NAME projectM
38-
EXPORT_FILE_NAME "${PROJECTM_EXPORT_HEADER}"
39-
)
40-
4147
add_library(libprojectM::API ALIAS projectM_api)
4248

4349

@@ -51,16 +57,4 @@ if(ENABLE_INSTALL)
5157
PUBLIC_HEADER DESTINATION "${PROJECTM_INCLUDE_DIR}/projectM-4" COMPONENT Devel
5258
)
5359

54-
install(FILES
55-
"${CMAKE_CURRENT_BINARY_DIR}/include/projectM-4/projectM_export.h"
56-
"${CMAKE_CURRENT_BINARY_DIR}/include/projectM-4/version.h"
57-
DESTINATION "${PROJECTM_INCLUDE_DIR}/projectM-4"
58-
COMPONENT Devel
59-
)
60-
61-
install(DIRECTORY include/projectM-4
62-
DESTINATION "${PROJECTM_INCLUDE_DIR}"
63-
COMPONENT Devel
64-
)
65-
6660
endif()

src/playlist/CMakeLists.txt

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,22 @@ if(NOT ENABLE_PLAYLIST)
22
return()
33
endif()
44

5+
set(PROJECTM_PLAYLIST_EXPORT_HEADER "${CMAKE_CURRENT_BINARY_DIR}/include/projectM-4/projectM_playlist_export.h")
6+
7+
set(PROJECTM_PLAYLIST_PUBLIC_HEADERS
8+
"${PROJECTM_PLAYLIST_EXPORT_HEADER}"
9+
api/projectM-4/playlist.h
10+
api/projectM-4/playlist_callbacks.h
11+
api/projectM-4/playlist_core.h
12+
api/projectM-4/playlist_filter.h
13+
api/projectM-4/playlist_items.h
14+
api/projectM-4/playlist_memory.h
15+
api/projectM-4/playlist_playback.h
16+
api/projectM-4/playlist_types.h
17+
)
18+
519
add_library(projectM_playlist_main OBJECT
20+
${PROJECTM_PLAYLIST_PUBLIC_HEADERS}
621
Filter.cpp
722
Filter.hpp
823
Item.cpp
@@ -11,14 +26,6 @@ add_library(projectM_playlist_main OBJECT
1126
Playlist.hpp
1227
PlaylistCWrapper.cpp
1328
PlaylistCWrapper.hpp
14-
api/projectM-4/playlist.h
15-
api/projectM-4/playlist_callbacks.h
16-
api/projectM-4/playlist_core.h
17-
api/projectM-4/playlist_filter.h
18-
api/projectM-4/playlist_items.h
19-
api/projectM-4/playlist_memory.h
20-
api/projectM-4/playlist_playback.h
21-
api/projectM-4/playlist_types.h
2229
)
2330

2431
target_include_directories(projectM_playlist_main
@@ -45,6 +52,7 @@ set_target_properties(projectM_playlist PROPERTIES
4552
EXPORT_NAME playlist
4653
FOLDER libprojectM
4754
OUTPUT_NAME ${PROJECTM_LIBRARY_BASE_OUTPUT_NAME}-playlist
55+
PUBLIC_HEADER "${PROJECTM_PLAYLIST_PUBLIC_HEADERS}"
4856
)
4957

5058
target_include_directories(projectM_playlist
@@ -88,8 +96,6 @@ endif()
8896

8997
include(GenerateExportHeader)
9098

91-
set(PROJECTM_PLAYLIST_EXPORT_HEADER "${CMAKE_CURRENT_BINARY_DIR}/include/projectM-4/projectM_playlist_export.h")
92-
9399
generate_export_header(projectM_playlist
94100
BASE_NAME projectM_playlist
95101
EXPORT_FILE_NAME "${PROJECTM_PLAYLIST_EXPORT_HEADER}"
@@ -107,17 +113,6 @@ if(ENABLE_INSTALL)
107113
PUBLIC_HEADER DESTINATION "${PROJECTM_INCLUDE_DIR}/projectM-4" COMPONENT Devel
108114
)
109115

110-
install(FILES
111-
"${CMAKE_CURRENT_BINARY_DIR}/include/projectM-4/projectM_playlist_export.h"
112-
DESTINATION "${PROJECTM_INCLUDE_DIR}/projectM-4"
113-
COMPONENT Devel
114-
)
115-
116-
install(DIRECTORY api/projectM-4
117-
DESTINATION "${PROJECTM_INCLUDE_DIR}"
118-
COMPONENT Devel
119-
)
120-
121116

122117
# For use from an installed package (system install, vcpkg, homebrew etc.)
123118
include(CMakePackageConfigHelpers)

0 commit comments

Comments
 (0)