Skip to content

Commit

Permalink
Add a config CMake (#752)
Browse files Browse the repository at this point in the history
Signed-off-by: Juan Cruz Viotti <[email protected]>
  • Loading branch information
jviotti authored Feb 12, 2024
1 parent 0bdb1e0 commit bb39c06
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
18 changes: 17 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,23 @@ option(JSONBINPACK_DOCS "Build the JSON BinPack documentation" OFF)
option(JSONBINPACK_ADDRESS_SANITIZER "Build JSON BinPack with an address sanitizer" OFF)
option(JSONBINPACK_UNDEFINED_SANITIZER "Build JSON BinPack with an undefined behavior sanitizer" OFF)

# TODO: Generate (and test) CMake config
# TODO: Test CMake config
if(PROJECT_IS_TOP_LEVEL)
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
configure_package_config_file(
config.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake"
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake"
COMPATIBILITY SameMajorVersion)
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
COMPONENT sourcemeta_jsonbinpack_dev)
endif()

# Dependencies
find_package(JSONToolkit REQUIRED)
Expand Down
7 changes: 7 additions & 0 deletions config.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@PACKAGE_INIT@

# TODO: Support component-based `find_package`
find_package(JSONToolkit REQUIRED)
include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_jsonbinpack_runtime.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_jsonbinpack_compiler.cmake")
check_required_components("@PROJECT_NAME@")

0 comments on commit bb39c06

Please sign in to comment.