FTXUI/cmake/ftxui_install.cmake
Henrik Gaßmann e2aff66b98
build: Check package version in find_package (#643)
Modify the `ftxui-config.cmake.in` file so that it includes
`ftxui-targets.cmake`. This causes cmake to check the version is
compatible with what the user requested.

This patch also includes additional minor changes.

Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
2023-05-25 19:37:55 +02:00

63 lines
2.2 KiB
CMake

if(NOT FTXUI_ENABLE_INSTALL)
return()
endif()
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
# ------------------------------------------------------------------------------
# Install the library and its public headers into the standard subdirectories
# ------------------------------------------------------------------------------
install(
TARGETS screen dom component
EXPORT ftxui-targets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
install(
DIRECTORY include/ftxui
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
# ------------------------------------------------------------------------------
# Install the exported cmake targets for use in other CMake projects.
# ------------------------------------------------------------------------------
install(
EXPORT ftxui-targets
NAMESPACE ftxui::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/ftxui
)
# ------------------------------------------------------------------------------
# Create and install the ftuxi-config.cmake and ftuxi-config-version.cmake files
# needed to support users of find_package()
# ------------------------------------------------------------------------------
configure_package_config_file(
${CMAKE_CURRENT_SOURCE_DIR}/cmake/ftxui-config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/cmake/ftxui-config.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/ftxui/cmake
PATH_VARS CMAKE_INSTALL_INCLUDEDIR
)
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/cmake/ftxui-config-version.cmake
VERSION ${PACKAGE_VERSION}
COMPATIBILITY SameMajorVersion
)
install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/cmake/ftxui-config.cmake
${CMAKE_CURRENT_BINARY_DIR}/cmake/ftxui-config-version.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/ftxui
)
# ------------------------------------------------------------------------------
# Create and install pkg-config file for easy use of library in build systems
# other than CMake:
# ------------------------------------------------------------------------------
configure_file(ftxui.pc.in ${CMAKE_CURRENT_BINARY_DIR}/ftxui.pc @ONLY)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/ftxui.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}
)