Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit c6e3c0c

Browse files
committedJan 30, 2023
cmake: Export config files
1 parent 3e241fb commit c6e3c0c

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed
 

‎cmake/config.cmake.in

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@PACKAGE_INIT@
2+
3+
include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@-targets.cmake")
4+
5+
check_required_components(@PROJECT_NAME@)

‎src/CMakeLists.txt

+24
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ if(SECP256K1_BUILD_CTIME_TESTS)
102102
endif()
103103

104104
install(TARGETS ${${PROJECT_NAME}_installables}
105+
EXPORT ${PROJECT_NAME}-targets
105106
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
106107
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
107108
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
@@ -125,3 +126,26 @@ endif()
125126
install(FILES ${${PROJECT_NAME}_headers}
126127
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
127128
)
129+
130+
install(EXPORT ${PROJECT_NAME}-targets
131+
FILE ${PROJECT_NAME}-targets.cmake
132+
NAMESPACE ${PROJECT_NAME}::
133+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
134+
)
135+
136+
include(CMakePackageConfigHelpers)
137+
configure_package_config_file(
138+
${PROJECT_SOURCE_DIR}/cmake/config.cmake.in
139+
${PROJECT_NAME}-config.cmake
140+
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
141+
NO_SET_AND_CHECK_MACRO
142+
)
143+
write_basic_package_version_file(${PROJECT_NAME}-config-version.cmake
144+
COMPATIBILITY SameMajorVersion
145+
)
146+
install(
147+
FILES
148+
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake
149+
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake
150+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
151+
)

0 commit comments

Comments
 (0)
Please sign in to comment.