ClausKlein
(Claus Klein)
December 30, 2023, 5:50pm
1
With this example
cmake_minimum_required(VERSION 3.14...3.28)
project(CPMExampleBoost VERSION 0.1.2 LANGUAGES CXX)
# ---- Create binary ----
add_executable(CPMExampleBoost main.cpp)
target_compile_features(CPMExampleBoost PRIVATE cxx_std_17)
# ---- Dependencies ----
include(../../cmake/CPM.cmake)
include(FetchContent)
option(BUILD_SHARED_LIBS "yes/no" YES)
CPMAddPackage(
NAME Boost
URL https://github.com/boostorg/boost/releases/download/boost-1.84.0/boost-1.84.0.tar.xz
URL_MD5 893b5203b862eb9bbd08553e24ff146a
EXCLUDE_FROM_ALL ON
SYSTEM ON
)
# ---- Create a library ----
add_library(scoped_lock scoped_lock.cpp scoped_lock.hpp)
target_compile_features(scoped_lock PUBLIC cxx_std_17)
install(FILES scoped_lock.hpp TYPE INCLUDE)
# ---- Install the library ----
target_link_libraries(scoped_lock PUBLIC Boost::thread)
install(TARGETS scoped_lock # XXX boost_thread
RUNTIME_DEPENDENCY_SET libDeps
)
install(RUNTIME_DEPENDENCY_SET libDeps)
# ---- Install the binary and its runtime dependeny set ----
target_link_libraries(CPMExampleBoost PUBLIC Boost::asio Boost::date_time Boost::filesystem)
install(TARGETS CPMExampleBoost # XXX boost_asio boost_date_time boost_filesystem
RUNTIME_DEPENDENCY_SET appDeps
)
install(RUNTIME_DEPENDENCY_SET appDeps)
set(CPACK_PACKAGE_INSTALL_DIRECTORY /)
set(CPACK_GENERATOR TBZ2)
include(CPack)
DESTDIR=/tmp ninja -C build install
ninja: Entering directory `build'
[0/2] Re-checking globbed directories...
[0/1] Install the project...
-- Install configuration: ""
-- Up-to-date: /tmp/usr/local/include/scoped_lock.hpp
-- Installing: /tmp/usr/local/lib/libscoped_lock.dylib
-- Installing: /tmp/usr/local/bin/CPMExampleBoost
bash-5.2$ dyld_info /tmp/usr/local/bin/CPMExampleBoost
/tmp/usr/local/bin/CPMExampleBoost [x86_64]:
-platform:
platform minOS sdk
macOS 13.6 14.2
-segments:
load-offset segment section sect-size seg-size perm
0x00000000 __TEXT 160KB r.x
0x00005EA0 __text 122362
0x00023C9A __stubs 4080
0x00024C8C __init_offsets 36
0x00024CB0 __gcc_except_tab 4460
0x00025E1C __cstring 2317
0x0002672C __const 2632
0x00027174 __unwind_info 3720
0x00028000 __DATA_CONST 16KB rw.
0x00028000 __got 6088
0x000297D0 __const 5184
0x0002C000 __DATA 16KB rw.
0x0002C000 __data 416
0x0002C1A0 __thread_vars 24
0x0002C1B8 __thread_ptrs 8
0x0002C1C0 __thread_bss 8
0x0002C1C8 __bss 32
-dependents:
attributes load path
@rpath/libboost_date_time.1.84.0.dylib
@rpath/libboost_filesystem.1.84.0.dylib
@rpath/libboost_container.1.84.0.dylib
@rpath/libboost_coroutine.1.84.0.dylib
@rpath/libboost_context.1.84.0.dylib
/usr/lib/libc++.1.dylib
/usr/lib/libSystem.B.dylib
bash-5.2$ /tmp/usr/local/bin/CPMExampleBoost
dyld[49545]: Symbol not found: __ZN5boost10filesystem6detail12current_pathEPNS_6system10error_codeE
Referenced from: <1D145780-04CD-322C-82F2-5CBBF64C507C> /private/tmp/usr/local/bin/CPMExampleBoost
Expected in: <no uuid> unknown
Abort trap: 6
ClausKlein
(Claus Klein)
December 30, 2023, 5:55pm
2
IMHO : the generated cmake_install.cmake script is buggy:
if(CMAKE_INSTALL_COMPONENT STREQUAL "Unspecified" OR NOT CMAKE_INSTALL_COMPONENT)
file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/bin" TYPE EXECUTABLE FILES "/Users/clausklein/cmake/TheLartians/CPM.cmake/examples/boost/build/CPMExampleBoost")
if(EXISTS "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/bin/CPMExampleBoost" AND
NOT IS_SYMLINK "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/bin/CPMExampleBoost")
execute_process(COMMAND /usr/bin/install_name_tool
-delete_rpath "/Users/clausklein/cmake/TheLartians/CPM.cmake/examples/boost/build/_deps/boost-build/libs/date_time"
-delete_rpath "/Users/clausklein/cmake/TheLartians/CPM.cmake/examples/boost/build/_deps/boost-build/libs/filesystem"
-delete_rpath "/Users/clausklein/cmake/TheLartians/CPM.cmake/examples/boost/build/_deps/boost-build/libs/container"
-delete_rpath "/Users/clausklein/cmake/TheLartians/CPM.cmake/examples/boost/build/_deps/boost-build/libs/coroutine"
-delete_rpath "/Users/clausklein/cmake/TheLartians/CPM.cmake/examples/boost/build/_deps/boost-build/libs/context"
"$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/bin/CPMExampleBoost")
if(CMAKE_INSTALL_DO_STRIP)
execute_process(COMMAND "/usr/bin/strip" -u -r "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/bin/CPMExampleBoost")
endif()
endif()
endif()
if(CMAKE_INSTALL_COMPONENT STREQUAL "Unspecified" OR NOT CMAKE_INSTALL_COMPONENT)
file(GET_RUNTIME_DEPENDENCIES
RESOLVED_DEPENDENCIES_VAR _CMAKE_DEPS
EXECUTABLES
"/Users/clausklein/cmake/TheLartians/CPM.cmake/examples/boost/build/CPMExampleBoost"
POST_EXCLUDE_FILES_STRICT
"/Users/clausklein/cmake/TheLartians/CPM.cmake/examples/boost/build/_deps/boost-build/libs/atomic/libboost_atomic.dylib"
"/Users/clausklein/cmake/TheLartians/CPM.cmake/examples/boost/build/_deps/boost-build/libs/container/libboost_container.dylib"
"/Users/clausklein/cmake/TheLartians/CPM.cmake/examples/boost/build/_deps/boost-build/libs/context/libboost_context.dylib"
"/Users/clausklein/cmake/TheLartians/CPM.cmake/examples/boost/build/_deps/boost-build/libs/coroutine/libboost_coroutine.dylib"
"/Users/clausklein/cmake/TheLartians/CPM.cmake/examples/boost/build/_deps/boost-build/libs/date_time/libboost_date_time.dylib"
"/Users/clausklein/cmake/TheLartians/CPM.cmake/examples/boost/build/_deps/boost-build/libs/filesystem/libboost_filesystem.dylib"
)
endif()
ClausKlein
(Claus Klein)
December 30, 2023, 10:43pm
3
I had to invest a load of time without success!
This is the project files where I had to installing all not direct dependent boost libraries (A bad HACK! )
If I would add more code in my example project, I would end to install most boost libraries (up to 150) manually.
cmake_minimum_required(VERSION 3.16...3.28)
project(
CPMExampleBoost
VERSION 0.1.2
LANGUAGES CXX
)
set(stageDir ${CMAKE_CURRENT_BINARY_DIR}/stage)
include(GNUInstallDirs)
if(NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${stageDir}/${CMAKE_INSTALL_BINDIR})
endif()
if(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${stageDir}/${CMAKE_INSTALL_LIBDIR})
endif()
if(NOT CMAKE_ARCHIVE_OUTPUT_DIRECTORY)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${stageDir}/${CMAKE_INSTALL_LIBDIR})
endif()
set(CMAKE_INSTALL_MESSAGE LAZY)
option(BUILD_SHARED_LIBS "yes/no" YES)
if(BUILD_SHARED_LIBS)
if(APPLE)
set(base @loader_path)
else()
set(base $ORIGIN)
endif()
file(RELATIVE_PATH relDir ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}
)
set(CMAKE_INSTALL_RPATH ${base} ${base}/${relDir})
# FIXME: install(DIRECTORY "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/" DESTINATION
# ${CMAKE_INSTALL_LIBDIR})
endif()
# ---- Create binary ----
add_executable(CPMExampleBoost main.cpp)
target_compile_features(CPMExampleBoost PRIVATE cxx_std_17)
# ---- Dependencies ----
include(../../cmake/CPM.cmake)
# XXX list(APPEND BOOST_INCLUDE_LIBRARIES headers asio date_time filesystem thread)
CPMAddPackage(
NAME Boost
URL https://github.com/boostorg/boost/releases/download/boost-1.84.0/boost-1.84.0.tar.xz
URL_MD5 893b5203b862eb9bbd08553e24ff146a
EXCLUDE_FROM_ALL ON
SYSTEM ON
)
# ---- Create a library ----
add_library(scoped_lock scoped_lock.cpp scoped_lock.hpp)
target_compile_features(scoped_lock PUBLIC cxx_std_17)
install(FILES scoped_lock.hpp TYPE INCLUDE)
# ---- Install the library ----
target_link_libraries(scoped_lock PUBLIC Boost::thread)
install(
TARGETS scoped_lock
boost_thread # XXX ...
boost_atomic
boost_chrono
boost_container
RUNTIME_DEPENDENCY_SET
libDeps
)
install(RUNTIME_DEPENDENCY_SET libDeps POST_INCLUDE_REGEXES
[[${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libboost_.*]]
)
# ---- Install the binary and its runtime dependency set ----
target_link_libraries(CPMExampleBoost PUBLIC Boost::asio Boost::date_time Boost::filesystem)
install(
TARGETS CPMExampleBoost
boost_asio
boost_date_time
boost_filesystem # XXX ...
boost_context
boost_coroutine
RUNTIME_DEPENDENCY_SET
appDeps
)
install(RUNTIME_DEPENDENCY_SET appDeps POST_INCLUDE_REGEXES
[[${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libboost_.*]]
)
set(CPACK_PACKAGE_INSTALL_DIRECTORY /)
set(CPACK_GENERATOR TBZ2)
include(CPack)
ben.boeckel
(Ben Boeckel (Kitware))
December 31, 2023, 6:29pm
4
Does it work if you flip the rpath editing and the runtime dependency discovery blocks in the install script?
ClausKlein
(Claus Klein)
December 31, 2023, 6:49pm
5
My First try was without rpath.
And I dit it also without explizit installing the boost libs.
ClausKlein
(Claus Klein)
December 31, 2023, 6:55pm
6
What is the reason for this?
If I change this to
POST_INCLUDE_FILES
it Works!
ben.boeckel
(Ben Boeckel (Kitware))
December 31, 2023, 7:14pm
7
It looks like that is the mechanism by which in-project files are excluded from installation by RUNTIME_DEPENDENCY_SET
.
ClausKlein
(Claus Klein)
December 31, 2023, 10:47pm
8
But this is exactly what is needed for transitive runtime-dependencies while using FetchContents
!
I have a lot of project that use spdlog
which use fmt
, or I use a project, that depends on 2 other libs which both use magic_enum
, and so on. I normally use CPM.cmake
to fetch only my direct dependencies. But I need to install them all.
ben.boeckel
(Ben Boeckel (Kitware))
January 1, 2024, 2:10pm
9
If you are vendoring them, you are responsible for their install rules too.
@craig.scott Any suggestions?
ClausKlein
(Claus Klein)
January 1, 2024, 9:00pm
10
Now I am totally confused.
What means install(RUNTIME_DEPENDENCY_SET libDeps)
really?
With this CMakeLists.txt:
cmake_minimum_required(VERSION 3.21...3.28)
project(
CPMExampleBoost
VERSION 0.1.2
LANGUAGES CXX
)
set(stageDir ${CMAKE_CURRENT_BINARY_DIR}/stage)
include(GNUInstallDirs)
if(NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${stageDir}/${CMAKE_INSTALL_BINDIR})
endif()
if(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${stageDir}/${CMAKE_INSTALL_LIBDIR})
endif()
if(NOT CMAKE_ARCHIVE_OUTPUT_DIRECTORY)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${stageDir}/${CMAKE_INSTALL_LIBDIR})
endif()
option(CPM_USE_LOCAL_PACKAGES "yes/no" YES)
option(BUILD_SHARED_LIBS "yes/no" YES)
if(BUILD_SHARED_LIBS)
if(APPLE)
set(base @loader_path)
else()
set(base $ORIGIN)
endif()
file(RELATIVE_PATH relDir ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}
)
set(CMAKE_INSTALL_RPATH ${base} ${base}/${relDir})
endif()
set(CMAKE_INSTALL_MESSAGE LAZY)
# ---- Create binary ----
add_executable(CPMExampleBoost main.cpp)
target_compile_features(CPMExampleBoost PRIVATE cxx_std_17)
# ---- Dependencies ----
include(../../cmake/CPM.cmake)
CPMAddPackage(
NAME Boost
VERSION 1.83
URL https://github.com/boostorg/boost/releases/download/boost-1.84.0/boost-1.84.0.tar.xz
URL_MD5 893b5203b862eb9bbd08553e24ff146a
FIND_PACKAGE_ARGUMENTS "COMPONENTS thread\;date_time\;filesystem"
EXCLUDE_FROM_ALL ON
SYSTEM ON
)
target_link_libraries(CPMExampleBoost PUBLIC Boost::headers Boost::date_time Boost::filesystem)
if(PROJECT_IS_TOP_LEVEL)
enable_testing()
add_test(NAME CPMExampleBoost COMMAND CPMExampleBoost)
endif()
# ---- Create a library ----
add_library(scoped_lock scoped_lock.cpp scoped_lock.hpp)
target_compile_features(scoped_lock PUBLIC cxx_std_17)
target_link_libraries(scoped_lock PUBLIC Boost::thread)
target_include_directories(
scoped_lock PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}>
)
if(NOT CMAKE_SKIP_INSTALL_RULES)
# ---- Install the binary and its runtime dependency set ----
install(
TARGETS CPMExampleBoost
# boost_headers boost_date_time boost_filesystem # XXX ... boost_context boost_coroutine
RUNTIME_DEPENDENCY_SET appDeps EXPORT scoped_lockTargets
)
if(BUILD_SHARED_LIBS)
install(RUNTIME_DEPENDENCY_SET appDeps POST_INCLUDE_REGEXES
[[${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libboost_.*]] EXPORT scoped_lockTargets
)
endif()
# ---- Install the library ----
install(FILES scoped_lock.hpp DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME})
if(NOT CPM_USE_LOCAL_PACKAGES)
install(TARGETS boost_headers EXPORT scoped_lockTargets)
elseif(BOOST_SRC_DIR)
install(TARGETS boost_thread EXPORT scoped_lockTargets)
endif()
install(TARGETS scoped_lock RUNTIME_DEPENDENCY_SET libDeps)
# PackageProject.cmake will be used to export our cmake config packages
CPMAddPackage("gh:TheLartians/PackageProject.cmake@1.11.0")
packageProject(
NAME scoped_lock
VERSION ${PROJECT_VERSION}
NAMESPACE ${PROJECT_NAME}
BINARY_DIR ${PROJECT_BINARY_DIR}
COMPATIBILITY AnyNewerVersion
DISABLE_VERSION_SUFFIX YES
DEPENDENCIES "Boost 1.83"
)
if(BUILD_SHARED_LIBS)
install(RUNTIME_DEPENDENCY_SET libDeps POST_INCLUDE_REGEXES
[[${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libboost_.*]] EXPORT scoped_lockTargets
)
endif()
set(CPACK_PACKAGE_INSTALL_DIRECTORY /)
set(CPACK_GENERATOR TBZ2)
include(CPack)
endif()
It will result to this:
bash-5.2$ cmake -G Ninja -B build -S . --fresh
-- The CXX compiler identification is Clang 17.0.6
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/local/opt/llvm/bin/clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Warning at /Users/clausklein/cmake/TheLartians/CPM.cmake/cmake/CPM.cmake:76 (message):
CPM: Your project is using an unstable development version of CPM.cmake.
Please update to a recent release if possible. See
https://github.com/cpm-cmake/CPM.cmake for details.
Call Stack (most recent call first):
CMakeLists.txt:46 (include)
-- CPM: Using local package Boost@1.83.0
-- Found Git: /usr/local/bin/git (found version "2.43.0")
-- CPM: Adding package PackageProject.cmake@1.11.0 (v1.11.0 at /Users/clausklein/.cache/CPM/packageproject.cmake/fc402989ee6e628476b3d8661f8f96774d89df74)
-- Configuring done (1.7s)
-- Generating done (0.0s)
-- Build files have been written to: /Users/clausklein/cmake/TheLartians/CPM.cmake/examples/boost/build
bash-5.2$ cd build
bash-5.2$ ninja
[4/4] Linking CXX executable stage/bin/CPMExampleBoost
bash-5.2$ ctest
Test project /Users/clausklein/cmake/TheLartians/CPM.cmake/examples/boost/build
Start 1: CPMExampleBoost
1/1 Test #1: CPMExampleBoost .................. Passed 1.39 sec
100% tests passed, 0 tests failed out of 1
Total Test time (real) = 1.41 sec
bash-5.2$ ll stage/
total 0
drwxr-xr-x 4 clausklein 128 Jan 1 21:52 ./
drwxr-xr-x 3 clausklein 96 Jan 1 21:52 lib/
drwxr-xr-x 3 clausklein 96 Jan 1 21:53 bin/
drwxr-xr-x 18 clausklein 576 Jan 1 21:53 ../
bash-5.2$ tree stage/
stage/
|-- bin
| `-- CPMExampleBoost
`-- lib
`-- libscoped_lock.dylib
3 directories, 2 files
bash-5.2$ cpack
CPack: Create package using TBZ2
CPack: Install projects
CPack: - Install project: CPMExampleBoost []
CPack: Create package
CPack: - package: /Users/clausklein/cmake/TheLartians/CPM.cmake/examples/boost/build/CPMExampleBoost-0.1.2-Darwin.tar.bz2 generated.
bash-5.2$ tree _CPack_Packages/
_CPack_Packages/
`-- Darwin
`-- TBZ2
|-- CPMExampleBoost-0.1.2-Darwin
| |-- bin
| | `-- CPMExampleBoost
| |-- include
| | `-- CPMExampleBoost
| | `-- scoped_lock.hpp
| `-- lib
| |-- cmake
| | `-- scoped_lock
| | |-- scoped_lockConfig.cmake
| | |-- scoped_lockConfigVersion.cmake
| | |-- scoped_lockTargets-noconfig.cmake
| | `-- scoped_lockTargets.cmake
| |-- libboost_atomic-mt.dylib
| |-- libboost_date_time-mt.dylib
| |-- libboost_filesystem-mt.dylib
| |-- libboost_thread-mt.dylib
| |-- libscoped_lock.dylib
| `-- scoped_lock
| `-- libscoped_lock.dylib
`-- CPMExampleBoost-0.1.2-Darwin.tar.bz2
11 directories, 13 files
bash-5.2$ make install
make: *** No rule to make target `install'. Stop.
bash-5.2$ ninja install
[0/1] Install the project...
-- Install configuration: ""
-- Installing: /usr/local/bin/CPMExampleBoost
-- Installing: /usr/local/lib/libscoped_lock.dylib
-- Installing: /usr/local/lib/scoped_lock/libscoped_lock.dylib
-- Old export file "/usr/local/lib/cmake/scoped_lock/scoped_lockTargets.cmake" will be replaced. Removing files [/usr/local/lib/cmake/scoped_lock/scoped_lockTargets-noconfig.cmake].
-- Installing: /usr/local/lib/cmake/scoped_lock/scoped_lockTargets.cmake
-- Installing: /usr/local/lib/cmake/scoped_lock/scoped_lockTargets-noconfig.cmake
-- Installing: /usr/local/lib/cmake/scoped_lock/scoped_lockConfigVersion.cmake
-- Installing: /usr/local/lib/cmake/scoped_lock/scoped_lockConfig.cmake
bash-5.2$
ClausKlein
(Claus Klein)
January 1, 2024, 10:13pm
11
It is a night mare with boost git repo cmake files:
-- CPM: Adding package Boost@1.84 (1.84 at /Users/clausklein/.cache/CPM/boost/757f611f9742245129baa985855fbe2d8422f7fa)
-- CPM: Adding package PackageProject.cmake@1.11.0 (v1.11.0 at /Users/clausklein/.cache/CPM/packageproject.cmake/fc402989ee6e628476b3d8661f8f96774d89df74)
-- Configuring done (3.4s)
CMake Error: install(EXPORT "scoped_lockTargets" ...) includes target "boost_thread" which requires target "boost_assert" that is not in any export set.
CMake Error: install(EXPORT "scoped_lockTargets" ...) includes target "boost_thread" which requires target "boost_atomic" that is not in any export set.
CMake Error: install(EXPORT "scoped_lockTargets" ...) includes target "boost_thread" which requires target "boost_bind" that is not in any export set.
CMake Error: install(EXPORT "scoped_lockTargets" ...) includes target "boost_thread" which requires target "boost_chrono" that is not in any export set.
CMake Error: install(EXPORT "scoped_lockTargets" ...) includes target "boost_thread" which requires target "boost_concept_check" that is not in any export set.
CMake Error: install(EXPORT "scoped_lockTargets" ...) includes target "boost_thread" which requires target "boost_config" that is not in any export set.
CMake Error: install(EXPORT "scoped_lockTargets" ...) includes target "boost_thread" which requires target "boost_container" that is not in any export set.
CMake Error: install(EXPORT "scoped_lockTargets" ...) includes target "boost_thread" which requires target "boost_container_hash" that is not in any export set.
CMake Error: install(EXPORT "scoped_lockTargets" ...) includes target "boost_thread" which requires target "boost_core" that is not in any export set.
CMake Error: install(EXPORT "scoped_lockTargets" ...) includes target "boost_thread" which requires target "boost_date_time" that is not in any export set.
CMake Error: install(EXPORT "scoped_lockTargets" ...) includes target "boost_thread" which requires target "boost_exception" that is not in any export set.
CMake Error: install(EXPORT "scoped_lockTargets" ...) includes target "boost_thread" which requires target "boost_function" that is not in any export set.
CMake Error: install(EXPORT "scoped_lockTargets" ...) includes target "boost_thread" which requires target "boost_io" that is not in any export set.
CMake Error: install(EXPORT "scoped_lockTargets" ...) includes target "boost_thread" which requires target "boost_move" that is not in any export set.
CMake Error: install(EXPORT "scoped_lockTargets" ...) includes target "boost_thread" which requires target "boost_optional" that is not in any export set.
CMake Error: install(EXPORT "scoped_lockTargets" ...) includes target "boost_thread" which requires target "boost_predef" that is not in any export set.
CMake Error: install(EXPORT "scoped_lockTargets" ...) includes target "boost_thread" which requires target "boost_preprocessor" that is not in any export set.
CMake Error: install(EXPORT "scoped_lockTargets" ...) includes target "boost_thread" which requires target "boost_smart_ptr" that is not in any export set.
CMake Error: install(EXPORT "scoped_lockTargets" ...) includes target "boost_thread" which requires target "boost_static_assert" that is not in any export set.
CMake Error: install(EXPORT "scoped_lockTargets" ...) includes target "boost_thread" which requires target "boost_system" that is not in any export set.
CMake Error: install(EXPORT "scoped_lockTargets" ...) includes target "boost_thread" which requires target "boost_throw_exception" that is not in any export set.
CMake Error: install(EXPORT "scoped_lockTargets" ...) includes target "boost_thread" which requires target "boost_tuple" that is not in any export set.
CMake Error: install(EXPORT "scoped_lockTargets" ...) includes target "boost_thread" which requires target "boost_type_traits" that is not in any export set.
CMake Error: install(EXPORT "scoped_lockTargets" ...) includes target "boost_thread" which requires target "boost_utility" that is not in any export set.
CMake Error: install(EXPORT "scoped_lockTargets" ...) includes target "boost_thread" which requires target "boost_winapi" that is not in any export set.
-- Generating done (0.3s)
CMake Generate step failed. Build files cannot be regenerated correctly.
ben.boeckel
(Ben Boeckel (Kitware))
January 2, 2024, 1:51pm
12
Sorry, I’m not that familiar with CPM to answer that; all I know is that file(GET_RUNTIME_DEPENDENCIES)
explicitly excludes build-local files as they are intended to be installed via install()
[1]. Personally I’d prefer find_package
for dependency management given what I see here as it clearly separates your code from external code, but it does mean using a separate dependency management tool. Something like Conan, vcpkg, Anaconda, Spack, custom superbuild, linux distro, HomeBrew, ports, Nix, etc.
[1] The main reason is that CMake’s export logic is going to assume the targets will also be exported.
ClausKlein
(Claus Klein)
January 2, 2024, 3:45pm
13
If I understand right, the cpack
install the dependent runtime libraries found on my build HOST
.
Than I would expect, that DESTDIR=/tmp ninja -C build install
will install them too?
ben.boeckel
(Ben Boeckel (Kitware))
January 2, 2024, 3:54pm
14
I don’t think that is CPack logic, but instead some combination of GetPrerequisites
and BundleUtilities
.
ClausKlein
(Claus Klein)
January 2, 2024, 3:58pm
15
sure, it works fine:
klein_cl@:~/Workspace/cmake/CPM.cmake/examples/boost/build$ cpack
CPack: Create package using TBZ2
CPack: Install projects
CPack: - Install project: CPMExampleBoost []
CPack: Create package
CPack: - package: /home/klein_cl/Workspace/cmake/CPM.cmake/examples/boost/build/CPMExampleBoost-0.1.2-Linux.tar.bz2 generated.
klein_cl@:~/Workspace/cmake/CPM.cmake/examples/boost/build$ cat install_manifest.txt
/home/klein_cl/Workspace/cmake/CPM.cmake/examples/boost/build/_CPack_Packages/Linux/TBZ2/CPMExampleBoost-0.1.2-Linux/bin/CPMExampleBoost
/home/klein_cl/Workspace/cmake/CPM.cmake/examples/boost/build/_CPack_Packages/Linux/TBZ2/CPMExampleBoost-0.1.2-Linux/lib/ld-linux-x86-64.so.2
/home/klein_cl/Workspace/cmake/CPM.cmake/examples/boost/build/_CPack_Packages/Linux/TBZ2/CPMExampleBoost-0.1.2-Linux/lib/libboost_date_time.so.1.74.0
/home/klein_cl/Workspace/cmake/CPM.cmake/examples/boost/build/_CPack_Packages/Linux/TBZ2/CPMExampleBoost-0.1.2-Linux/lib/libboost_filesystem.so.1.74.0
/home/klein_cl/Workspace/cmake/CPM.cmake/examples/boost/build/_CPack_Packages/Linux/TBZ2/CPMExampleBoost-0.1.2-Linux/lib/libc.so.6
/home/klein_cl/Workspace/cmake/CPM.cmake/examples/boost/build/_CPack_Packages/Linux/TBZ2/CPMExampleBoost-0.1.2-Linux/lib/libgcc_s.so.1
/home/klein_cl/Workspace/cmake/CPM.cmake/examples/boost/build/_CPack_Packages/Linux/TBZ2/CPMExampleBoost-0.1.2-Linux/lib/libm.so.6
/home/klein_cl/Workspace/cmake/CPM.cmake/examples/boost/build/_CPack_Packages/Linux/TBZ2/CPMExampleBoost-0.1.2-Linux/lib/libstdc++.so.6
/home/klein_cl/Workspace/cmake/CPM.cmake/examples/boost/build/_CPack_Packages/Linux/TBZ2/CPMExampleBoost-0.1.2-Linux/lib/libstdc++.so.6.0.32
/home/klein_cl/Workspace/cmake/CPM.cmake/examples/boost/build/_CPack_Packages/Linux/TBZ2/CPMExampleBoost-0.1.2-Linux/include/CPMExampleBoost/scoped_lock.hpp
/home/klein_cl/Workspace/cmake/CPM.cmake/examples/boost/build/_CPack_Packages/Linux/TBZ2/CPMExampleBoost-0.1.2-Linux/lib/libscoped_lock.so
/home/klein_cl/Workspace/cmake/CPM.cmake/examples/boost/build/_CPack_Packages/Linux/TBZ2/CPMExampleBoost-0.1.2-Linux/lib/scoped_lock/libscoped_lock.so
/home/klein_cl/Workspace/cmake/CPM.cmake/examples/boost/build/_CPack_Packages/Linux/TBZ2/CPMExampleBoost-0.1.2-Linux/lib/cmake/scoped_lock/scoped_lockTargets.cmake
/home/klein_cl/Workspace/cmake/CPM.cmake/examples/boost/build/_CPack_Packages/Linux/TBZ2/CPMExampleBoost-0.1.2-Linux/lib/cmake/scoped_lock/scoped_lockTargets-release.cmake
/home/klein_cl/Workspace/cmake/CPM.cmake/examples/boost/build/_CPack_Packages/Linux/TBZ2/CPMExampleBoost-0.1.2-Linux/lib/cmake/scoped_lock/scoped_lockConfigVersion.cmake
/home/klein_cl/Workspace/cmake/CPM.cmake/examples/boost/build/_CPack_Packages/Linux/TBZ2/CPMExampleBoost-0.1.2-Linux/lib/cmake/scoped_lock/scoped_lockConfig.cmake
/home/klein_cl/Workspace/cmake/CPM.cmake/examples/boost/build/_CPack_Packages/Linux/TBZ2/CPMExampleBoost-0.1.2-Linux/lib/ld-linux-x86-64.so.2
/home/klein_cl/Workspace/cmake/CPM.cmake/examples/boost/build/_CPack_Packages/Linux/TBZ2/CPMExampleBoost-0.1.2-Linux/lib/libboost_atomic.so.1.74.0
/home/klein_cl/Workspace/cmake/CPM.cmake/examples/boost/build/_CPack_Packages/Linux/TBZ2/CPMExampleBoost-0.1.2-Linux/lib/libboost_thread.so.1.74.0
/home/klein_cl/Workspace/cmake/CPM.cmake/examples/boost/build/_CPack_Packages/Linux/TBZ2/CPMExampleBoost-0.1.2-Linux/lib/libc.so.6
/home/klein_cl/Workspace/cmake/CPM.cmake/examples/boost/build/_CPack_Packages/Linux/TBZ2/CPMExampleBoost-0.1.2-Linux/lib/libgcc_s.so.1
/home/klein_cl/Workspace/cmake/CPM.cmake/examples/boost/build/_CPack_Packages/Linux/TBZ2/CPMExampleBoost-0.1.2-Linux/lib/libm.so.6
/home/klein_cl/Workspace/cmake/CPM.cmake/examples/boost/build/_CPack_Packages/Linux/TBZ2/CPMExampleBoost-0.1.2-Linux/lib/libstdc++.so.6
/home/klein_cl/Workspace/cmake/CPM.cmake/examples/boost/build/_CPack_Packages/Linux/TBZ2/CPMExampleBoost-0.1.2-Linux/lib/libstdc++.so.6.0.32
klein_cl@:~/Workspace/cmake/CPM.cmake/examples/boost/build$
ClausKlein
(Claus Klein)
January 2, 2024, 4:00pm
16
And to a stage dir too:
klein_cl@:~/Workspace/cmake/CPM.cmake/examples/boost$ cmake -G Ninja -B build -S . -DCMAKE_BUILD_TYPE=Release
-- The CXX compiler identification is Clang 15.0.7
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/lib/llvm-15/bin/clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Warning at /home/klein_cl/Workspace/cmake/CPM.cmake/cmake/CPM.cmake:76 (message):
CPM: Your project is using an unstable development version of CPM.cmake.
Please update to a recent release if possible. See
https://github.com/cpm-cmake/CPM.cmake for details.
Call Stack (most recent call first):
CMakeLists.txt:46 (include)
-- CPM: Using local package Boost@1.74.0
-- Found Git: /usr/bin/git (found version "2.34.1")
-- CPM: Adding package PackageProject.cmake@1.11.0 (v1.11.0 at /home/klein_cl/.cache/CPM/packageproject.cmake/fc402989ee6e628476b3d8661f8f96774d89df74)
-- Configuring done (0.6s)
-- Generating done (0.0s)
-- Build files have been written to: /home/klein_cl/Workspace/cmake/CPM.cmake/examples/boost/build
klein_cl@:~/Workspace/cmake/CPM.cmake/examples/boost$ ninja -C build
ninja: Entering directory `build'
[4/4] Linking CXX executable stage/bin/CPMExampleBoost
klein_cl@:~/Workspace/cmake/CPM.cmake/examples/boost$ DESTDIR=/tmp ninja -C build install
ninja: Entering directory `build'
[0/1] Install the project...
-- Install configuration: "Release"
-- Installing: /tmp/usr/local/bin/CPMExampleBoost
-- Set non-toolchain portion of runtime path of "/tmp/usr/local/bin/CPMExampleBoost" to "$ORIGIN:$ORIGIN/../lib"
-- Installing: /tmp/usr/local/lib/ld-linux-x86-64.so.2
-- Installing: /tmp/usr/local/lib/libboost_date_time.so.1.74.0
-- Installing: /tmp/usr/local/lib/libboost_filesystem.so.1.74.0
-- Installing: /tmp/usr/local/lib/libc.so.6
-- Installing: /tmp/usr/local/lib/libgcc_s.so.1
-- Installing: /tmp/usr/local/lib/libm.so.6
-- Installing: /tmp/usr/local/lib/libstdc++.so.6
-- Installing: /tmp/usr/local/lib/libstdc++.so.6.0.32
-- Installing: /tmp/usr/local/include/CPMExampleBoost/scoped_lock.hpp
-- Installing: /tmp/usr/local/lib/libscoped_lock.so
-- Set non-toolchain portion of runtime path of "/tmp/usr/local/lib/libscoped_lock.so" to "$ORIGIN:$ORIGIN/../lib"
-- Installing: /tmp/usr/local/lib/scoped_lock/libscoped_lock.so
-- Set non-toolchain portion of runtime path of "/tmp/usr/local/lib/scoped_lock/libscoped_lock.so" to "$ORIGIN:$ORIGIN/../lib"
-- Installing: /tmp/usr/local/lib/cmake/scoped_lock/scoped_lockTargets.cmake
-- Installing: /tmp/usr/local/lib/cmake/scoped_lock/scoped_lockTargets-release.cmake
-- Installing: /tmp/usr/local/lib/cmake/scoped_lock/scoped_lockConfigVersion.cmake
-- Installing: /tmp/usr/local/lib/cmake/scoped_lock/scoped_lockConfig.cmake
-- Installing: /tmp/usr/local/lib/libboost_atomic.so.1.74.0
-- Installing: /tmp/usr/local/lib/libboost_thread.so.1.74.0
klein_cl@:~/Workspace/cmake/CPM.cmake/examples/boost$ /tmp/usr/local/bin/CPMExampleBoost
Hello, world! ...
Current path is "/home/klein_cl/Workspace/cmake/CPM.cmake/examples/boost"
The TMP path is "/tmp"
... Good by!
klein_cl@:~/Workspace/cmake/CPM.cmake/examples/boost$ ldd /tmp/usr/local/bin/CPMExampleBoost
linux-vdso.so.1 (0x00007ffc119b2000)
libboost_date_time.so.1.74.0 => /tmp/usr/local/bin/../lib/libboost_date_time.so.1.74.0 (0x00007fa3e7018000)
libboost_filesystem.so.1.74.0 => /tmp/usr/local/bin/../lib/libboost_filesystem.so.1.74.0 (0x00007fa3e6ff8000)
libstdc++.so.6 => /tmp/usr/local/bin/../lib/libstdc++.so.6 (0x00007fa3e6d8b000)
libm.so.6 => /tmp/usr/local/bin/../lib/libm.so.6 (0x00007fa3e6ca4000)
libgcc_s.so.1 => /tmp/usr/local/bin/../lib/libgcc_s.so.1 (0x00007fa3e6c80000)
libc.so.6 => /tmp/usr/local/bin/../lib/libc.so.6 (0x00007fa3e6a56000)
/lib64/ld-linux-x86-64.so.2 (0x00007fa3e7038000)
klein_cl@:~/Workspace/cmake/CPM.cmake/examples/boost$
GulgDev
(Gulg)
January 16, 2025, 11:07am
17
Hello! Sorry for reviving an old topic, but I’m having the same issue, could you please provide the code that you used to fix this problem?
ClausKlein
(Claus Klein)
January 16, 2025, 11:28am
18
What exactly do you try or want to use from boost
?
ClausKlein
(Claus Klein)
January 16, 2025, 11:51am
19
A working example with RUNTIME_DEPENDENCY_SET
may be found ClausKlein/docker_build at feature/use-ubuntu-20.04
GulgDev
(Gulg)
January 16, 2025, 12:31pm
20
That worked for me, thank you!
Also, for future viewers of this thread: if it gives you errors on windows, use exclude regexes like this:
install(RUNTIME_DEPENDENCY_SET app_deps
PRE_EXCLUDE_REGEXES
[=[api-ms-]=]
[=[ext-ms-]=]
[[kernel32\.dll]]
[[libc\.so\..*]] [[libgcc_s\.so\..*]] [[libm\.so\..*]] [[libstdc\+\+\.so\..*]]
POST_EXCLUDE_REGEXES
[=[.*system32\/.*\.dll]=]
[=[^\/(lib|usr\/lib|usr\/local\/lib\/lib64)]=]
)