Skip to content

Commit 273e26a

Browse files
RIscRIptathre0z
authored andcommitted
Add CMake package config file
1 parent 3435866 commit 273e26a

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

CMakeLists.txt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ endif ()
55
cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
66
include(GenerateExportHeader)
77
include(GNUInstallDirs)
8+
include(CMakePackageConfigHelpers)
89

910
project(Zycore VERSION 1.0.0.0 LANGUAGES C CXX)
1011

@@ -190,7 +191,15 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND NOT ZYAN_NO_LIBC)
190191
target_link_libraries("Zycore" Threads::Threads)
191192
endif ()
192193

193-
# TODO: Install CMake config.
194+
configure_package_config_file(cmake/zycore-config.cmake.in
195+
"${CMAKE_CURRENT_BINARY_DIR}/zycore-config.cmake"
196+
INSTALL_DESTINATION "${CMAKE_INSTALL_PREFIX}/cmake"
197+
)
198+
install(FILES
199+
"${CMAKE_CURRENT_BINARY_DIR}/zycore-config.cmake"
200+
DESTINATION "${CMAKE_INSTALL_PREFIX}/cmake"
201+
)
202+
194203
install(TARGETS "Zycore"
195204
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
196205
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}

cmake/zycore-config.cmake.in

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
set(zycore_VERSION @PROJECT_VERSION@)
2+
3+
@PACKAGE_INIT@
4+
5+
set_and_check(zycore_INCLUDE_DIR "${PACKAGE_PREFIX_DIR}/@CMAKE_INSTALL_INCLUDEDIR@")
6+
set_and_check(zycore_LIB_DIR "${PACKAGE_PREFIX_DIR}/@CMAKE_INSTALL_LIBDIR@")
7+
8+
check_required_components(zycore)

0 commit comments

Comments
 (0)