mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-26 23:36:11 +01:00
Disable installation step when Catch is used as a subproject
This is because otherwise the installations paths provided via GNUInstallDirs become messed up and parts of the installation package will end up in the wrong place. Also it doesn't make much sense to force dependees to also install our header alongside them. Closes #1373
This commit is contained in:
parent
90663b2e75
commit
0646e0283c
@ -91,102 +91,107 @@ target_include_directories(Catch2
|
|||||||
# provide a namespaced alias for clients to 'link' against if catch is included as a sub-project
|
# provide a namespaced alias for clients to 'link' against if catch is included as a sub-project
|
||||||
add_library(Catch2::Catch2 ALIAS Catch2)
|
add_library(Catch2::Catch2 ALIAS Catch2)
|
||||||
|
|
||||||
set(CATCH_CMAKE_CONFIG_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/Catch2")
|
# Only perform the installation steps when Catch is not being used as
|
||||||
|
# a subproject via `add_subdirectory`, or the destinations will break,
|
||||||
|
# see https://github.com/catchorg/Catch2/issues/1373
|
||||||
|
if (NOT_SUBPROJECT)
|
||||||
|
set(CATCH_CMAKE_CONFIG_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/Catch2")
|
||||||
|
|
||||||
include(CMakePackageConfigHelpers)
|
configure_package_config_file(
|
||||||
configure_package_config_file(
|
|
||||||
${CMAKE_CURRENT_LIST_DIR}/CMake/Catch2Config.cmake.in
|
${CMAKE_CURRENT_LIST_DIR}/CMake/Catch2Config.cmake.in
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/Catch2Config.cmake
|
${CMAKE_CURRENT_BINARY_DIR}/Catch2Config.cmake
|
||||||
INSTALL_DESTINATION
|
INSTALL_DESTINATION
|
||||||
${CATCH_CMAKE_CONFIG_DESTINATION}
|
${CATCH_CMAKE_CONFIG_DESTINATION}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
# create and install an export set for catch target as Catch2::Catch
|
# create and install an export set for catch target as Catch2::Catch
|
||||||
install(
|
install(
|
||||||
TARGETS
|
TARGETS
|
||||||
Catch2
|
Catch2
|
||||||
EXPORT
|
EXPORT
|
||||||
Catch2Targets
|
Catch2Targets
|
||||||
DESTINATION
|
DESTINATION
|
||||||
${CMAKE_INSTALL_LIBDIR}
|
${CMAKE_INSTALL_LIBDIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
install(
|
install(
|
||||||
EXPORT
|
EXPORT
|
||||||
Catch2Targets
|
Catch2Targets
|
||||||
NAMESPACE
|
NAMESPACE
|
||||||
Catch2::
|
Catch2::
|
||||||
DESTINATION
|
DESTINATION
|
||||||
${CATCH_CMAKE_CONFIG_DESTINATION}
|
${CATCH_CMAKE_CONFIG_DESTINATION}
|
||||||
)
|
)
|
||||||
|
|
||||||
write_basic_package_version_file(
|
write_basic_package_version_file(
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/Catch2ConfigVersion.cmake"
|
"${CMAKE_CURRENT_BINARY_DIR}/Catch2ConfigVersion.cmake"
|
||||||
COMPATIBILITY
|
COMPATIBILITY
|
||||||
SameMajorVersion
|
SameMajorVersion
|
||||||
)
|
)
|
||||||
|
|
||||||
install(
|
install(
|
||||||
DIRECTORY
|
DIRECTORY
|
||||||
"single_include/"
|
"single_include/"
|
||||||
DESTINATION
|
DESTINATION
|
||||||
"${CMAKE_INSTALL_INCLUDEDIR}"
|
"${CMAKE_INSTALL_INCLUDEDIR}"
|
||||||
)
|
)
|
||||||
|
|
||||||
install(
|
install(
|
||||||
FILES
|
FILES
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/Catch2Config.cmake"
|
"${CMAKE_CURRENT_BINARY_DIR}/Catch2Config.cmake"
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/Catch2ConfigVersion.cmake"
|
"${CMAKE_CURRENT_BINARY_DIR}/Catch2ConfigVersion.cmake"
|
||||||
DESTINATION
|
DESTINATION
|
||||||
${CATCH_CMAKE_CONFIG_DESTINATION}
|
${CATCH_CMAKE_CONFIG_DESTINATION}
|
||||||
)
|
)
|
||||||
|
|
||||||
# Install documentation
|
# Install documentation
|
||||||
if(CATCH_INSTALL_DOCS)
|
if(CATCH_INSTALL_DOCS)
|
||||||
install(
|
install(
|
||||||
DIRECTORY
|
DIRECTORY
|
||||||
docs/
|
docs/
|
||||||
DESTINATION
|
DESTINATION
|
||||||
"${CMAKE_INSTALL_DOCDIR}"
|
"${CMAKE_INSTALL_DOCDIR}"
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CATCH_INSTALL_HELPERS)
|
if(CATCH_INSTALL_HELPERS)
|
||||||
# Install CMake scripts
|
# Install CMake scripts
|
||||||
install(
|
install(
|
||||||
FILES
|
FILES
|
||||||
"contrib/ParseAndAddCatchTests.cmake"
|
"contrib/ParseAndAddCatchTests.cmake"
|
||||||
"contrib/Catch.cmake"
|
"contrib/Catch.cmake"
|
||||||
"contrib/CatchAddTests.cmake"
|
"contrib/CatchAddTests.cmake"
|
||||||
DESTINATION
|
DESTINATION
|
||||||
${CATCH_CMAKE_CONFIG_DESTINATION}
|
${CATCH_CMAKE_CONFIG_DESTINATION}
|
||||||
)
|
)
|
||||||
|
|
||||||
# Install debugger helpers
|
# Install debugger helpers
|
||||||
install(
|
install(
|
||||||
FILES
|
FILES
|
||||||
"contrib/gdbinit"
|
"contrib/gdbinit"
|
||||||
"contrib/lldbinit"
|
"contrib/lldbinit"
|
||||||
DESTINATION
|
DESTINATION
|
||||||
${CMAKE_INSTALL_DATAROOTDIR}/Catch2
|
${CMAKE_INSTALL_DATAROOTDIR}/Catch2
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
## Provide some pkg-config integration
|
## Provide some pkg-config integration
|
||||||
set(PKGCONFIG_INSTALL_DIR
|
set(PKGCONFIG_INSTALL_DIR
|
||||||
"${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig"
|
"${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig"
|
||||||
CACHE PATH "Path where catch2.pc is installed"
|
CACHE PATH "Path where catch2.pc is installed"
|
||||||
)
|
)
|
||||||
configure_file(
|
configure_file(
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/CMake/catch2.pc.in
|
${CMAKE_CURRENT_SOURCE_DIR}/CMake/catch2.pc.in
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/catch2.pc
|
${CMAKE_CURRENT_BINARY_DIR}/catch2.pc
|
||||||
@ONLY
|
@ONLY
|
||||||
)
|
)
|
||||||
install(
|
install(
|
||||||
FILES
|
FILES
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/catch2.pc"
|
"${CMAKE_CURRENT_BINARY_DIR}/catch2.pc"
|
||||||
DESTINATION
|
DESTINATION
|
||||||
${PKGCONFIG_INSTALL_DIR}
|
${PKGCONFIG_INSTALL_DIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
endif(NOT_SUBPROJECT)
|
||||||
|
Loading…
Reference in New Issue
Block a user