Skip to content

Commit

Permalink
feat: add support for installing private header files
Browse files Browse the repository at this point in the history
  • Loading branch information
sanfengAndroid committed Dec 6, 2024
1 parent 41548b7 commit 4ebcbff
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions library/src/main/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_C_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN ON)

option(FAKELINKER_INSTALL_PRIVATE_HEADERS "Install private header files for static linking" OFF)

if(NOT ${CMAKE_BUILD_TYPE} STREQUAL "Debug")
set(CMAKE_BUILD_TYPE "Release")
endif()
Expand Down Expand Up @@ -99,7 +101,6 @@ target_include_directories(fakelinker_static PUBLIC
)
target_link_libraries(fakelinker_static ${log-lib})


add_library(fakelinker SHARED
linker/linker_dynamic.cpp
)
Expand All @@ -117,7 +118,6 @@ set_target_properties(fakelinker PROPERTIES
"${LINK_FLAGS} -Wl,--gc-sections,-s,--version-script=\"${CMAKE_CURRENT_SOURCE_DIR}/symbol.map.txt\""
)


install(TARGETS fakelinker fakelinker_static
EXPORT fakelinker
)
Expand All @@ -126,6 +126,13 @@ install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/fakelinker/fakelinker
)

if(FAKELINKER_INSTALL_PRIVATE_HEADERS)
install(DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/linker"
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/fakelinker/fakelinker
FILES_MATCHING PATTERN "*.h"
)
endif()

install(EXPORT fakelinker
FILE fakelinker-config.cmake
NAMESPACE fakelinker::
Expand Down

0 comments on commit 4ebcbff

Please sign in to comment.