Skip to content

Commit

Permalink
Fixes #166: Now installing a printf-config.cmake file
Browse files Browse the repository at this point in the history
This file is installed along with the other CMake configuration file (targets, version, build-type); it is the file which `find_package()` searches for.
  • Loading branch information
crvux authored and eyalroz committed Nov 9, 2023
1 parent de32abc commit af78f24
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
10 changes: 9 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,21 @@ install(

include(CMakePackageConfigHelpers)

configure_package_config_file(
"cmake/printf-config.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/printf-config.cmake"
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/printf"
)

write_basic_package_version_file(
"printf-config-version.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMinorVersion
)

install(
FILES "${CMAKE_CURRENT_BINARY_DIR}/printf-config-version.cmake"
FILES
"${CMAKE_CURRENT_BINARY_DIR}/printf-config-version.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/printf-config.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/printf"
)
5 changes: 5 additions & 0 deletions cmake/printf-config.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
get_filename_component(PRINTF_CMAKE_CONFIG_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)

if(NOT TARGET printf::printf)
include("${PRINTF_CMAKE_CONFIG_DIR}/printf-targets.cmake")
endif()

0 comments on commit af78f24

Please sign in to comment.