Skip to content

Commit

Permalink
Allow saying find_package(XACC 1.0.0)
Browse files Browse the repository at this point in the history
This creates a version file so that you can specify a version for
find_package(XACC), like find_package(XACC 1.0.0). For more info, see:
https://cmake.org/cmake/help/latest/command/find_package.html#config-mode-version-selection
  • Loading branch information
ausbin committed Jun 2, 2024
1 parent 187a3e7 commit 5329e78
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,9 @@ set(PATCH_VERSION 0)
# their CMake builds, and pass -DXACC_DIR=/path/to/install/xacc
# and CMake loads include paths, libs, etc
configure_file("${CMAKE_SOURCE_DIR}/cmake/xacc-config.cmake.in" "${CMAKE_BINARY_DIR}/xacc-config.cmake" @ONLY)
configure_file("${CMAKE_SOURCE_DIR}/cmake/xacc-config-version.cmake.in" "${CMAKE_BINARY_DIR}/xacc-config-version.cmake" @ONLY)
install(FILES "${CMAKE_BINARY_DIR}/xacc-config.cmake" DESTINATION .)
install(FILES "${CMAKE_BINARY_DIR}/xacc-config-version.cmake" DESTINATION .)
install(FILES "${CMAKE_SOURCE_DIR}/cmake/Modules/format.cmake" DESTINATION share/xacc/)
install(FILES "${CMAKE_SOURCE_DIR}/tpls/mpark-variant/variant.hpp" DESTINATION include/xacc/)
install(FILES "${CMAKE_SOURCE_DIR}/tpls/taocpp/operators.hpp" DESTINATION include/xacc/)
Expand Down
8 changes: 8 additions & 0 deletions cmake/xacc-config-version.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
set(PACKAGE_VERSION "@MAJOR_VERSION@.@MINOR_VERSION@.@PATCH_VERSION@")
# The quotes for the right operand are intentional here: if CMake executes this
# file without ${PACKAGE_FIND_VERSION} set, then if() will still get three
# operands. Without the quotes, if() will only get two operands in that case,
# throwing an error.
if(${PACKAGE_VERSION} VERSION_GREATER_EQUAL "${PACKAGE_FIND_VERSION}")
set(PACKAGE_VERSION_COMPATIBLE 1)
endif()
4 changes: 0 additions & 4 deletions cmake/xacc-config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@ if(NOT TARGET format)
endif()

# Set version info
set(XACC_VERSION_MAJOR @MAJOR_VERSION@)
set(XACC_VERSION_MINOR @MINOR_VERSION@)
set(XACC_VERSION_PATCH @PATCH_VERSION@)
set(XACC_VERSION_SUFFIX @XACC_BUILD_VERSION@)
set(XACC_VERSION "@MAJOR_VERSION@.@MINOR_VERSION@.@PATCH_VERSION@-@XACC_BUILD_VERSION@")

set(XACC_LIBRARY_DIR "${XACC_ROOT}/lib")

Expand Down

0 comments on commit 5329e78

Please sign in to comment.