File: dependencies.cmake

package info (click to toggle)
boost1.90 1.90.0-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 593,120 kB
  • sloc: cpp: 4,190,908; xml: 196,648; python: 34,618; ansic: 23,145; asm: 5,468; sh: 3,774; makefile: 1,161; perl: 1,020; sql: 728; ruby: 676; yacc: 478; java: 77; lisp: 24; csh: 6
file content (90 lines) | stat: -rw-r--r-- 3,392 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# Copyright Louis Dionne 2016
# Copyright Zach Laine 2024
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)

###############################################################################
# Boost
###############################################################################
set(Boost_USE_STATIC_LIBS ON)

if (NOT BOOST_BRANCH)
  set(BOOST_BRANCH master)
endif()

add_custom_target(boost_clone_superproject
  DEPENDS
    ${CMAKE_BINARY_DIR}/boost_root/LICENSE_1_0.txt
  COMMENT
    "Cloning Boost superproject."
  VERBATIM)

add_custom_command(
  OUTPUT ${CMAKE_BINARY_DIR}/boost_root/LICENSE_1_0.txt
  COMMAND git clone --depth 100 -b ${BOOST_BRANCH}
    https://github.com/boostorg/boost.git boost_root
  WORKING_DIRECTORY ${CMAKE_BINARY_DIR})

# MSVC determines the compiler and not the target platform
# here we need to check WIN32
if (WIN32)
  set(b2_exe b2.exe)
else()
  set(b2_exe b2)
endif()

add_custom_target(boost_clone_deps
  DEPENDS
    ${CMAKE_BINARY_DIR}/boost_root/${b2_exe}
  COMMENT
    "Cloning Boost dependencies."
  VERBATIM)
add_dependencies(boost_clone_deps boost_clone_superproject)


if (WIN32)
  # Windows:
  # in order to build 'b2_exe' with the same toolset as configured in the current cmake run,
  # we need to tell the boost bootstrap process and pass some parameters
  # - as first parameter msvc, gcc or clang for the compiler type
  # - additionally, for non-MSVC we need to set the environment variable CXX to the compiler: ${CMAKE_CXX_COMPILER} which
  #   is a fully qualified path name, so that the compiler can be found by the bootstrap_cmd
  # calling b2.exe should work also for non-MSVC compilers, as during the build, the runtime directory is part of the search PATH

  if (MSVC OR CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC")
    message(STATUS "configure BOOST for Visual Studio built-in compilers (i.e cl, clang-cl and clang")
    set(bootstrap_cmd ./bootstrap.bat msvc)
    # here we do not need to distinguish the different compilers as only the frontend is different
  elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
    message(STATUS "configure BOOST for Clang compiler")
    set(bootstrap_cmd ./bootstrap.bat clang)
    set(COMMAND_ENV set CXX=${CMAKE_CXX_COMPILER})
  elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
    message(STATUS "configure BOOST for GCC compiler")
    set(bootstrap_cmd ./bootstrap.bat gcc)
    set(COMMAND_ENV set CXX=${CMAKE_CXX_COMPILER})
  endif ()
else()
  # windres produces relocations that are rejected
  # by stricter ld configurations used in some distros
  set(bootstrap_cmd env B2_DONT_EMBED_MANIFEST=true ./bootstrap.sh)
endif()

add_custom_command(
  OUTPUT ${CMAKE_BINARY_DIR}/boost_root/${b2_exe}
  COMMAND git submodule init libs/assert
  COMMAND git submodule init libs/config
  COMMAND git submodule init libs/core
  COMMAND git submodule init libs/hana
  COMMAND git submodule init tools/build
  COMMAND git submodule init libs/headers
  COMMAND git submodule init tools/boost_install
  COMMAND git submodule update --jobs 3 --depth 100
  COMMAND ${COMMAND_ENV}
  COMMAND ${bootstrap_cmd}
  COMMAND ./b2 headers
  WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/boost_root)

add_library(boost INTERFACE)
add_dependencies(boost boost_clone_deps)
target_include_directories(boost INTERFACE ${CMAKE_BINARY_DIR}/boost_root)