Skip to content

Commit

Permalink
Install libunicode install targets the same way we now do with boxed-cpp
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Parpart <[email protected]>
  • Loading branch information
christianparpart committed Oct 24, 2023
1 parent 204a3ae commit bc1c276
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 32 deletions.
43 changes: 26 additions & 17 deletions src/libunicode/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,9 @@ set_target_properties(unicode PROPERTIES
)

add_library(unicode::core ALIAS unicode)
target_include_directories(unicode PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>
$<INSTALL_INTERFACE:include>)
target_include_directories(unicode PUBLIC $<BUILD_INTERFACE:${${PROJECT_NAME}_SOURCE_DIR}/src>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
target_link_libraries(unicode PUBLIC unicode::ucd)

add_executable(unicode_tablegen tablegen.cpp)
Expand All @@ -140,17 +141,14 @@ target_link_libraries(unicode_tablegen PRIVATE unicode::loader)
set(LIBUNICODE_CMAKE_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/libunicode" CACHE PATH "Installation directory for cmake files, a relative path that will be joined with ${CMAKE_INSTALL_PREFIX} or an absolute path.")
set(LIBUNICODE_INSTALL_CMAKE_FILES ${MASTER_PROJECT} CACHE BOOL "Decides whether or not to install CMake config and -version files.")

set(INSTALL_TARGETS unicode_ucd unicode_loader unicode)
set(TARGETS_EXPORT_NAME unicode-targets)

# Create and install package configuration and version files.
# Install library and headers.
install(TARGETS ${INSTALL_TARGETS}
EXPORT ${TARGETS_EXPORT_NAME}
install(TARGETS unicode_ucd unicode_loader unicode
EXPORT unicode-targets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_PREFIX}/include/libunicode"
PRIVATE_HEADER DESTINATION "${CMAKE_INSTALL_PREFIX}/include/libunicode"
PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/libunicode"
PRIVATE_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/libunicode"
FRAMEWORK DESTINATION "."
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})

Expand All @@ -162,21 +160,32 @@ install(
ucd_ostream.h
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/libunicode"
)
# }}}

# {{{ Generate the version, config and target files
if(LIBUNICODE_INSTALL_CMAKE_FILES)
set(version "${CMAKE_PROJECT_VERSION}")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libunicode-config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/libunicode-config.cmake @ONLY)
# Install version, config and target files.
include(CMakePackageConfigHelpers)

write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/libunicode-config-version.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion
)

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libunicode-config-version.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/libunicode-config-version.cmake @ONLY)
configure_package_config_file(libunicode-config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/libunicode-config.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/libunicode
)

install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libunicode-config.cmake
${CMAKE_CURRENT_BINARY_DIR}/libunicode-config-version.cmake
DESTINATION ${LIBUNICODE_CMAKE_DIR})
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/libunicode
)

# Install version, config and target files.
install(EXPORT ${TARGETS_EXPORT_NAME} DESTINATION ${LIBUNICODE_CMAKE_DIR} NAMESPACE unicode::)
install(EXPORT unicode-targets
DESTINATION ${LIBUNICODE_CMAKE_DIR}
NAMESPACE unicode::
)
endif()
# }}}

Expand Down
7 changes: 0 additions & 7 deletions src/libunicode/libunicode-config-version.cmake.in

This file was deleted.

14 changes: 6 additions & 8 deletions src/libunicode/libunicode-config.cmake.in
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
# Compute installation prefix relative to this file.
get_filename_component(_dir "${CMAKE_CURRENT_LIST_FILE}" PATH)
get_filename_component(_prefix "${_dir}/../../.." ABSOLUTE)
@PACKAGE_INIT@

# Import the targets.
include("${_dir}/@[email protected]")
# prevent repeatedly including the targets
if(NOT TARGET unicode::core)
include(${CMAKE_CURRENT_LIST_DIR}/libunicode-targets.cmake)
endif()

# Report other information.
set(libunicode_INCLUDE_DIRS "${_prefix}/include")
set(libunicode_FOUND TRUE)
message(STATUS "Found @PROJECT_NAME@, version: ${@PROJECT_NAME@_VERSION}")

0 comments on commit bc1c276

Please sign in to comment.