Skip to content

Commit

Permalink
cmake: simplify installation, install as architecture-independent
Browse files Browse the repository at this point in the history
Since μt is header/module-only so it should be installed to an architecture-independent location.
While PackageProject.cmake supports the ARCH_INDEPENDENT I ripped it out in favour of doing everything ourselves as:
1. This removes a layer of abstraction while still being short and simple (delta -190 lines).
2. Results in a smaller installed CMake footprint.
3. Is more suitable for Linux distributions due to not including the version number in various installed paths.
4. Makes the whole repository single licence (BSL-1.0) again as PackageProject.cmake was MIT.
  • Loading branch information
tambry committed Jan 5, 2025
1 parent f83e15c commit 23b3f9f
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 222 deletions.
53 changes: 32 additions & 21 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,7 @@ option(BOOST_UT_USE_WARNINGS_AS_ERORS "Build the tests" ${PROJECT_IS_TOP_LEVEL})
option(BOOST_UT_DISABLE_MODULE "Disable ut module" OFF)

add_library(ut INTERFACE)

if(NOT DEFINED INCLUDE_INSTALL_DIR)
set(INCLUDE_INSTALL_DIR include/${PROJECT_NAME}-${PROJECT_VERSION}/include)
endif()
target_include_directories(ut INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:${INCLUDE_INSTALL_DIR}>)
target_include_directories(ut INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>)
target_compile_features(ut INTERFACE cxx_std_20)

if(BOOST_UT_USE_WARNINGS_AS_ERORS)
Expand Down Expand Up @@ -65,26 +61,41 @@ if(BOOST_UT_DISABLE_MODULE)
target_compile_definitions(ut INTERFACE BOOST_UT_DISABLE_MODULE)
endif()

if(BOOST_UT_ENABLE_INSTALL AND NOT CMAKE_SKIP_INSTALL_RULES)
include(cmake/PackageProject.cmake)
# Create target Boost::ut and install target
packageProject(
NAME ${PROJECT_NAME}
VERSION ${PROJECT_VERSION}
NAMESPACE Boost
BINARY_DIR ${PROJECT_BINARY_DIR}
INCLUDE_DIR ${PROJECT_SOURCE_DIR}/include
INCLUDE_DESTINATION ${INCLUDE_INSTALL_DIR}
# XXX variant: DISABLE_VERSION_SUFFIX YES
COMPATIBILITY SameMajorVersion
# Note: only if needed i.e. DEPENDENCIES "fmt 7.1.3; span"
)
endif()

if(NOT TARGET Boost::ut)
add_library(Boost::ut ALIAS ut)
endif()

include(GNUInstallDirs)
include(CMakePackageConfigHelpers)

install(
FILES include/boost/ut.hpp
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/boost
)

install(
TARGETS ut
EXPORT ut_Targets
INCLUDES DESTINATION include
)
install(
EXPORT ut_Targets
FILE utConfig.cmake
NAMESPACE Boost::
DESTINATION lib/cmake/ut
)

write_basic_package_version_file(
"utConfigVersion.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion
ARCH_INDEPENDENT
)
install(
FILES "${PROJECT_BINARY_DIR}/utConfigVersion.cmake"
DESTINATION lib/cmake/ut
)

if(EMSCRIPTEN)
set(CMAKE_EXECUTABLE_SUFFIX ".js")
target_link_options(ut INTERFACE "SHELL:-s ALLOW_MEMORY_GROWTH=1" "SHELL:-s EXIT_RUNTIME=1" -fwasm-exceptions -g)
Expand Down
13 changes: 0 additions & 13 deletions cmake/Config.cmake.in

This file was deleted.

188 changes: 0 additions & 188 deletions cmake/PackageProject.cmake

This file was deleted.

0 comments on commit 23b3f9f

Please sign in to comment.