Skip to content

Commit

Permalink
Generate proper config and configVersion file.
Browse files Browse the repository at this point in the history
  • Loading branch information
Holt59 committed Jul 4, 2024
1 parent 9e2509c commit 63bd972
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
31 changes: 31 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
cmake_minimum_required(VERSION 3.16)

include(CMakePackageConfigHelpers)

project(usvfs)

set_property(GLOBAL PROPERTY USE_FOLDERS ON)
Expand All @@ -23,6 +25,35 @@ add_subdirectory(src/usvfs_helper)
add_subdirectory(src/usvfs_dll)
add_subdirectory(src/usvfs_proxy)

configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/config.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/usvfsConfig.cmake"
INSTALL_DESTINATION "lib/cmake/usvfs"
NO_SET_AND_CHECK_MACRO
NO_CHECK_REQUIRED_COMPONENTS_MACRO
)

file(READ "${CMAKE_CURRENT_SOURCE_DIR}/include/usvfs/usvfs_version.h" usvfs_version)
string(REGEX MATCH "USVFS_VERSION_MAJOR ([0-9]*)" _ ${usvfs_version})
set(usvfs_version_major ${CMAKE_MATCH_1})
string(REGEX MATCH "USVFS_VERSION_MINOR ([0-9]*)" _ ${usvfs_version})
set(usvfs_version_minor ${CMAKE_MATCH_1})
string(REGEX MATCH "USVFS_VERSION_BUILD ([0-9]*)" _ ${usvfs_version})
set(usvfs_version_build ${CMAKE_MATCH_1})
string(REGEX MATCH "USVFS_VERSION_REVISION ([0-9]*)" _ ${usvfs_version})
set(usvfs_version_revision ${CMAKE_MATCH_1})

write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/usvfsConfigVersion.cmake"
VERSION "${usvfs_version_major}.${usvfs_version_minor}.${usvfs_version_build}.${usvfs_version_revision}"
COMPATIBILITY AnyNewerVersion
)

install(FILES
${CMAKE_CURRENT_BINARY_DIR}/usvfsConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/usvfsConfigVersion.cmake
DESTINATION lib/cmake/usvfs
)

if (BUILD_TESTING)
enable_testing()
set(USVFS_TEST_BINDIR ${CMAKE_CURRENT_LIST_DIR}/test/bin)
Expand Down
6 changes: 6 additions & 0 deletions cmake/config.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@PACKAGE_INIT@

include ( "${CMAKE_CURRENT_LIST_DIR}/usvfs_x86Targets.cmake" )
include ( "${CMAKE_CURRENT_LIST_DIR}/usvfs_x64Targets.cmake" )

add_library(usvfs::usvfs ALIAS usvfs_x64::usvfs_dll)

0 comments on commit 63bd972

Please sign in to comment.