Skip to content

Commit

Permalink
Updated cmake export config
Browse files Browse the repository at this point in the history
Followed the official cmake doc and added newest
export config.
https://cmake.org/cmake/help/latest/guide/tutorial/Adding%20Export%20Configuration.html
  • Loading branch information
berndporr committed Jun 9, 2022
1 parent a2e4a7b commit 729c179
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
23 changes: 22 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -109,5 +109,26 @@ install(TARGETS iir_static EXPORT iir-targets
install(EXPORT iir-targets
DESTINATION lib/cmake/iir
NAMESPACE iir::
FILE iir-config.cmake
FILE iirTargets.cmake
)

include(CMakePackageConfigHelpers)

configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/iirConfig.cmake"
INSTALL_DESTINATION "lib/cmake/iir"
NO_SET_AND_CHECK_MACRO
NO_CHECK_REQUIRED_COMPONENTS_MACRO
)

write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/iirConfigVersion.cmake"
VERSION "${iir_VERSION_MAJOR}.${iir_VERSION_MINOR}"
COMPATIBILITY AnyNewerVersion
)

install(FILES
${CMAKE_CURRENT_BINARY_DIR}/iirConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/iirConfigVersion.cmake
DESTINATION lib/cmake/iir
)
12 changes: 12 additions & 0 deletions Config.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Config.cmake.in

@PACKAGE_INIT@

# Value of 'iir_INCLUDE_DIRS' is real: it contains the include directory.
set(iir_INCLUDE_DIRS @CMAKE_INSTALL_PREFIX@/include)

# CMake extracts a library path from it.
set(iir_LIBRARIES iir)

# Include the export script generated by CMake:
include(${CMAKE_CURRENT_LIST_DIR}/iirTargets.cmake)

0 comments on commit 729c179

Please sign in to comment.