Skip to content

Commit 7b32b18

Browse files
committed
Add standalone path and keep support for boost superproject
1 parent e6cf9b6 commit 7b32b18

File tree

1 file changed

+73
-7
lines changed

1 file changed

+73
-7
lines changed

CMakeLists.txt

Lines changed: 73 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,34 @@
1-
# Generated by `boostdep --cmake int128`
2-
# Copyright 2020, 2021 Peter Dimov
3-
# Copyright 2023 Matt Borland
1+
# Copyright 2023 - 2025 Matt Borland
42
# Distributed under the Boost Software License, Version 1.0.
53
# https://www.boost.org/LICENSE_1_0.txt
64

7-
cmake_minimum_required(VERSION 3.8...3.20)
5+
cmake_minimum_required(VERSION 3.10...3.20)
86

9-
project(boost_int128 VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
7+
# Set version explicitly if not part of Boost superproject
8+
if(NOT BOOST_SUPERPROJECT_VERSION)
9+
set(BOOST_INT128_VERSION 1.1.0)
10+
else()
11+
set(BOOST_INT128_VERSION ${BOOST_SUPERPROJECT_VERSION})
12+
endif()
13+
14+
project(boost_int128 VERSION ${BOOST_INT128_VERSION} LANGUAGES CXX)
1015

1116
add_library(boost_int128 INTERFACE)
1217

1318
add_library(Boost::int128 ALIAS boost_int128)
1419

15-
target_include_directories(boost_int128 INTERFACE include)
20+
if(NOT BOOST_SUPERPROJECT_VERSION)
21+
22+
target_include_directories(boost_int128 INTERFACE
23+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
24+
$<INSTALL_INTERFACE:include>
25+
)
26+
27+
else()
28+
29+
target_include_directories(boost_int128 INTERFACE include)
30+
31+
endif()
1632

1733
target_compile_features(boost_int128 INTERFACE cxx_std_14)
1834

@@ -22,9 +38,59 @@ if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt")
2238

2339
endif()
2440

41+
# Installation and config-file package generation
2542
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
2643

2744
include(GNUInstallDirs)
28-
install(DIRECTORY "include/" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
45+
include(CMakePackageConfigHelpers)
46+
47+
# Install headers
48+
install(DIRECTORY "include/"
49+
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
50+
)
51+
52+
# Install targets
53+
install(TARGETS boost_int128
54+
EXPORT boost_int128Targets
55+
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
56+
)
57+
58+
# Install export targets
59+
install(EXPORT boost_int128Targets
60+
FILE boost_int128Targets.cmake
61+
NAMESPACE Boost::
62+
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/boost_int128"
63+
)
64+
65+
# Generate config files
66+
configure_package_config_file(
67+
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/boost_int128Config.cmake.in"
68+
"${CMAKE_CURRENT_BINARY_DIR}/boost_int128Config.cmake"
69+
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/boost_int128"
70+
)
71+
72+
write_basic_package_version_file(
73+
"${CMAKE_CURRENT_BINARY_DIR}/boost_int128ConfigVersion.cmake"
74+
VERSION ${PROJECT_VERSION}
75+
COMPATIBILITY SameMajorVersion
76+
)
77+
78+
# Install config files
79+
install(FILES
80+
"${CMAKE_CURRENT_BINARY_DIR}/boost_int128Config.cmake"
81+
"${CMAKE_CURRENT_BINARY_DIR}/boost_int128ConfigVersion.cmake"
82+
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/boost_int128"
83+
)
84+
85+
configure_file(
86+
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/boost_int128.pc.in"
87+
"${CMAKE_CURRENT_BINARY_DIR}/boost_int128.pc"
88+
@ONLY
89+
)
90+
91+
install(FILES
92+
"${CMAKE_CURRENT_BINARY_DIR}/boost_int128.pc"
93+
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig"
94+
)
2995

3096
endif()

0 commit comments

Comments
 (0)