├── .gitattributes ├── .github └── workflows │ └── ci.yml ├── .travis.yml ├── README.md ├── appveyor.yml ├── config └── BoostConfig.cmake ├── developer.md ├── include ├── BoostFetch.cmake ├── BoostInstall.cmake ├── BoostMessage.cmake ├── BoostRoot.cmake ├── BoostTest.cmake └── BoostTestJamfile.cmake └── test ├── add_subdir ├── CMakeLists.txt └── main.cpp ├── add_subdir_compat ├── CMakeLists.txt └── main.cpp ├── add_subdir_exc ├── CMakeLists.txt └── main.cpp ├── add_subdir_exc_compat ├── CMakeLists.txt └── main.cpp ├── assert ├── CMakeLists.txt └── main.cpp ├── atomic ├── CMakeLists.txt └── main.cpp ├── bind ├── CMakeLists.txt └── main.cpp ├── boost_fetch ├── CMakeLists.txt └── main.cpp ├── boost_test ├── CMakeLists.txt ├── Jamfile ├── arguments.cpp ├── compile.cpp ├── compile_fail.cpp ├── emits_warning.cpp ├── include_subdir.cpp ├── link.cpp ├── link_fail.cpp ├── requires_no_exceptions.cpp ├── requires_no_rtti.cpp ├── requires_variadic_templates.cpp ├── return_exit_code.cpp ├── run.cpp ├── run_fail.cpp ├── run_multi.cpp ├── run_multi_2.cpp └── subdir │ └── header.hpp ├── endian ├── CMakeLists.txt └── main.cpp ├── iostreams ├── CMakeLists.txt ├── test.txt └── test_fd.cpp ├── locale ├── CMakeLists.txt └── main.cpp ├── mp11 ├── CMakeLists.txt └── main.cpp ├── mysql ├── CMakeLists.txt └── main.cpp ├── preprocessor ├── CMakeLists.txt └── main.cpp ├── system ├── CMakeLists.txt └── main.cpp └── timer ├── CMakeLists.txt └── main.cpp /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto !eol svneol=native#text/plain 2 | *.gitattributes text svneol=native#text/plain 3 | 4 | # Scriptish formats 5 | *.bat text svneol=native#text/plain 6 | *.bsh text svneol=native#text/x-beanshell 7 | *.cgi text svneol=native#text/plain 8 | *.cmd text svneol=native#text/plain 9 | *.js text svneol=native#text/javascript 10 | *.php text svneol=native#text/x-php 11 | *.pl text svneol=native#text/x-perl 12 | *.pm text svneol=native#text/x-perl 13 | *.py text svneol=native#text/x-python 14 | *.sh eol=lf svneol=LF#text/x-sh 15 | configure eol=lf svneol=LF#text/x-sh 16 | 17 | # Image formats 18 | *.bmp binary svneol=unset#image/bmp 19 | *.gif binary svneol=unset#image/gif 20 | *.ico binary svneol=unset#image/ico 21 | *.jpeg binary svneol=unset#image/jpeg 22 | *.jpg binary svneol=unset#image/jpeg 23 | *.png binary svneol=unset#image/png 24 | *.tif binary svneol=unset#image/tiff 25 | *.tiff binary svneol=unset#image/tiff 26 | *.svg text svneol=native#image/svg%2Bxml 27 | 28 | # Data formats 29 | *.pdf binary svneol=unset#application/pdf 30 | *.avi binary svneol=unset#video/avi 31 | *.doc binary svneol=unset#application/msword 32 | *.dsp text svneol=crlf#text/plain 33 | *.dsw text svneol=crlf#text/plain 34 | *.eps binary svneol=unset#application/postscript 35 | *.gz binary svneol=unset#application/gzip 36 | *.mov binary svneol=unset#video/quicktime 37 | *.mp3 binary svneol=unset#audio/mpeg 38 | *.ppt binary svneol=unset#application/vnd.ms-powerpoint 39 | *.ps binary svneol=unset#application/postscript 40 | *.psd binary svneol=unset#application/photoshop 41 | *.rdf binary svneol=unset#text/rdf 42 | *.rss text svneol=unset#text/xml 43 | *.rtf binary svneol=unset#text/rtf 44 | *.sln text svneol=native#text/plain 45 | *.swf binary svneol=unset#application/x-shockwave-flash 46 | *.tgz binary svneol=unset#application/gzip 47 | *.vcproj text svneol=native#text/xml 48 | *.vcxproj text svneol=native#text/xml 49 | *.vsprops text svneol=native#text/xml 50 | *.wav binary svneol=unset#audio/wav 51 | *.xls binary svneol=unset#application/vnd.ms-excel 52 | *.zip binary svneol=unset#application/zip 53 | 54 | # Text formats 55 | .htaccess text svneol=native#text/plain 56 | *.bbk text svneol=native#text/xml 57 | *.cmake text svneol=native#text/plain 58 | *.css text svneol=native#text/css 59 | *.dtd text svneol=native#text/xml 60 | *.htm text svneol=native#text/html 61 | *.html text svneol=native#text/html 62 | *.ini text svneol=native#text/plain 63 | *.log text svneol=native#text/plain 64 | *.mak text svneol=native#text/plain 65 | *.qbk text svneol=native#text/plain 66 | *.rst text svneol=native#text/plain 67 | *.sql text svneol=native#text/x-sql 68 | *.txt text svneol=native#text/plain 69 | *.xhtml text svneol=native#text/xhtml%2Bxml 70 | *.xml text svneol=native#text/xml 71 | *.xsd text svneol=native#text/xml 72 | *.xsl text svneol=native#text/xml 73 | *.xslt text svneol=native#text/xml 74 | *.xul text svneol=native#text/xul 75 | *.yml text svneol=native#text/plain 76 | boost-no-inspect text svneol=native#text/plain 77 | CHANGES text svneol=native#text/plain 78 | COPYING text svneol=native#text/plain 79 | INSTALL text svneol=native#text/plain 80 | Jamfile text svneol=native#text/plain 81 | Jamroot text svneol=native#text/plain 82 | Jamfile.v2 text svneol=native#text/plain 83 | Jamrules text svneol=native#text/plain 84 | Makefile* text svneol=native#text/plain 85 | README text svneol=native#text/plain 86 | TODO text svneol=native#text/plain 87 | 88 | # Code formats 89 | *.c text svneol=native#text/plain 90 | *.cpp text svneol=native#text/plain 91 | *.h text svneol=native#text/plain 92 | *.hpp text svneol=native#text/plain 93 | *.ipp text svneol=native#text/plain 94 | *.tpp text svneol=native#text/plain 95 | *.jam text svneol=native#text/plain 96 | *.java text svneol=native#text/plain 97 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | pull_request: 5 | push: 6 | branches: 7 | - master 8 | - develop 9 | - feature/** 10 | 11 | env: 12 | UBSAN_OPTIONS: print_stacktrace=1 13 | 14 | jobs: 15 | posix: 16 | strategy: 17 | fail-fast: false 18 | matrix: 19 | include: 20 | - os: ubuntu-latest 21 | shared: OFF 22 | layout: tagged 23 | python: ON 24 | mpi: OFF 25 | - os: ubuntu-latest 26 | shared: ON 27 | layout: versioned 28 | python: ON 29 | mpi: OFF 30 | - os: ubuntu-latest 31 | shared: ON 32 | layout: system 33 | python: ON 34 | mpi: ON 35 | install: libopenmpi-dev 36 | - os: macos-latest 37 | shared: OFF 38 | layout: versioned 39 | python: ON 40 | mpi: OFF 41 | - os: macos-latest 42 | shared: ON 43 | layout: tagged 44 | python: ON 45 | mpi: OFF 46 | - os: ubuntu-latest 47 | shared: ON 48 | testing: ON 49 | layout: system 50 | python: OFF 51 | mpi: OFF 52 | exclude: "process;geometry" 53 | - os: ubuntu-latest 54 | include: assert 55 | testing: ON 56 | test_install: ON 57 | - os: macos-latest 58 | include: assert 59 | testing: ON 60 | test_install: ON 61 | - os: ubuntu-latest 62 | include: mp11 63 | testing: ON 64 | test_install: ON 65 | - os: macos-latest 66 | include: mp11 67 | testing: ON 68 | test_install: ON 69 | - os: ubuntu-latest 70 | include: preprocessor 71 | testing: ON 72 | test_install: ON 73 | - os: macos-latest 74 | include: preprocessor 75 | testing: ON 76 | test_install: ON 77 | - os: ubuntu-latest 78 | include: timer 79 | testing: ON 80 | layout: versioned 81 | shared: OFF 82 | test_install: ON 83 | - os: ubuntu-latest 84 | include: timer 85 | testing: ON 86 | layout: versioned 87 | shared: ON 88 | test_install: ON 89 | - os: macos-latest 90 | include: timer 91 | testing: ON 92 | layout: versioned 93 | shared: OFF 94 | test_install: ON 95 | - os: macos-latest 96 | include: timer 97 | testing: ON 98 | layout: versioned 99 | shared: ON 100 | test_install: ON 101 | - os: ubuntu-latest 102 | include: iostreams 103 | layout: versioned 104 | shared: OFF 105 | test_install: ON 106 | - os: ubuntu-latest 107 | include: iostreams 108 | layout: versioned 109 | shared: ON 110 | test_install: ON 111 | - os: macos-latest 112 | include: iostreams 113 | layout: versioned 114 | shared: OFF 115 | test_install: ON 116 | - os: macos-latest 117 | include: iostreams 118 | layout: versioned 119 | shared: ON 120 | test_install: ON 121 | - os: ubuntu-latest 122 | include: locale 123 | layout: versioned 124 | shared: OFF 125 | test_install: ON 126 | - os: ubuntu-latest 127 | include: locale 128 | layout: versioned 129 | shared: ON 130 | test_install: ON 131 | - os: macos-latest 132 | include: locale 133 | layout: versioned 134 | shared: OFF 135 | test_install: ON 136 | - os: macos-latest 137 | include: locale 138 | layout: versioned 139 | shared: ON 140 | test_install: ON 141 | - os: ubuntu-latest 142 | include: mysql 143 | testing: ON 144 | install: libssl-dev 145 | - os: ubuntu-latest 146 | include: mysql 147 | test_install: ON 148 | install: libssl-dev 149 | - os: ubuntu-latest 150 | include: bind 151 | testing: ON 152 | - os: ubuntu-latest 153 | include: bind 154 | test_install: ON 155 | - os: ubuntu-latest 156 | include: endian 157 | testing: ON 158 | - os: ubuntu-latest 159 | include: endian 160 | test_install: ON 161 | - os: ubuntu-latest 162 | include: system 163 | testing: ON 164 | - os: ubuntu-latest 165 | include: system 166 | test_install: ON 167 | 168 | runs-on: ${{matrix.os}} 169 | 170 | steps: 171 | - uses: actions/checkout@v4 172 | 173 | - name: Install packages 174 | if: matrix.install 175 | run: sudo apt install ${{matrix.install}} 176 | 177 | - name: Setup Boost 178 | run: | 179 | echo GITHUB_BASE_REF: $GITHUB_BASE_REF 180 | echo GITHUB_REF: $GITHUB_REF 181 | REF=${GITHUB_BASE_REF:-$GITHUB_REF} 182 | REF=${REF#refs/heads/} 183 | echo REF: $REF 184 | BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true 185 | echo BOOST_BRANCH: $BOOST_BRANCH 186 | cd .. 187 | git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root 188 | cd boost-root 189 | git submodule update --init --jobs 3 190 | rm -rf tools/cmake/* 191 | cp -r $GITHUB_WORKSPACE/* tools/cmake 192 | 193 | - name: Configure Boost 194 | run: | 195 | cd ../boost-root 196 | mkdir __build__ && cd __build__ 197 | cmake -DCMAKE_INSTALL_PREFIX=~/.local -DBoost_VERBOSE=${{matrix.verbose}} -DBUILD_TESTING=${{matrix.testing}} -DBOOST_INCLUDE_LIBRARIES="${{matrix.include}}" -DBOOST_EXCLUDE_LIBRARIES="${{matrix.exclude}}" -DBUILD_SHARED_LIBS=${{matrix.shared}} -DBOOST_INSTALL_LAYOUT=${{matrix.layout}} -DBOOST_ENABLE_MPI=${{matrix.mpi}} -DBOOST_ENABLE_PYTHON=${{matrix.python}} .. 198 | 199 | - name: Build Boost 200 | run: | 201 | cd ../boost-root/__build__ 202 | cmake --build . 203 | 204 | - name: Install Boost 205 | run: | 206 | cd ../boost-root/__build__ 207 | cmake --build . --target install 208 | 209 | - name: Test Boost 210 | if: matrix.testing 211 | run: | 212 | cd ../boost-root/__build__ 213 | cmake --build . --target tests -- -j 3 214 | ctest --output-on-failure --no-tests=error -j 3 215 | 216 | - name: Test installed Boost library 217 | if: matrix.test_install 218 | run: | 219 | cd ../boost-root/tools/cmake/test/${{matrix.include}} 220 | mkdir __build__ && cd __build__ 221 | cmake -DCMAKE_INSTALL_PREFIX=~/.local .. 222 | cmake --build . 223 | export LD_LIBRARY_PATH=$HOME/.local/lib:$LD_LIBRARY_PATH 224 | cmake --build . --target check 225 | 226 | windows: 227 | strategy: 228 | fail-fast: false 229 | matrix: 230 | include: 231 | - os: windows-2022 232 | shared: OFF 233 | python: ON 234 | mpi: OFF 235 | - os: windows-2022 236 | shared: ON 237 | python: ON 238 | mpi: OFF 239 | - os: windows-2022 240 | include: assert 241 | testing: ON 242 | test_install: ON 243 | - os: windows-2022 244 | include: mp11 245 | testing: ON 246 | test_install: ON 247 | - os: windows-2022 248 | include: timer 249 | shared: OFF 250 | testing: ON 251 | test_install: ON 252 | - os: windows-2022 253 | include: timer 254 | shared: ON 255 | testing: ON 256 | test_install: ON 257 | - os: windows-2022 258 | include: iostreams 259 | shared: OFF 260 | test_install: ON 261 | - os: windows-2022 262 | include: iostreams 263 | shared: ON 264 | test_install: ON 265 | - os: windows-2022 266 | include: bind 267 | testing: ON 268 | - os: windows-2022 269 | include: bind 270 | test_install: ON 271 | - os: windows-2022 272 | include: endian 273 | testing: ON 274 | - os: windows-2022 275 | include: endian 276 | test_install: ON 277 | - os: windows-2022 278 | include: system 279 | testing: ON 280 | - os: windows-2022 281 | include: system 282 | test_install: ON 283 | 284 | # mingw 285 | 286 | - os: windows-latest 287 | include: timer 288 | shared: OFF 289 | testing: ON 290 | test_install: ON 291 | opts: "-G \"MinGW Makefiles\"" 292 | - os: windows-latest 293 | include: timer 294 | shared: ON 295 | testing: ON 296 | test_install: ON 297 | opts: "-G \"MinGW Makefiles\"" 298 | 299 | # clang-cl 300 | 301 | - os: windows-latest 302 | include: timer 303 | shared: OFF 304 | testing: ON 305 | test_install: ON 306 | opts: "-T clangcl" 307 | - os: windows-latest 308 | include: timer 309 | shared: ON 310 | testing: ON 311 | test_install: ON 312 | opts: "-T clangcl" 313 | 314 | runs-on: ${{matrix.os}} 315 | 316 | defaults: 317 | run: 318 | shell: cmd 319 | 320 | steps: 321 | - uses: actions/checkout@v4 322 | 323 | - name: Setup Boost 324 | run: | 325 | echo GITHUB_BASE_REF: %GITHUB_BASE_REF% 326 | echo GITHUB_REF: %GITHUB_REF% 327 | if "%GITHUB_BASE_REF%" == "" set GITHUB_BASE_REF=%GITHUB_REF% 328 | set BOOST_BRANCH=develop 329 | for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master 330 | echo BOOST_BRANCH: %BOOST_BRANCH% 331 | cd .. 332 | git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root 333 | cd boost-root 334 | git submodule update --init --jobs 3 335 | rd /s/q tools\cmake 336 | xcopy /s /e /q %GITHUB_WORKSPACE% tools\cmake\ 337 | 338 | - name: Configure Boost 339 | run: | 340 | cd ../boost-root 341 | mkdir __build__ && cd __build__ 342 | cmake -DBoost_VERBOSE=${{matrix.verbose}} -DBUILD_TESTING=${{matrix.testing}} -DBOOST_INCLUDE_LIBRARIES=${{matrix.include}} -DBOOST_EXCLUDE_LIBRARIES=${{matrix.exclude}} -DBUILD_SHARED_LIBS=${{matrix.shared}} -DBOOST_ENABLE_MPI=${{matrix.mpi}} -DBOOST_ENABLE_PYTHON=${{matrix.python}} -DCMAKE_IGNORE_PREFIX_PATH="C:/Strawberry/c" ${{matrix.opts}} .. 343 | 344 | - name: Build Boost (Debug) 345 | run: cmake --build ../boost-root/__build__ --config Debug 346 | 347 | - name: Build Boost (Release) 348 | run: cmake --build ../boost-root/__build__ --config Release 349 | 350 | - name: Install Boost (Debug) 351 | run: cmake --build ../boost-root/__build__ --target install --config Debug 352 | 353 | - name: Install Boost (Release) 354 | run: cmake --build ../boost-root/__build__ --target install --config Release 355 | 356 | - name: Test Boost (Debug) 357 | if: matrix.testing 358 | run: cd ../boost-root/__build__ && cmake --build . --target tests --config Debug && ctest --output-on-failure --no-tests=error -j 3 -C Debug 359 | 360 | - name: Test Boost (Release) 361 | if: matrix.testing 362 | run: cd ../boost-root/__build__ && cmake --build . --target tests --config Release && ctest --output-on-failure --no-tests=error -j 3 -C Release 363 | 364 | - name: Configure test project 365 | if: matrix.test_install 366 | run: | 367 | cd ../boost-root/tools/cmake/test/${{matrix.include}} 368 | mkdir __build__ && cd __build__ 369 | cmake -DCMAKE_PREFIX_PATH=C:/Boost ${{matrix.opts}} .. 370 | 371 | - name: Test installed Boost library (Debug) 372 | if: matrix.test_install 373 | run: | 374 | cd ../boost-root/tools/cmake/test/${{matrix.include}}/__build__ 375 | PATH C:\Boost\bin;%PATH% 376 | cmake --build . --config Debug && ctest --output-on-failure --no-tests=error -j 3 -C Debug 377 | 378 | - name: Test installed Boost library (Release) 379 | if: matrix.test_install 380 | run: | 381 | cd ../boost-root/tools/cmake/test/${{matrix.include}}/__build__ 382 | PATH C:\Boost\bin;%PATH% 383 | cmake --build . --config Release && ctest --output-on-failure --no-tests=error -j 3 -C Release 384 | 385 | BoostRoot: 386 | strategy: 387 | matrix: 388 | enable_test: [ON, OFF] 389 | cmake_version: [default, 3.8.0, 3.9.0, 3.10.0, 3.11.0, 3.12.0, 3.13.0, 3.14.0, 3.16.0, 3.19.0, 3.31.0, 4.0.0, 4.1.0] 390 | exclude: 391 | # BoostTestJamfile requires CMake 3.9 392 | - cmake_version: 3.8.0 393 | enable_test: ON 394 | fail-fast: false 395 | 396 | runs-on: ubuntu-latest 397 | 398 | steps: 399 | - uses: actions/checkout@v4 400 | - name: Setup Boost 401 | run: | 402 | REF=${GITHUB_BASE_REF:-$GITHUB_REF} 403 | REF=${REF#refs/heads/} 404 | echo REF: $REF 405 | BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true 406 | echo BOOST_BRANCH: $BOOST_BRANCH 407 | cd .. 408 | git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root 409 | cd boost-root 410 | git submodule update --init --jobs 3 411 | rm -rf tools/cmake/* 412 | cp -r $GITHUB_WORKSPACE/* tools/cmake 413 | - name: Configure each library independently 414 | working-directory: ../boost-root 415 | if: matrix.cmake_version == 'default' 416 | run: | 417 | failed_libs="" 418 | failed_outputs=() 419 | for cml in libs/*/CMakeLists.txt; do 420 | lib=$(dirname "${cml#*libs/}") 421 | echo "=====================================================================" 422 | echo "Building $lib" 423 | echo "=====================================================================" 424 | error=0 425 | out=$(cmake -DBUILD_TESTING=${{matrix.enable_test}} -DBOOST_INCLUDE_LIBRARIES=$lib -DBoost_DEBUG=ON -B "__build_$lib" . 2>&1) || error=1 426 | echo "$out" 427 | echo; echo; echo 428 | [[ "$out" != *"BOOST_INCLUDE_LIBRARIES has not been found"* ]] || error=1 429 | [[ "$out" != *"CMake Error"* ]] || error=1 430 | if ((error==1)); then 431 | failed_libs+=" $lib" 432 | failed_outputs+=( 433 | "=====================================================================" 434 | "Output of $lib" 435 | "$out" 436 | ) 437 | fi 438 | done 439 | if [[ -n $failed_libs ]]; then 440 | echo "Failed libraries: $failed_libs" 441 | printf '%s\n' "${failed_outputs[@]}" 442 | exit 1 443 | fi 444 | 445 | - name: Cache CMake 446 | if: matrix.cmake_version != 'default' 447 | id: cache-cmake 448 | uses: actions/cache@v4 449 | with: 450 | path: /tmp/cmake 451 | key: ${{ runner.os }}-cmake-${{matrix.cmake_version}} 452 | 453 | - name: Install CMake dependencies 454 | if: matrix.cmake_version != 'default' 455 | run: sudo apt-get -o Acquire::Retries=3 -y -q --no-install-suggests --no-install-recommends install curl libcurl4-openssl-dev libarchive-dev 456 | 457 | - name: Build CMake 458 | if: matrix.cmake_version != 'default' && steps.cache-cmake.outputs.cache-hit != 'true' 459 | run: | 460 | version=${{matrix.cmake_version}} 461 | filename="cmake-$version.tar.gz" 462 | cd "$(mktemp -d)" 463 | wget https://cmake.org/files/v${version%.*}/$filename 464 | tar -xf $filename --strip-components=1 465 | flags=( 466 | "-DCMAKE_BUILD_TYPE=Release" 467 | "-DCMAKE_INSTALL_PREFIX=/tmp/cmake" 468 | "-B" "__build" 469 | "-Wno-dev" # Make configuring more silent 470 | "-DCMAKE_USE_SYSTEM_CURL=1" # Avoid failures caused by newer (system) OpenSSL in CMake < 3.10 471 | "-DCMAKE_CXX_FLAGS='-include cstdint -include limits'" # Fix missing includes in CMake < 3.10 472 | ) 473 | cmake "${flags[@]}" . 474 | cmake --build __build -- -j 3 475 | cmake --build __build --target install 476 | 477 | - name: Configure Boost with CMake ${{matrix.cmake_version}} 478 | working-directory: ../boost-root 479 | if: matrix.cmake_version != 'default' 480 | run: | 481 | version_greater_equal() { printf '%s\n' "$2" "$1" | sort --check=quiet --version-sort; } 482 | excluded=() 483 | for cml in "$PWD"/libs/*/CMakeLists.txt "$PWD"/libs/numeric/*/CMakeLists.txt; do 484 | lib=$(dirname "${cml#*libs/}") 485 | if minimal_cmake_version=$(grep "cmake_minimum_required" "$cml" | grep -Eo '[0-9]\.[0-9]+' | head -1); then 486 | version_greater_equal ${{matrix.cmake_version}} "$minimal_cmake_version" || excluded+=("$lib") 487 | else 488 | echo "Minimum required CMake version not found in $cml for library $lib" 489 | fi 490 | done 491 | # Libraries that don't declare their correct minimal required CMake version or where dependencies require higher version 492 | version_greater_equal ${{matrix.cmake_version}} 3.12.0 || excluded+=("msm") 493 | version_greater_equal ${{matrix.cmake_version}} 3.14.0 || excluded+=("pfr" "mysql") # mysql depends on pfr 494 | /tmp/cmake/bin/cmake --version 495 | /tmp/cmake/bin/cmake -DBUILD_TESTING=${{matrix.enable_test}} -DBOOST_EXCLUDE_LIBRARIES="$(IFS=';'; echo "${excluded[*]}")" -B "__build_cmake-$version" . 496 | 497 | BoostTest: 498 | strategy: 499 | fail-fast: false 500 | 501 | runs-on: ubuntu-latest 502 | 503 | steps: 504 | - uses: actions/checkout@v4 505 | 506 | - name: Setup Boost 507 | run: | 508 | echo GITHUB_BASE_REF: $GITHUB_BASE_REF 509 | echo GITHUB_REF: $GITHUB_REF 510 | REF=${GITHUB_BASE_REF:-$GITHUB_REF} 511 | REF=${REF#refs/heads/} 512 | echo REF: $REF 513 | BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true 514 | echo BOOST_BRANCH: $BOOST_BRANCH 515 | cd .. 516 | git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root 517 | cd boost-root 518 | git submodule update --init --jobs 3 libs/core libs/assert libs/config libs/static_assert libs/throw_exception 519 | rm -rf tools/cmake/* 520 | cp -r $GITHUB_WORKSPACE/* tools/cmake 521 | 522 | - name: Test BoostTest 523 | run: | 524 | cd ../boost-root/tools/cmake/test/boost_test 525 | mkdir __build__ && cd __build__ 526 | cmake -DBoost_VERBOSE=ON .. 527 | cmake --build . --target tests -j 3 528 | ctest --output-on-failure --no-tests=error -j 3 529 | 530 | BoostFetch: 531 | strategy: 532 | fail-fast: false 533 | 534 | runs-on: ubuntu-latest 535 | 536 | steps: 537 | - uses: actions/checkout@v4 538 | 539 | - name: Test BoostFetch 540 | run: | 541 | cd test/boost_fetch 542 | mkdir __build__ && cd __build__ 543 | cmake .. 544 | cmake --build . 545 | cmake --build . --target check 546 | 547 | posix-subdir: 548 | strategy: 549 | fail-fast: false 550 | matrix: 551 | os: [ ubuntu-22.04, ubuntu-24.04, macos-13, macos-14, macos-15 ] 552 | shared: [ ON, OFF ] 553 | 554 | runs-on: ${{matrix.os}} 555 | 556 | steps: 557 | - uses: actions/checkout@v4 558 | 559 | - name: Install packages 560 | if: matrix.install 561 | run: sudo apt install ${{matrix.install}} 562 | 563 | - name: Setup Boost 564 | run: | 565 | echo GITHUB_BASE_REF: $GITHUB_BASE_REF 566 | echo GITHUB_REF: $GITHUB_REF 567 | REF=${GITHUB_BASE_REF:-$GITHUB_REF} 568 | REF=${REF#refs/heads/} 569 | echo REF: $REF 570 | BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true 571 | echo BOOST_BRANCH: $BOOST_BRANCH 572 | cd .. 573 | git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root 574 | cd boost-root 575 | git submodule update --init --jobs 3 576 | rm -rf tools/cmake/* 577 | cp -r $GITHUB_WORKSPACE/* tools/cmake 578 | 579 | - name: Test Boost with add_subdirectory 580 | run: | 581 | cd ../boost-root/tools/cmake/test/add_subdir 582 | mkdir __build__ && cd __build__ 583 | cmake -DBoost_VERBOSE=ON -DBUILD_SHARED_LIBS=${{matrix.shared}} .. 584 | cmake --build . 585 | ctest --output-on-failure --no-tests=error 586 | 587 | - name: Test Boost with add_subdirectory(EXCLUDE_FROM_ALL) 588 | run: | 589 | cd ../boost-root/tools/cmake/test/add_subdir_exc 590 | mkdir __build__ && cd __build__ 591 | cmake -DBoost_VERBOSE=ON -DBUILD_SHARED_LIBS=${{matrix.shared}} .. 592 | cmake --build . 593 | ctest --output-on-failure --no-tests=error 594 | 595 | - name: Test installation with add_subdirectory 596 | run: | 597 | cd ../boost-root/tools/cmake/test/add_subdir 598 | mkdir __build2__ && cd __build2__ 599 | cmake -DCMAKE_INSTALL_PREFIX=~/.local -DBoost_VERBOSE=ON -DBUILD_SHARED_LIBS=${{matrix.shared}} .. 600 | cmake --build . --target install 601 | cmake --install . 602 | 603 | - name: Test installation with add_subdirectory(EXCLUDE_FROM_ALL) 604 | run: | 605 | cd ../boost-root/tools/cmake/test/add_subdir_exc 606 | mkdir __build2__ && cd __build2__ 607 | cmake -DCMAKE_INSTALL_PREFIX=~/.local -DBoost_VERBOSE=ON -DBUILD_SHARED_LIBS=${{matrix.shared}} .. 608 | cmake --build . --target install 609 | cmake --install . 610 | 611 | - name: Test add_subdirectory compatibility targets 612 | run: | 613 | cd ../boost-root/tools/cmake/test/add_subdir_compat 614 | mkdir __build__ && cd __build__ 615 | cmake -DBoost_VERBOSE=ON -DBUILD_SHARED_LIBS=${{matrix.shared}} .. 616 | cmake --build . 617 | ctest --output-on-failure --no-tests=error 618 | 619 | - name: Test add_subdirectory(EXCLUDE_FROM_ALL) compatibility targets 620 | run: | 621 | cd ../boost-root/tools/cmake/test/add_subdir_exc_compat 622 | mkdir __build__ && cd __build__ 623 | cmake -DBoost_VERBOSE=ON -DBUILD_SHARED_LIBS=${{matrix.shared}} .. 624 | cmake --build . 625 | ctest --output-on-failure --no-tests=error 626 | 627 | posix-target-check: 628 | strategy: 629 | fail-fast: false 630 | matrix: 631 | include: 632 | - os: ubuntu-22.04 633 | include: timer 634 | shared: ON 635 | - os: ubuntu-24.04 636 | include: timer 637 | shared: ON 638 | - os: macos-13 639 | include: timer 640 | shared: ON 641 | - os: macos-14 642 | include: timer 643 | shared: ON 644 | - os: macos-15 645 | include: timer 646 | shared: ON 647 | 648 | runs-on: ${{matrix.os}} 649 | 650 | steps: 651 | - uses: actions/checkout@v4 652 | 653 | - name: Install packages 654 | if: matrix.install 655 | run: sudo apt install ${{matrix.install}} 656 | 657 | - name: Setup Boost 658 | run: | 659 | echo GITHUB_BASE_REF: $GITHUB_BASE_REF 660 | echo GITHUB_REF: $GITHUB_REF 661 | REF=${GITHUB_BASE_REF:-$GITHUB_REF} 662 | REF=${REF#refs/heads/} 663 | echo REF: $REF 664 | BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true 665 | echo BOOST_BRANCH: $BOOST_BRANCH 666 | cd .. 667 | git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root 668 | cd boost-root 669 | git submodule update --init --jobs 3 670 | rm -rf tools/cmake/* 671 | cp -r $GITHUB_WORKSPACE/* tools/cmake 672 | 673 | - name: Configure Boost 674 | run: | 675 | cd ../boost-root 676 | mkdir __build__ && cd __build__ 677 | cmake -DBoost_VERBOSE=${{matrix.verbose}} -DBUILD_TESTING=ON -DBOOST_INCLUDE_LIBRARIES=${{matrix.include}} -DBUILD_SHARED_LIBS=${{matrix.shared}} .. 678 | 679 | - name: Test Boost 680 | run: | 681 | cd ../boost-root/__build__ 682 | cmake --build . --target check 683 | 684 | posix-check-quick: 685 | strategy: 686 | fail-fast: false 687 | matrix: 688 | os: [ ubuntu-22.04, ubuntu-24.04, macos-13, macos-14, macos-15 ] 689 | shared: [ ON, OFF ] 690 | 691 | runs-on: ${{matrix.os}} 692 | 693 | steps: 694 | - uses: actions/checkout@v4 695 | 696 | - name: Install packages 697 | if: matrix.install 698 | run: sudo apt install ${{matrix.install}} 699 | 700 | - name: Setup Boost 701 | run: | 702 | echo GITHUB_BASE_REF: $GITHUB_BASE_REF 703 | echo GITHUB_REF: $GITHUB_REF 704 | REF=${GITHUB_BASE_REF:-$GITHUB_REF} 705 | REF=${REF#refs/heads/} 706 | echo REF: $REF 707 | BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true 708 | echo BOOST_BRANCH: $BOOST_BRANCH 709 | cd .. 710 | git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root 711 | cd boost-root 712 | git submodule update --init --jobs 3 713 | rm -rf tools/cmake/* 714 | cp -r $GITHUB_WORKSPACE/* tools/cmake 715 | 716 | - name: Configure Boost 717 | run: | 718 | cd ../boost-root 719 | mkdir __build__ && cd __build__ 720 | cmake -DBoost_VERBOSE=${{matrix.verbose}} -DBUILD_TESTING=ON -DBUILD_SHARED_LIBS=${{matrix.shared}} .. 721 | 722 | - name: Test Boost 723 | run: | 724 | cd ../boost-root/__build__ 725 | cmake --build . --target check-quick 726 | 727 | posix-install: 728 | strategy: 729 | fail-fast: false 730 | matrix: 731 | os: [ ubuntu-latest, macos-latest ] 732 | include_libraries: [ timer ] 733 | layout: [ system, versioned ] 734 | verbose: [ ON ] 735 | 736 | runs-on: ${{matrix.os}} 737 | 738 | steps: 739 | - uses: actions/checkout@v4 740 | 741 | - name: Setup Boost 742 | run: | 743 | echo GITHUB_BASE_REF: $GITHUB_BASE_REF 744 | echo GITHUB_REF: $GITHUB_REF 745 | REF=${GITHUB_BASE_REF:-$GITHUB_REF} 746 | REF=${REF#refs/heads/} 747 | echo REF: $REF 748 | BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true 749 | echo BOOST_BRANCH: $BOOST_BRANCH 750 | cd .. 751 | git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root 752 | cd boost-root 753 | git submodule update --init --jobs 3 754 | rm -rf tools/cmake/* 755 | cp -r $GITHUB_WORKSPACE/* tools/cmake 756 | 757 | - name: Configure (Static) 758 | run: | 759 | cd ../boost-root 760 | mkdir __build_static__ && cd __build_static__ 761 | cmake -DCMAKE_INSTALL_PREFIX=~/.local -DBoost_VERBOSE=${{matrix.verbose}} -DBOOST_INCLUDE_LIBRARIES="${{matrix.include_libraries}}" -DBOOST_EXCLUDE_LIBRARIES="${{matrix.exclude_libraries}}" -DBUILD_SHARED_LIBS=OFF -DBOOST_INSTALL_LAYOUT=${{matrix.layout}} .. 762 | 763 | - name: Build (Static) 764 | run: | 765 | cd ../boost-root/__build_static__ 766 | cmake --build . 767 | 768 | - name: Install (Static) 769 | run: | 770 | cd ../boost-root/__build_static__ 771 | cmake --build . --target install 772 | 773 | - name: Configure (Shared) 774 | run: | 775 | cd ../boost-root 776 | mkdir __build_shared__ && cd __build_shared__ 777 | cmake -DCMAKE_INSTALL_PREFIX=~/.local -DBoost_VERBOSE=${{matrix.verbose}} -DBOOST_INCLUDE_LIBRARIES="${{matrix.include_libraries}}" -DBOOST_EXCLUDE_LIBRARIES="${{matrix.exclude_libraries}}" -DBUILD_SHARED_LIBS=ON -DBOOST_INSTALL_LAYOUT=${{matrix.layout}} .. 778 | 779 | - name: Build (Shared) 780 | run: | 781 | cd ../boost-root/__build_shared__ 782 | cmake --build . 783 | 784 | - name: Install (Shared) 785 | run: | 786 | cd ../boost-root/__build_shared__ 787 | cmake --build . --target install 788 | 789 | - name: Test (Static) 790 | run: | 791 | cd ../boost-root/tools/cmake/test/${{matrix.include_libraries}} 792 | mkdir __build_static__ && cd __build_static__ 793 | cmake -DCMAKE_INSTALL_PREFIX=~/.local -DBoost_VERBOSE=${{matrix.verbose}} -DBoost_USE_STATIC_LIBS=ON .. 794 | cmake --build . 795 | export LD_LIBRARY_PATH=$HOME/.local/lib:$LD_LIBRARY_PATH 796 | cmake --build . --target check 797 | 798 | - name: Test (Shared) 799 | run: | 800 | cd ../boost-root/tools/cmake/test/${{matrix.include_libraries}} 801 | mkdir __build_shared__ && cd __build_shared__ 802 | cmake -DCMAKE_INSTALL_PREFIX=~/.local -DBoost_VERBOSE=${{matrix.verbose}} -DBoost_USE_STATIC_LIBS=OFF .. 803 | cmake --build . 804 | export LD_LIBRARY_PATH=$HOME/.local/lib:$LD_LIBRARY_PATH 805 | cmake --build . --target check 806 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2016-2021 Peter Dimov 2 | # Distributed under the Boost Software License, Version 1.0. 3 | # (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt) 4 | 5 | language: cpp 6 | 7 | sudo: false 8 | 9 | dist: xenial 10 | 11 | branches: 12 | only: 13 | - master 14 | - develop 15 | - /feature\/.*/ 16 | 17 | env: 18 | matrix: 19 | - BOGUS_JOB=true 20 | 21 | matrix: 22 | exclude: 23 | - env: BOGUS_JOB=true 24 | 25 | include: 26 | 27 | - env: LIB=assert 28 | dist: trusty 29 | compiler: g++ 30 | 31 | - env: LIB=assert 32 | dist: trusty 33 | compiler: clang++ 34 | 35 | - env: LIB=assert 36 | dist: xenial 37 | compiler: g++ 38 | 39 | - env: LIB=assert 40 | dist: xenial 41 | compiler: clang++ 42 | 43 | - env: LIB=assert 44 | dist: bionic 45 | compiler: g++ 46 | 47 | - env: LIB=assert 48 | dist: bionic 49 | compiler: clang++ 50 | 51 | - env: LIB=assert 52 | dist: focal 53 | compiler: g++ 54 | 55 | - env: LIB=assert 56 | dist: focal 57 | compiler: clang++ 58 | 59 | - env: LIB=assert 60 | os: osx 61 | 62 | - env: LIB=mp11 63 | compiler: g++ 64 | 65 | - env: LIB=mp11 66 | compiler: clang++ 67 | 68 | - env: LIB=mp11 69 | os: osx 70 | 71 | - env: LIB=timer 72 | compiler: g++ 73 | 74 | - env: LIB=timer BUILD_SHARED_LIBS=ON 75 | compiler: g++ 76 | 77 | - env: LIB=timer 78 | compiler: clang++ 79 | 80 | - env: LIB=timer BUILD_SHARED_LIBS=ON 81 | compiler: clang++ 82 | 83 | - env: LIB=timer 84 | os: osx 85 | 86 | - env: LIB=timer BUILD_SHARED_LIBS=ON 87 | os: osx 88 | 89 | - env: TEST_BOOST_TEST=1 LIB=core 90 | script: 91 | - cd tools/cmake/test/boost_test 92 | - mkdir __build__ && cd __build__ 93 | - cmake -DBoost_VERBOSE=ON .. 94 | - cmake --build . -j 3 --target tests 95 | - ctest --output-on-failure -j 3 96 | 97 | - env: TEST_BOOST_FETCH=1 98 | install: true 99 | script: 100 | - cd test/boost_fetch 101 | - mkdir __build__ && cd __build__ 102 | - cmake .. 103 | - cmake --build . 104 | - cmake --build . --target check 105 | 106 | - env: TEST_BOOST_INSTALL=1 LIB=mp11 107 | script: 108 | - mkdir __build__ && cd __build__ 109 | - cmake -DCMAKE_INSTALL_PREFIX=~/.local -DBOOST_ENABLE_CMAKE=1 -DBoost_VERBOSE=ON -DBOOST_INCLUDE_LIBRARIES=${BOOST_INCLUDE_LIBRARIES:-$LIB} ${BOOST_INSTALL_LAYOUT:+-DBOOST_INSTALL_LAYOUT=$BOOST_INSTALL_LAYOUT} ${BUILD_SHARED_LIBS:+-DBUILD_SHARED_LIBS=$BUILD_SHARED_LIBS} .. 110 | - cmake --build . --target install 111 | - cd ../tools/cmake/test/$LIB && mkdir __build__ && cd __build__ 112 | - cmake -DCMAKE_INSTALL_PREFIX=~/.local .. 113 | - cmake --build . 114 | - cmake --build . --target check 115 | 116 | - env: TEST_BOOST_INSTALL=1 LIB=assert 117 | script: 118 | - pip install --user cmake 119 | - mkdir __build__ && cd __build__ 120 | - cmake -DCMAKE_INSTALL_PREFIX=~/.local -DBOOST_ENABLE_CMAKE=1 -DBoost_VERBOSE=ON -DBOOST_INCLUDE_LIBRARIES=${BOOST_INCLUDE_LIBRARIES:-$LIB} ${BOOST_INSTALL_LAYOUT:+-DBOOST_INSTALL_LAYOUT=$BOOST_INSTALL_LAYOUT} ${BUILD_SHARED_LIBS:+-DBUILD_SHARED_LIBS=$BUILD_SHARED_LIBS} .. 121 | - cmake --build . --target install 122 | - cd ../tools/cmake/test/$LIB && mkdir __build__ && cd __build__ 123 | - cmake -DCMAKE_INSTALL_PREFIX=~/.local .. 124 | - cmake --build . 125 | - cmake --build . --target check 126 | 127 | - env: TEST_BOOST_INSTALL=1 LIB=assert BOOST_INSTALL_LAYOUT=tagged 128 | script: 129 | - pip install --user cmake 130 | - mkdir __build__ && cd __build__ 131 | - cmake -DCMAKE_INSTALL_PREFIX=~/.local -DBOOST_ENABLE_CMAKE=1 -DBoost_VERBOSE=ON -DBOOST_INCLUDE_LIBRARIES=${BOOST_INCLUDE_LIBRARIES:-$LIB} ${BOOST_INSTALL_LAYOUT:+-DBOOST_INSTALL_LAYOUT=$BOOST_INSTALL_LAYOUT} ${BUILD_SHARED_LIBS:+-DBUILD_SHARED_LIBS=$BUILD_SHARED_LIBS} .. 132 | - cmake --build . --target install 133 | - cd ../tools/cmake/test/$LIB && mkdir __build__ && cd __build__ 134 | - cmake -DCMAKE_INSTALL_PREFIX=~/.local .. 135 | - cmake --build . 136 | - cmake --build . --target check 137 | 138 | - env: TEST_BOOST_INSTALL=1 LIB=assert BOOST_INSTALL_LAYOUT=versioned 139 | script: 140 | - pip install --user cmake 141 | - mkdir __build__ && cd __build__ 142 | - cmake -DCMAKE_INSTALL_PREFIX=~/.local -DBOOST_ENABLE_CMAKE=1 -DBoost_VERBOSE=ON -DBOOST_INCLUDE_LIBRARIES=${BOOST_INCLUDE_LIBRARIES:-$LIB} ${BOOST_INSTALL_LAYOUT:+-DBOOST_INSTALL_LAYOUT=$BOOST_INSTALL_LAYOUT} ${BUILD_SHARED_LIBS:+-DBUILD_SHARED_LIBS=$BUILD_SHARED_LIBS} .. 143 | - cmake --build . --target install 144 | - cd ../tools/cmake/test/$LIB && mkdir __build__ && cd __build__ 145 | - cmake -DCMAKE_INSTALL_PREFIX=~/.local .. 146 | - cmake --build . 147 | - cmake --build . --target check 148 | 149 | - env: TEST_BOOST_INSTALL=1 LIB=atomic 150 | script: 151 | - pip install --user cmake 152 | - mkdir __build__ && cd __build__ 153 | - cmake -DCMAKE_INSTALL_PREFIX=~/.local -DBOOST_ENABLE_CMAKE=1 -DBoost_VERBOSE=ON -DBOOST_INCLUDE_LIBRARIES=${BOOST_INCLUDE_LIBRARIES:-$LIB} ${BOOST_INSTALL_LAYOUT:+-DBOOST_INSTALL_LAYOUT=$BOOST_INSTALL_LAYOUT} ${BUILD_SHARED_LIBS:+-DBUILD_SHARED_LIBS=$BUILD_SHARED_LIBS} .. 154 | - cmake --build . --target install 155 | - cd ../tools/cmake/test/$LIB && mkdir __build__ && cd __build__ 156 | - cmake -DCMAKE_INSTALL_PREFIX=~/.local .. 157 | - cmake --build . 158 | - cmake --build . --target check 159 | 160 | - env: TEST_BOOST_INSTALL=1 LIB=atomic BOOST_INSTALL_LAYOUT=tagged BUILD_SHARED_LIBS=ON 161 | script: 162 | - pip install --user cmake 163 | - mkdir __build__ && cd __build__ 164 | - cmake -DCMAKE_INSTALL_PREFIX=~/.local -DBOOST_ENABLE_CMAKE=1 -DBoost_VERBOSE=ON -DBOOST_INCLUDE_LIBRARIES=${BOOST_INCLUDE_LIBRARIES:-$LIB} ${BOOST_INSTALL_LAYOUT:+-DBOOST_INSTALL_LAYOUT=$BOOST_INSTALL_LAYOUT} ${BUILD_SHARED_LIBS:+-DBUILD_SHARED_LIBS=$BUILD_SHARED_LIBS} .. 165 | - cmake --build . --target install 166 | - cd ../tools/cmake/test/$LIB && mkdir __build__ && cd __build__ 167 | - cmake -DCMAKE_INSTALL_PREFIX=~/.local .. 168 | - cmake --build . 169 | - cmake --build . --target check 170 | 171 | - env: TEST_BOOST_INSTALL=1 LIB=atomic BOOST_INSTALL_LAYOUT=versioned 172 | script: 173 | - pip install --user cmake 174 | - mkdir __build__ && cd __build__ 175 | - cmake -DCMAKE_INSTALL_PREFIX=~/.local -DBOOST_ENABLE_CMAKE=1 -DBoost_VERBOSE=ON -DBOOST_INCLUDE_LIBRARIES=${BOOST_INCLUDE_LIBRARIES:-$LIB} ${BOOST_INSTALL_LAYOUT:+-DBOOST_INSTALL_LAYOUT=$BOOST_INSTALL_LAYOUT} ${BUILD_SHARED_LIBS:+-DBUILD_SHARED_LIBS=$BUILD_SHARED_LIBS} .. 176 | - cmake --build . --target install 177 | - cd ../tools/cmake/test/$LIB && mkdir __build__ && cd __build__ 178 | - cmake -DCMAKE_INSTALL_PREFIX=~/.local .. 179 | - cmake --build . 180 | - cmake --build . --target check 181 | 182 | - env: TEST_BOOST_INSTALL=1 LIB=timer 183 | script: 184 | - pip install --user cmake 185 | - which cmake 186 | - cmake --version 187 | - mkdir __build__ && cd __build__ 188 | - cmake -DCMAKE_INSTALL_PREFIX=~/.local -DBOOST_ENABLE_CMAKE=1 -DBoost_VERBOSE=ON -DBOOST_INCLUDE_LIBRARIES=${BOOST_INCLUDE_LIBRARIES:-$LIB} ${BOOST_INSTALL_LAYOUT:+-DBOOST_INSTALL_LAYOUT=$BOOST_INSTALL_LAYOUT} ${BUILD_SHARED_LIBS:+-DBUILD_SHARED_LIBS=$BUILD_SHARED_LIBS} .. 189 | - cmake --build . --target install 190 | - cd ../tools/cmake/test/$LIB && mkdir __build__ && cd __build__ 191 | - cmake -DCMAKE_INSTALL_PREFIX=~/.local .. 192 | - cmake --build . 193 | - cmake --build . --target check 194 | 195 | - env: TEST_BOOST_INSTALL=1 LIB=timer BOOST_INSTALL_LAYOUT=tagged BUILD_SHARED_LIBS=ON 196 | script: 197 | - pip install --user cmake 198 | - which cmake 199 | - cmake --version 200 | - mkdir __build__ && cd __build__ 201 | - cmake -DCMAKE_INSTALL_PREFIX=~/.local -DBOOST_ENABLE_CMAKE=1 -DBoost_VERBOSE=ON -DBOOST_INCLUDE_LIBRARIES=${BOOST_INCLUDE_LIBRARIES:-$LIB} ${BOOST_INSTALL_LAYOUT:+-DBOOST_INSTALL_LAYOUT=$BOOST_INSTALL_LAYOUT} ${BUILD_SHARED_LIBS:+-DBUILD_SHARED_LIBS=$BUILD_SHARED_LIBS} .. 202 | - cmake --build . --target install 203 | - cd ../tools/cmake/test/$LIB && mkdir __build__ && cd __build__ 204 | - cmake -DCMAKE_INSTALL_PREFIX=~/.local .. 205 | - cmake --build . 206 | - cmake --build . --target check 207 | 208 | - env: TEST_BOOST_INSTALL=1 LIB=timer BOOST_INSTALL_LAYOUT=versioned 209 | script: 210 | - pip install --user cmake 211 | - which cmake 212 | - cmake --version 213 | - mkdir __build__ && cd __build__ 214 | - cmake -DCMAKE_INSTALL_PREFIX=~/.local -DBOOST_ENABLE_CMAKE=1 -DBoost_VERBOSE=ON -DBOOST_INCLUDE_LIBRARIES=${BOOST_INCLUDE_LIBRARIES:-$LIB} ${BOOST_INSTALL_LAYOUT:+-DBOOST_INSTALL_LAYOUT=$BOOST_INSTALL_LAYOUT} ${BUILD_SHARED_LIBS:+-DBUILD_SHARED_LIBS=$BUILD_SHARED_LIBS} .. 215 | - cmake --build . --target install 216 | - cd ../tools/cmake/test/$LIB && mkdir __build__ && cd __build__ 217 | - cmake -DCMAKE_INSTALL_PREFIX=~/.local .. 218 | - cmake --build . 219 | - cmake --build . --target check 220 | 221 | - env: TEST_BOOST_INSTALL=1 LIB=iostreams 222 | script: 223 | - pip install --user cmake 224 | - mkdir __build__ && cd __build__ 225 | - cmake -DCMAKE_INSTALL_PREFIX=~/.local -DBOOST_ENABLE_CMAKE=1 -DBoost_VERBOSE=ON -DBOOST_INCLUDE_LIBRARIES=${BOOST_INCLUDE_LIBRARIES:-$LIB} ${BOOST_INSTALL_LAYOUT:+-DBOOST_INSTALL_LAYOUT=$BOOST_INSTALL_LAYOUT} ${BUILD_SHARED_LIBS:+-DBUILD_SHARED_LIBS=$BUILD_SHARED_LIBS} .. 226 | - cmake --build . --target install 227 | - cd ../tools/cmake/test/$LIB && mkdir __build__ && cd __build__ 228 | - cmake -DCMAKE_INSTALL_PREFIX=~/.local .. 229 | - cmake --build . 230 | - cmake --build . --target check 231 | 232 | - env: TEST_BOOST_INSTALL=1 LIB=iostreams BOOST_INSTALL_LAYOUT=tagged BUILD_SHARED_LIBS=ON 233 | script: 234 | - pip install --user cmake 235 | - mkdir __build__ && cd __build__ 236 | - cmake -DCMAKE_INSTALL_PREFIX=~/.local -DBOOST_ENABLE_CMAKE=1 -DBoost_VERBOSE=ON -DBOOST_INCLUDE_LIBRARIES=${BOOST_INCLUDE_LIBRARIES:-$LIB} ${BOOST_INSTALL_LAYOUT:+-DBOOST_INSTALL_LAYOUT=$BOOST_INSTALL_LAYOUT} ${BUILD_SHARED_LIBS:+-DBUILD_SHARED_LIBS=$BUILD_SHARED_LIBS} .. 237 | - cmake --build . --target install 238 | - cd ../tools/cmake/test/$LIB && mkdir __build__ && cd __build__ 239 | - cmake -DCMAKE_INSTALL_PREFIX=~/.local .. 240 | - cmake --build . 241 | - cmake --build . --target check 242 | 243 | - env: TEST_BOOST_INSTALL=1 LIB=iostreams BOOST_INSTALL_LAYOUT=versioned 244 | script: 245 | - pip install --user cmake 246 | - mkdir __build__ && cd __build__ 247 | - cmake -DCMAKE_INSTALL_PREFIX=~/.local -DBOOST_ENABLE_CMAKE=1 -DBoost_VERBOSE=ON -DBOOST_INCLUDE_LIBRARIES=${BOOST_INCLUDE_LIBRARIES:-$LIB} ${BOOST_INSTALL_LAYOUT:+-DBOOST_INSTALL_LAYOUT=$BOOST_INSTALL_LAYOUT} ${BUILD_SHARED_LIBS:+-DBUILD_SHARED_LIBS=$BUILD_SHARED_LIBS} .. 248 | - cmake --build . --target install 249 | - cd ../tools/cmake/test/$LIB && mkdir __build__ && cd __build__ 250 | - cmake -DCMAKE_INSTALL_PREFIX=~/.local .. 251 | - cmake --build . 252 | - cmake --build . --target check 253 | 254 | - env: BUILD_BOOST=1 BOOST_INSTALL_LAYOUT=tagged BUILD_SHARED_LIBS=ON 255 | install: 256 | - BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true 257 | - cd .. 258 | - git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root 259 | - cd boost-root 260 | - git submodule update --init --jobs 3 261 | - rm -rf tools/cmake/* 262 | - cp -r $TRAVIS_BUILD_DIR/* tools/cmake 263 | script: 264 | - mkdir __build__ && cd __build__ 265 | - cmake -DCMAKE_INSTALL_PREFIX=~/.local -DBOOST_ENABLE_CMAKE=1 -DBoost_VERBOSE=ON ${BOOST_INSTALL_LAYOUT:+-DBOOST_INSTALL_LAYOUT=$BOOST_INSTALL_LAYOUT} ${BUILD_SHARED_LIBS:+-DBUILD_SHARED_LIBS=$BUILD_SHARED_LIBS} .. 266 | - cmake --build . 267 | 268 | - env: INSTALL_BOOST=1 269 | install: 270 | - BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true 271 | - cd .. 272 | - git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root 273 | - cd boost-root 274 | - git submodule update --init --jobs 3 275 | - rm -rf tools/cmake/* 276 | - cp -r $TRAVIS_BUILD_DIR/* tools/cmake 277 | - pip install --user cmake 278 | script: 279 | - mkdir __build__ && cd __build__ 280 | - cmake -DCMAKE_INSTALL_PREFIX=~/.local -DBOOST_ENABLE_CMAKE=1 -DBoost_VERBOSE=ON ${BOOST_INSTALL_LAYOUT:+-DBOOST_INSTALL_LAYOUT=$BOOST_INSTALL_LAYOUT} ${BUILD_SHARED_LIBS:+-DBUILD_SHARED_LIBS=$BUILD_SHARED_LIBS} .. 281 | - cmake --build . --target install 282 | 283 | - env: INSTALL_BOOST=1 BOOST_INSTALL_LAYOUT=versioned BUILD_SHARED_LIBS=ON 284 | install: 285 | - BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true 286 | - cd .. 287 | - git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root 288 | - cd boost-root 289 | - git submodule update --init --jobs 3 290 | - rm -rf tools/cmake/* 291 | - cp -r $TRAVIS_BUILD_DIR/* tools/cmake 292 | - pip install --user cmake 293 | script: 294 | - mkdir __build__ && cd __build__ 295 | - cmake -DCMAKE_INSTALL_PREFIX=~/.local -DBOOST_ENABLE_CMAKE=1 -DBoost_VERBOSE=ON ${BOOST_INSTALL_LAYOUT:+-DBOOST_INSTALL_LAYOUT=$BOOST_INSTALL_LAYOUT} ${BUILD_SHARED_LIBS:+-DBUILD_SHARED_LIBS=$BUILD_SHARED_LIBS} .. 296 | - cmake --build . --target install 297 | 298 | install: 299 | - BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true 300 | - cd .. 301 | - git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root 302 | - cd boost-root 303 | - git submodule update --init --jobs 3 tools/boostdep libs/$LIB 304 | - python tools/boostdep/depinst/depinst.py -g "--jobs 3" $LIB 305 | - rm -rf tools/cmake/* 306 | - cp -r $TRAVIS_BUILD_DIR/* tools/cmake 307 | 308 | script: 309 | - mkdir __build__ && cd __build__ 310 | - cmake -DBOOST_ENABLE_CMAKE=1 -DBUILD_TESTING=ON -DBoost_VERBOSE=ON -DBOOST_INCLUDE_LIBRARIES=${BOOST_INCLUDE_LIBRARIES:-$LIB} ${BUILD_SHARED_LIBS:+-DBUILD_SHARED_LIBS=$BUILD_SHARED_LIBS} .. 311 | - cmake --build . --target tests -- -j 3 312 | - ctest --output-on-failure -j 3 313 | 314 | notifications: 315 | email: 316 | on_success: always 317 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Boost CMake support infrastructure 2 | 3 | This repository hosts the `tools/cmake` Boost submodule, containing 4 | the CMake support infrastructure for Boost. 5 | 6 | Note that the officially supported way to build Boost remains 7 | [with `b2`](https://www.boost.org/more/getting_started/index.html). 8 | 9 | ## Building Boost with CMake 10 | 11 | The first thing you need to know is that the 12 | [official Boost releases](https://www.boost.org/users/download/) 13 | can't be built with CMake. Even though the Boost Github repository 14 | contains a `CMakeLists.txt` file, it's removed from the release. 15 | 16 | That's because the file and directory layout of Boost releases, 17 | for historical reasons, has all the Boost header files copied 18 | into a single `boost/` directory. These headers are then removed 19 | from the individual library `include/` directories. The CMake 20 | support infrastructure expects the headers to remain in their 21 | respective `libs//include` directories, and therefore 22 | does not work on a release archive. 23 | 24 | To build Boost with CMake, you will need either a Git clone 25 | of Boost 26 | (`git clone --recurse-submodules https://github.com/boostorg/boost`) 27 | or the alternative archives 28 | [available on Github](https://github.com/boostorg/boost/releases). 29 | 30 | Once you have cloned, or downloaded and extracted, Boost, use the 31 | usual procedure of 32 | 33 | ``` 34 | mkdir __build 35 | cd __build 36 | cmake .. 37 | cmake --build . 38 | ``` 39 | 40 | to build it with CMake. To install it, add 41 | 42 | ``` 43 | cmake --build . --target install 44 | ``` 45 | 46 | Under Windows (when using the Visual Studio generator), you can 47 | control whether Debug or Release variants are built by adding 48 | `--config Debug` or `--config Release` to the `cmake --build` lines: 49 | 50 | ``` 51 | cmake --build . --config Debug 52 | ``` 53 | 54 | ``` 55 | cmake --build . --target install --config Debug 56 | ``` 57 | 58 | The default is Debug. You can build and 59 | install both Debug and Release at the same time, by running the 60 | respective `cmake --build` line twice, once per `--config`: 61 | 62 | ``` 63 | cmake --build . --target install --config Debug 64 | cmake --build . --target install --config Release 65 | ``` 66 | 67 | ## Configuration variables 68 | 69 | The following variables are supported and can be set either from 70 | the command line as `cmake -DVARIABLE=VALUE ..`, or via `ccmake` 71 | or `cmake-gui`: 72 | 73 | * `BOOST_INCLUDE_LIBRARIES` 74 | 75 | A semicolon-separated list of libraries to include into the build (and 76 | installation.) Defaults 77 | to empty, which means "all libraries". Example: `filesystem;regex`. 78 | 79 | * `BOOST_EXCLUDE_LIBRARIES` 80 | 81 | A semicolon-separated list of libraries to exclude from the build (and 82 | installation.) This is useful if a library causes an error in the CMake 83 | configure phase. 84 | 85 | * `BOOST_ENABLE_MPI` 86 | 87 | Set to ON if Boost libraries depending on MPI should be built. 88 | 89 | * `BOOST_ENABLE_PYTHON` 90 | 91 | Set to ON if Boost libraries depending on Python should be built. 92 | 93 | * [`CMAKE_BUILD_TYPE`](https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html) 94 | 95 | For single-configuration generators such as Makefile and Ninja (the typical 96 | case under POSIX operating systems), controls the build variant (Debug or 97 | Release.) The default when building Boost is set to Release. 98 | 99 | For multi-configuration generators such as the Visual Studio generators, 100 | `CMAKE_BUILD_TYPE` is ignored; the desired configuration is set at build 101 | (or install) time, with the `--config` option to `cmake --build` and 102 | `cmake --install`. 103 | 104 | For more information, see 105 | [the CMake documentation on build configurations](https://cmake.org/cmake/help/latest/manual/cmake-buildsystem.7.html#build-configurations). 106 | 107 | * [`CMAKE_INSTALL_PREFIX`](https://cmake.org/cmake/help/latest/variable/CMAKE_INSTALL_PREFIX.html) 108 | 109 | A standard CMake variable that determines where the headers and libraries 110 | should be installed. The default when building Boost is set to `C:/Boost` 111 | under Windows, `/usr/local` otherwise. 112 | 113 | * [`CMAKE_INSTALL_INCLUDEDIR`](https://cmake.org/cmake/help/latest/module/GNUInstallDirs.html) 114 | 115 | Directory in which to install the header files. Can be relative to 116 | `CMAKE_INSTALL_PREFIX`. Default `include`. 117 | 118 | * [`CMAKE_INSTALL_BINDIR`](https://cmake.org/cmake/help/latest/module/GNUInstallDirs.html) 119 | 120 | Directory in which to install the binary artifacts (executables and Windows 121 | DLLs.) Can be relative to `CMAKE_INSTALL_PREFIX`. Default `bin`. 122 | 123 | * [`CMAKE_INSTALL_LIBDIR`](https://cmake.org/cmake/help/latest/module/GNUInstallDirs.html) 124 | 125 | Directory in which to install the compiled libraries. Can be relative to 126 | `CMAKE_INSTALL_PREFIX`. Default `lib`. 127 | 128 | * `BOOST_INSTALL_CMAKEDIR` 129 | 130 | Directory in which to install the CMake configuration files. Default `lib/cmake`. 131 | 132 | * `BOOST_INSTALL_LAYOUT` 133 | 134 | Boost installation layout. Can be one of `system`, `tagged`, or `versioned`. 135 | The default is `versioned` under Windows, and `system` otherwise. 136 | 137 | `versioned` produces library names of the form 138 | `libboost_timer-vc143-mt-gd-x64-1_82.lib`, containing the toolset (compiler) 139 | name and version, encoded build settings, and the Boost version. (The 140 | extension is `.lib` under Windows, `.a` or `.so` under Linux, and `.a` or 141 | `.dylib` under macOS.) 142 | 143 | `tagged` produces library names of the form `libboost_timer-mt-gd-x64.lib`; 144 | only the build settings are encoded in the name, the toolset and the Boost 145 | version are not. 146 | 147 | `system` produces library names of the form `libboost_timer.lib` (or 148 | `libboost_timer.a`, `libboost_timer.so`, `libboost_timer.dylib`.) 149 | 150 | * `BOOST_INSTALL_INCLUDE_SUBDIR` 151 | 152 | When `BOOST_INSTALL_LAYOUT` is `versioned`, headers are installed in a 153 | subdirectory of `CMAKE_INSTALL_INCLUDEDIR` (to enable several Boost releases 154 | being installed at the same time.) The default for release e.g. 1.81 is 155 | `/boost-1_81`.) 156 | 157 | * `BOOST_RUNTIME_LINK` 158 | 159 | Whether to use the static or the shared C++ runtime libraries under Microsoft 160 | Visual C++ and compatible compilers. (The available values are `shared` and 161 | `static` and the default is `shared`.) 162 | 163 | * [`BUILD_TESTING`](https://cmake.org/cmake/help/latest/module/CTest.html) 164 | 165 | A standard CMake variable; when ON, tests are configured and built. Defaults 166 | to OFF. 167 | 168 | * [`BUILD_SHARED_LIBS`](https://cmake.org/cmake/help/latest/variable/BUILD_SHARED_LIBS.html) 169 | 170 | A standard CMake variable that determines whether to build shared or static 171 | libraries. Defaults to OFF. 172 | 173 | * `BOOST_STAGEDIR` 174 | 175 | The directory in which to place the build outputs. Defaults to the `stage` 176 | subdirectory of the current CMake binary directory. 177 | 178 | The standard CMake variables 179 | [`CMAKE_RUNTIME_OUTPUT_DIRECTORY`](https://cmake.org/cmake/help/latest/variable/CMAKE_RUNTIME_OUTPUT_DIRECTORY.html), 180 | [`CMAKE_LIBRARY_OUTPUT_DIRECTORY`](https://cmake.org/cmake/help/latest/variable/CMAKE_LIBRARY_OUTPUT_DIRECTORY.html), 181 | and 182 | [`CMAKE_ARCHIVE_OUTPUT_DIRECTORY`](https://cmake.org/cmake/help/latest/variable/CMAKE_ARCHIVE_OUTPUT_DIRECTORY.html) 183 | are set by default to `${BOOST_STAGEDIR}/bin`, `${BOOST_STAGEDIR}/lib`, and 184 | `${BOOST_STAGEDIR}/lib`, respectively. 185 | 186 | * [`CMAKE_CXX_VISIBILITY_PRESET`](https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_VISIBILITY_PRESET.html) 187 | 188 | C++ symbol visibility (one of `default`, `hidden`, `protected`, `internal`). The default is set to `hidden` to match `b2`. 189 | 190 | * [`CMAKE_C_VISIBILITY_PRESET`](https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_VISIBILITY_PRESET.html) 191 | 192 | C symbol visibility (one of `default`, `hidden`, `protected`, `internal`). The default is set to `hidden` to match `b2`. 193 | 194 | * [`CMAKE_VISIBILITY_INLINES_HIDDEN`](https://cmake.org/cmake/help/latest/variable/CMAKE_VISIBILITY_INLINES_HIDDEN.html) 195 | 196 | Whether inline functions should have hidden visibility. The default is set to `ON` to match `b2`. 197 | 198 | ## Library-specific configuration variables 199 | 200 | Some Boost libraries provide their own configuration variables, some of which 201 | are given below. 202 | 203 | ### Context 204 | 205 | * `BOOST_CONTEXT_BINARY_FORMAT` 206 | 207 | Allowed values are `elf`, `mach-o`, `pe`, `xcoff`. The default is 208 | autodetected from the platform. 209 | 210 | * `BOOST_CONTEXT_ABI` 211 | 212 | Allowed values are `aapcs`, `eabi`, `ms`, `n32`, `n64`, `o32`, `o64`, `sysv`, 213 | `x32`. The default is autodetected from the platform. 214 | 215 | * `BOOST_CONTEXT_ARCHITECTURE` 216 | 217 | Allowed values are `arm`, `arm64`, `loongarch64`, `mips32`, `mips64`, 218 | `ppc32`, `ppc64`, `riscv64`, `s390x`, `i386`, `x86_64`, `combined`. 219 | The default is autodetected from the platform. 220 | 221 | * `BOOST_CONTEXT_ASSEMBLER` 222 | 223 | Allowed values are `masm`, `gas`, `armasm`. The default is autodetected from 224 | the platform. 225 | 226 | * `BOOST_CONTEXT_ASM_SUFFIX` 227 | 228 | Allowed values are `.asm` and `.S`. The default is autodetected from the 229 | platform. 230 | 231 | * `BOOST_CONTEXT_IMPLEMENTATION` 232 | 233 | Allowed values are `fcontext`, `ucontext`, `winfib`. Defaults to `fcontext`. 234 | 235 | ### Fiber 236 | 237 | * `BOOST_FIBER_NUMA_TARGET_OS` 238 | 239 | Target OS for the Fiber NUMA support. Can be `aix`, `freebsd`, `hpux`, 240 | `linux`, `solaris`, `windows`, `none`. Defaults to `windows` under Windows, 241 | `linux` under Linux, otherwise `none`. 242 | 243 | ### IOStreams 244 | 245 | * `BOOST_IOSTREAMS_ENABLE_ZLIB` 246 | 247 | When ON, enables ZLib support. Defaults to ON when `zlib` is found, OFF 248 | otherwise. 249 | 250 | * `BOOST_IOSTREAMS_ENABLE_BZIP2` 251 | 252 | When ON, enables BZip2 support. Defaults to ON when `libbzip2` is found, 253 | OFF otherwise. 254 | 255 | * `BOOST_IOSTREAMS_ENABLE_LZMA` 256 | 257 | When ON, enables LZMA support. Defaults to ON when `liblzma` is found, 258 | OFF otherwise. 259 | 260 | * `BOOST_IOSTREAMS_ENABLE_ZSTD` 261 | 262 | When ON, enables Zstd support. Defaults to ON when `libzstd` is found, 263 | OFF otherwise. 264 | 265 | ### Locale 266 | 267 | * `BOOST_LOCALE_ENABLE_ICU` 268 | 269 | When ON, enables the ICU backend. Defaults to ON when ICU is found, 270 | OFF otherwise. 271 | 272 | * `BOOST_LOCALE_ENABLE_ICONV` 273 | 274 | When ON, enables the Iconv backend. Defaults to ON when `iconv` is found, 275 | OFF otherwise. 276 | 277 | * `BOOST_LOCALE_ENABLE_POSIX` 278 | 279 | When ON, enables the POSIX backend. Defaults to ON on POSIX systems, 280 | OFF otherwise. 281 | 282 | * `BOOST_LOCALE_ENABLE_STD` 283 | 284 | When ON, enables the `std::locale` backend. Defaults to ON. 285 | 286 | * `BOOST_LOCALE_ENABLE_WINAPI` 287 | 288 | When ON, enables the Windows API backend. Defaults to ON under Windows, OFF 289 | otherwise. 290 | 291 | ### Stacktrace 292 | 293 | * `BOOST_STACKTRACE_ENABLE_NOOP` 294 | 295 | When ON, builds the `boost_stacktrace_noop` library variant. Defaults to ON. 296 | 297 | * `BOOST_STACKTRACE_ENABLE_BACKTRACE` 298 | 299 | When ON, builds the `boost_stacktrace_backtrace` library variant. Defaults 300 | to ON when `libbacktrace` is found, OFF otherwise. 301 | 302 | * `BOOST_STACKTRACE_ENABLE_ADDR2LINE` 303 | 304 | When ON, builds the `boost_stacktrace_addr2line` library variant. Defaults 305 | to ON, except on Windows. 306 | 307 | * `BOOST_STACKTRACE_ENABLE_BASIC` 308 | 309 | When ON, builds the `boost_stacktrace_basic` library variant. Defaults to ON. 310 | 311 | * `BOOST_STACKTRACE_ENABLE_WINDBG` 312 | 313 | When ON, builds the `boost_stacktrace_windbg` library variant. Defaults to 314 | ON under Windows when WinDbg support is autodetected, otherwise OFF. 315 | 316 | * `BOOST_STACKTRACE_ENABLE_WINDBG_CACHED` 317 | 318 | When ON, builds the `boost_stacktrace_windbg_cached` library variant. 319 | Defaults to ON under Windows when WinDbg support is autodetected and when 320 | `thread_local` is supported, otherwise OFF. 321 | 322 | ### Test 323 | 324 | * `BOOST_TEST_HEADERS_ONLY` 325 | 326 | When ON, installs only headers required for using the header-only variant of 327 | the Unit Test Framework. Defaults to OFF. 328 | 329 | ### Thread 330 | 331 | * `BOOST_THREAD_THREADAPI` 332 | 333 | Threading API, `pthread` or `win32`. Defaults to `win32` under Windows, 334 | `pthread` otherwise. 335 | 336 | ## Testing Boost with CMake 337 | 338 | To run the Boost tests with CMake/CTest, first configure as before, but with 339 | `BUILD_TESTING=ON`: 340 | 341 | ``` 342 | mkdir __build 343 | cd __build 344 | cmake -DBUILD_TESTING=ON .. 345 | ``` 346 | 347 | then build the tests: 348 | 349 | ``` 350 | cmake --build . --target tests 351 | ``` 352 | 353 | and then run them: 354 | 355 | ``` 356 | ctest --output-on-failure --no-tests=error 357 | ``` 358 | 359 | Under Windows, you need to select a configuration (Debug or Release): 360 | 361 | ``` 362 | cmake --build . --target tests --config Debug 363 | ctest --output-on-failure --no-tests=error -C Debug 364 | ``` 365 | 366 | To only build the tests for a specific library, and not the entire Boost, 367 | use `BOOST_INCLUDE_LIBRARIES`: 368 | 369 | ``` 370 | cmake -DBUILD_TESTING=ON -DBOOST_INCLUDE_LIBRARIES=timer .. 371 | ``` 372 | 373 | To build and run in parallel using more than one core, use the `-j` 374 | option: 375 | 376 | ``` 377 | cmake --build . --target tests -j 16 378 | ctest --output-on-failure --no-tests=error -j 16 379 | ``` 380 | 381 | A convenience target `check` is provided that first builds the tests and 382 | then invokes `ctest`: 383 | 384 | ``` 385 | cmake --build . --target check 386 | ``` 387 | 388 | but it doesn't support running the tests in parallel. 389 | 390 | ## Using Boost after building and installing it with CMake 391 | 392 | Normally, a Boost installation is used from CMake by means of 393 | `find_package(Boost)`. However, up to and including release 1.81.0, installing 394 | Boost with CMake did not deploy the necessary CMake configuration file for 395 | the `Boost` package, so `find_package(Boost)` did not work. (It also did 396 | not provide the `Boost::boost` and `Boost::headers` targets, on which many 397 | existing `CMakeLists.txt` files rely.) 398 | 399 | Instead, the individual Boost libraries needed to be referenced as in 400 | ```cmake 401 | find_package(boost_filesystem 1.81 REQUIRED) 402 | ``` 403 | 404 | This has been rectified in Boost 1.82, which installs an umbrella CMake 405 | configuration file for the Boost package (`BoostConfig.cmake`) and 406 | provides the `Boost::boost` and `Boost::headers` compatibility targets. 407 | 408 | ## Using Boost with `add_subdirectory` 409 | 410 | Assuming that your project already has a copy of Boost in a subdirectory, 411 | either deployed as a Git submodule or extracted manually by the user as a 412 | prerequisite, using it is relatively straightforward: 413 | 414 | ```cmake 415 | add_subdirectory(deps/boost) 416 | ``` 417 | 418 | However, as-is, this will configure all Boost libraries and build them by 419 | default regardless of whether they are used. It's better to use 420 | 421 | ```cmake 422 | add_subdirectory(deps/boost EXCLUDE_FROM_ALL) 423 | ``` 424 | 425 | so that only the libraries that are referenced by the project are built, 426 | and it's even better to set `BOOST_INCLUDE_LIBRARIES` before the 427 | `add_subdirectory` call to a list of the Boost libraries that need to be 428 | configured: 429 | 430 | ```cmake 431 | set(BOOST_INCLUDE_LIBRARIES filesystem regex) 432 | add_subdirectory(deps/boost EXCLUDE_FROM_ALL) 433 | ``` 434 | 435 | ## Using an individual Boost library with `add_subdirectory` 436 | 437 | Boost is a large dependency, and sometimes a project only needs a single 438 | library. It's possible to use `add_subdirectory` with individual Boost 439 | libraries (`https://github.com/boostorg/`) instead of the entire 440 | superproject or release archive. However, since Boost libraries depend on 441 | each other quite extensively, all library dependencies also need to be 442 | added (again via `add_subdirectory`.) 443 | 444 | As an example, this is how one would use Boost.Timer in this manner: 445 | 446 | ```cmake 447 | set(libs 448 | 449 | timer 450 | 451 | # Primary dependencies 452 | 453 | chrono 454 | config 455 | core 456 | io 457 | predef 458 | system 459 | throw_exception 460 | 461 | # Secondary dependencies 462 | 463 | assert 464 | integer 465 | move 466 | mpl 467 | ratio 468 | static_assert 469 | type_traits 470 | typeof 471 | utility 472 | winapi 473 | variant2 474 | preprocessor 475 | rational 476 | mp11 477 | ) 478 | 479 | foreach(lib IN LISTS libs) 480 | 481 | add_subdirectory(deps/boost/${lib} EXCLUDE_FROM_ALL) 482 | 483 | endforeach() 484 | ``` 485 | 486 | assuming that the individual libraries have been placed in subdirectories 487 | of `deps/boost`. 488 | 489 | (The list of required dependencies above has been produced by running 490 | `boostdep --brief timer`. See 491 | [the documentation of Boostdep](https://boost.org/tools/boostdep).) 492 | 493 | ## Using Boost with `FetchContent` 494 | 495 | `FetchContent` downloads the required dependencies as part of CMake's 496 | project configuration phase. While this is convenient because it doesn't 497 | require the user to acquire the dependencies beforehand, in the case of 498 | Boost it involves an 87 MB download, so you should carefully weigh the 499 | pros and cons of this approach. 500 | 501 | That said, here's how one would use Boost with `FetchContent`: 502 | 503 | ```cmake 504 | include(FetchContent) 505 | 506 | FetchContent_Declare( 507 | Boost 508 | URL https://github.com/boostorg/boost/releases/download/boost-1.84.0/boost-1.84.0.tar.xz 509 | URL_MD5 893b5203b862eb9bbd08553e24ff146a 510 | DOWNLOAD_EXTRACT_TIMESTAMP ON 511 | ) 512 | 513 | FetchContent_MakeAvailable(Boost) 514 | ``` 515 | 516 | This has the same drawback as the simple `add_subdirectory` call -- all 517 | Boost libraries are configured and built, even if not used by the project. 518 | 519 | To configure only some Boost libraries, set `BOOST_INCLUDE_LIBRARIES` 520 | before the `FetchContent_MakeAvailable` call: 521 | 522 | ```cmake 523 | set(BOOST_INCLUDE_LIBRARIES timer filesystem regex) 524 | FetchContent_MakeAvailable(Boost) 525 | ``` 526 | 527 | To perform the `add_subdirectory` call with the `EXCLUDE_FROM_ALL` option, if you 528 | are using CMake 3.28 or newer, you can simply pass `EXCLUDE_FROM_ALL` to 529 | `FetchContent_Declare`: 530 | 531 | ```cmake 532 | FetchContent_Declare( 533 | Boost 534 | URL https://github.com/boostorg/boost/releases/download/boost-1.84.0/boost-1.84.0.tar.xz 535 | URL_MD5 893b5203b862eb9bbd08553e24ff146a 536 | DOWNLOAD_EXTRACT_TIMESTAMP ON 537 | EXCLUDE_FROM_ALL 538 | ) 539 | ``` 540 | 541 | For earlier versions of CMake, you can replace `FetchContent_MakeAvailable(Boost)` with this: 542 | 543 | ```cmake 544 | FetchContent_GetProperties(Boost) 545 | 546 | if(NOT Boost_POPULATED) 547 | 548 | message(STATUS "Fetching Boost") 549 | FetchContent_Populate(Boost) 550 | 551 | message(STATUS "Configuring Boost") 552 | add_subdirectory(${Boost_SOURCE_DIR} ${Boost_BINARY_DIR} EXCLUDE_FROM_ALL) 553 | 554 | endif() 555 | ``` 556 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2016-2021 Peter Dimov 2 | # Distributed under the Boost Software License, Version 1.0. 3 | # (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt) 4 | 5 | version: 1.0.{build}-{branch} 6 | 7 | shallow_clone: true 8 | 9 | branches: 10 | only: 11 | - master 12 | - develop 13 | - /feature\/.*/ 14 | 15 | image: Visual Studio 2019 16 | 17 | environment: 18 | matrix: 19 | 20 | - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 21 | LIB: assert 22 | - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 23 | LIB: assert 24 | - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 25 | LIB: assert 26 | - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 27 | LIB: assert 28 | 29 | - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 30 | LIB: timer 31 | - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 32 | LIB: timer 33 | BUILD_SHARED_LIBS: ON 34 | - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 35 | LIB: timer 36 | - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 37 | LIB: timer 38 | BUILD_SHARED_LIBS: ON 39 | 40 | - TEST_BOOST_TEST: 1 41 | LIB: core 42 | 43 | - TEST_BOOST_INSTALL: 1 44 | LIB: assert 45 | 46 | - TEST_BOOST_INSTALL: 1 47 | LIB: mp11 48 | 49 | - TEST_BOOST_INSTALL: 1 50 | LIB: atomic 51 | 52 | - TEST_BOOST_INSTALL: 1 53 | LIB: atomic 54 | BUILD_SHARED_LIBS: ON 55 | 56 | - TEST_BOOST_INSTALL: 1 57 | LIB: atomic 58 | BOOST_RUNTIME_LINK: static 59 | 60 | - TEST_BOOST_INSTALL: 1 61 | LIB: timer 62 | 63 | - TEST_BOOST_INSTALL: 1 64 | LIB: timer 65 | BUILD_SHARED_LIBS: ON 66 | 67 | - TEST_BOOST_INSTALL: 1 68 | LIB: timer 69 | BOOST_RUNTIME_LINK: static 70 | 71 | - TEST_BOOST_INSTALL: 1 72 | LIB: iostreams 73 | 74 | - TEST_BOOST_INSTALL: 1 75 | LIB: iostreams 76 | BUILD_SHARED_LIBS: ON 77 | 78 | - TEST_BOOST_INSTALL: 1 79 | LIB: iostreams 80 | BOOST_RUNTIME_LINK: static 81 | 82 | install: 83 | - set BOOST_BRANCH=develop 84 | - if "%APPVEYOR_REPO_BRANCH%" == "master" set BOOST_BRANCH=master 85 | - cd .. 86 | - git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root 87 | - cd boost-root 88 | - git submodule update --init --jobs 3 tools/boostdep libs/%LIB% 89 | - python tools/boostdep/depinst/depinst.py -g "--jobs 3" %LIB% 90 | - rd /s/q tools\cmake 91 | - xcopy /s /e /q %APPVEYOR_BUILD_FOLDER% tools\cmake\ 92 | 93 | build: off 94 | 95 | test_script: 96 | - if "%BUILD_SHARED_LIBS%" == "" SET BUILD_SHARED_LIBS=0 97 | - if "%BOOST_INCLUDE_LIBRARIES%" == "" SET BOOST_INCLUDE_LIBRARIES=%LIB% 98 | 99 | - if "%TEST_BOOST_TEST%%TEST_BOOST_FETCH%" == "" mkdir __build__ && cd __build__ 100 | - if "%TEST_BOOST_TEST%%TEST_BOOST_FETCH%" == "" cmake -DBOOST_ENABLE_CMAKE=1 -DBUILD_TESTING=ON -DBoost_VERBOSE=ON -DBUILD_SHARED_LIBS=%BUILD_SHARED_LIBS% -DBOOST_INCLUDE_LIBRARIES=%BOOST_INCLUDE_LIBRARIES% -DBOOST_RUNTIME_LINK=%BOOST_RUNTIME_LINK% .. 101 | 102 | - if "%TEST_BOOST_TEST%%TEST_BOOST_FETCH%%TEST_BOOST_INSTALL%" == "" cmake --build . -j 3 --target tests --config Debug && ctest --output-on-failure -j 3 -C Debug 103 | - if "%TEST_BOOST_TEST%%TEST_BOOST_FETCH%%TEST_BOOST_INSTALL%" == "" cmake --build . -j 3 --target tests --config Release && ctest --output-on-failure -j 3 -C Release 104 | - if "%TEST_BOOST_TEST%%TEST_BOOST_FETCH%%TEST_BOOST_INSTALL%" == "" cmake --build . -j 3 --target tests --config MinSizeRel && ctest --output-on-failure -j 3 -C MinSizeRel 105 | - if "%TEST_BOOST_TEST%%TEST_BOOST_FETCH%%TEST_BOOST_INSTALL%" == "" cmake --build . -j 3 --target tests --config RelWithDebInfo && ctest --output-on-failure -j 3 -C RelWithDebInfo 106 | 107 | - if NOT "%TEST_BOOST_INSTALL%" == "" cmake --build . -j 3 --target install --config Debug 108 | - if NOT "%TEST_BOOST_INSTALL%" == "" cmake --build . -j 3 --target install --config Release 109 | - if NOT "%TEST_BOOST_INSTALL%" == "" cd ../tools/cmake/test/%LIB% 110 | - if NOT "%TEST_BOOST_INSTALL%" == "" mkdir __build__ && cd __build__ 111 | - if NOT "%TEST_BOOST_INSTALL%" == "" cmake -DCMAKE_PREFIX_PATH=C:/Boost -DBOOST_RUNTIME_LINK=%BOOST_RUNTIME_LINK% .. 112 | - if NOT "%TEST_BOOST_INSTALL%" == "" PATH C:\Boost\bin;%PATH% 113 | - if NOT "%TEST_BOOST_INSTALL%" == "" cmake --build . --config Debug && ctest --output-on-failure -C Debug 114 | - if NOT "%TEST_BOOST_INSTALL%" == "" cmake --build . --config Release && ctest --output-on-failure -C Release 115 | 116 | - if NOT "%TEST_BOOST_TEST%" == "" cd tools/cmake/test/boost_test 117 | - if NOT "%TEST_BOOST_TEST%" == "" mkdir __build__ && cd __build__ 118 | - if NOT "%TEST_BOOST_TEST%" == "" cmake -DBoost_VERBOSE=ON .. 119 | - if NOT "%TEST_BOOST_TEST%" == "" cmake --build . -j 3 --target tests --config Debug && ctest --output-on-failure -j 3 -C Debug 120 | - if NOT "%TEST_BOOST_TEST%" == "" cmake --build . -j 3 --target tests --config Release && ctest --output-on-failure -j 3 -C Release 121 | - if NOT "%TEST_BOOST_TEST%" == "" cmake --build . -j 3 --target tests --config MinSizeRel && ctest --output-on-failure -j 3 -C MinSizeRel 122 | - if NOT "%TEST_BOOST_TEST%" == "" cmake --build . -j 3 --target tests --config RelWithDebInfo && ctest --output-on-failure -j 3 -C RelWithDebInfo 123 | -------------------------------------------------------------------------------- /config/BoostConfig.cmake: -------------------------------------------------------------------------------- 1 | # Copyright 2019, 2023 Peter Dimov 2 | # Distributed under the Boost Software License, Version 1.0. 3 | # (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt) 4 | 5 | # This CMake configuration file provides support for find_package(Boost). 6 | 7 | if(Boost_VERBOSE OR Boost_DEBUG) 8 | 9 | message(STATUS "Found Boost ${Boost_VERSION} at ${Boost_DIR}") 10 | 11 | # Output requested configuration (f.ex. "REQUIRED COMPONENTS filesystem") 12 | 13 | if(Boost_FIND_QUIETLY) 14 | set(_BOOST_CONFIG "${_BOOST_CONFIG} QUIET") 15 | endif() 16 | 17 | if(Boost_FIND_REQUIRED) 18 | set(_BOOST_CONFIG "${_BOOST_CONFIG} REQUIRED") 19 | endif() 20 | 21 | foreach(__boost_comp IN LISTS Boost_FIND_COMPONENTS) 22 | if(${Boost_FIND_REQUIRED_${__boost_comp}}) 23 | list(APPEND _BOOST_COMPONENTS ${__boost_comp}) 24 | else() 25 | list(APPEND _BOOST_OPTIONAL_COMPONENTS ${__boost_comp}) 26 | endif() 27 | endforeach() 28 | 29 | if(_BOOST_COMPONENTS) 30 | set(_BOOST_CONFIG "${_BOOST_CONFIG} COMPONENTS ${_BOOST_COMPONENTS}") 31 | endif() 32 | 33 | if(_BOOST_OPTIONAL_COMPONENTS) 34 | set(_BOOST_CONFIG "${_BOOST_CONFIG} OPTIONAL_COMPONENTS ${_BOOST_OPTIONAL_COMPONENTS}") 35 | endif() 36 | 37 | if(_BOOST_CONFIG) 38 | message(STATUS " Requested configuration:${_BOOST_CONFIG}") 39 | endif() 40 | 41 | unset(_BOOST_CONFIG) 42 | unset(_BOOST_COMPONENTS) 43 | unset(_BOOST_OPTIONAL_COMPONENTS) 44 | 45 | endif() 46 | 47 | macro(boostcfg_find_component comp required quiet) 48 | 49 | set(_BOOST_QUIET) 50 | if(Boost_FIND_QUIETLY OR ${quiet}) 51 | set(_BOOST_QUIET QUIET) 52 | endif() 53 | 54 | set(_BOOST_REQUIRED) 55 | if(${required} AND Boost_FIND_REQUIRED) 56 | set(_BOOST_REQUIRED REQUIRED) 57 | endif() 58 | 59 | set(__boost_comp_nv "${comp}") 60 | 61 | get_filename_component(_BOOST_CMAKEDIR "${CMAKE_CURRENT_LIST_DIR}/../" ABSOLUTE) 62 | 63 | if(Boost_DEBUG) 64 | message(STATUS "BoostConfig: find_package(boost_${__boost_comp_nv} ${Boost_VERSION} EXACT CONFIG ${_BOOST_REQUIRED} ${_BOOST_QUIET} HINTS ${_BOOST_CMAKEDIR})") 65 | endif() 66 | 67 | find_package(boost_${__boost_comp_nv} ${Boost_VERSION} EXACT CONFIG ${_BOOST_REQUIRED} ${_BOOST_QUIET} HINTS ${_BOOST_CMAKEDIR}) 68 | 69 | set(__boost_comp_found ${boost_${__boost_comp_nv}_FOUND}) 70 | 71 | # FindPackageHandleStandardArgs expects __FOUND 72 | set(Boost_${comp}_FOUND ${__boost_comp_found}) 73 | 74 | # FindBoost sets Boost__FOUND 75 | string(TOUPPER ${comp} _BOOST_COMP) 76 | set(Boost_${_BOOST_COMP}_FOUND ${__boost_comp_found}) 77 | 78 | # FindBoost compatibility variables: Boost_LIBRARIES, Boost__LIBRARY 79 | if(__boost_comp_found) 80 | 81 | list(APPEND Boost_LIBRARIES Boost::${__boost_comp_nv}) 82 | set(Boost_${_BOOST_COMP}_LIBRARY Boost::${__boost_comp_nv}) 83 | 84 | endif() 85 | 86 | unset(_BOOST_REQUIRED) 87 | unset(_BOOST_QUIET) 88 | unset(_BOOST_CMAKEDIR) 89 | unset(__boost_comp_nv) 90 | unset(__boost_comp_found) 91 | unset(_BOOST_COMP) 92 | 93 | endmacro() 94 | 95 | # Find boost_headers 96 | 97 | boostcfg_find_component(headers 1 0) 98 | 99 | if(NOT boost_headers_FOUND) 100 | 101 | set(Boost_FOUND 0) 102 | set(Boost_NOT_FOUND_MESSAGE "A required dependency, boost_headers, has not been found.") 103 | 104 | return() 105 | 106 | endif() 107 | 108 | # Compatibility variables 109 | 110 | set(Boost_MAJOR_VERSION ${Boost_VERSION_MAJOR}) 111 | set(Boost_MINOR_VERSION ${Boost_VERSION_MINOR}) 112 | set(Boost_SUBMINOR_VERSION ${Boost_VERSION_PATCH}) 113 | 114 | set(Boost_VERSION_STRING ${Boost_VERSION}) 115 | set(Boost_VERSION_MACRO ${Boost_VERSION_MAJOR}0${Boost_VERSION_MINOR}0${Boost_VERSION_PATCH}) 116 | 117 | get_target_property(Boost_INCLUDE_DIRS Boost::headers INTERFACE_INCLUDE_DIRECTORIES) 118 | set(Boost_LIBRARIES "") 119 | 120 | # Save project's policies 121 | cmake_policy(PUSH) 122 | cmake_policy(SET CMP0057 NEW) # if IN_LIST 123 | 124 | # Find components 125 | 126 | foreach(__boost_comp IN LISTS Boost_FIND_COMPONENTS) 127 | 128 | boostcfg_find_component(${__boost_comp} ${Boost_FIND_REQUIRED_${__boost_comp}} 0) 129 | 130 | endforeach() 131 | 132 | # Compatibility targets 133 | 134 | if(NOT TARGET Boost::boost) 135 | 136 | add_library(Boost::boost INTERFACE IMPORTED) 137 | set_property(TARGET Boost::boost APPEND PROPERTY INTERFACE_LINK_LIBRARIES Boost::headers) 138 | 139 | add_library(Boost::diagnostic_definitions INTERFACE IMPORTED) 140 | add_library(Boost::disable_autolinking INTERFACE IMPORTED) 141 | add_library(Boost::dynamic_linking INTERFACE IMPORTED) 142 | 143 | if(WIN32) 144 | 145 | set_property(TARGET Boost::diagnostic_definitions PROPERTY INTERFACE_COMPILE_DEFINITIONS "BOOST_LIB_DIAGNOSTIC") 146 | set_property(TARGET Boost::disable_autolinking PROPERTY INTERFACE_COMPILE_DEFINITIONS "BOOST_ALL_NO_LIB") 147 | set_property(TARGET Boost::dynamic_linking PROPERTY INTERFACE_COMPILE_DEFINITIONS "BOOST_ALL_DYN_LINK") 148 | 149 | endif() 150 | 151 | endif() 152 | 153 | # Restore project's policies 154 | cmake_policy(POP) 155 | -------------------------------------------------------------------------------- /developer.md: -------------------------------------------------------------------------------- 1 | # CMake for Boost Developers 2 | 3 | ## Header-only Libraries 4 | 5 | ### Automatic Generation with Boostdep 6 | 7 | The easiest way to add CMake support to a header-only Boost library is 8 | to generate a `CMakeLists.txt` file with 9 | [Boostdep](https://www.boost.org/doc/libs/release/tools/boostdep/doc/html/index.html) 10 | using the command `boostdep --cmake `, where `` is the 11 | name of the repository (or the directory name). 12 | 13 | For example, a `CMakeLists.txt` file for Boost.Core can be generated with 14 | `boostdep --cmake core`, and the result will be, as of this writing, 15 | 16 | ```cmake 17 | # Generated by `boostdep --cmake core` 18 | # Copyright 2020 Peter Dimov 19 | # Distributed under the Boost Software License, Version 1.0. 20 | # https://www.boost.org/LICENSE_1_0.txt 21 | 22 | cmake_minimum_required(VERSION 3.5...3.16) 23 | 24 | project(boost_core VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX) 25 | 26 | add_library(boost_core INTERFACE) 27 | add_library(Boost::core ALIAS boost_core) 28 | 29 | target_include_directories(boost_core INTERFACE include) 30 | 31 | target_link_libraries(boost_core 32 | INTERFACE 33 | Boost::assert 34 | Boost::config 35 | Boost::static_assert 36 | ) 37 | 38 | if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt") 39 | 40 | add_subdirectory(test) 41 | 42 | endif() 43 | ``` 44 | 45 | Most header-only libraries require no modification to this `boostdep` output. 46 | 47 | You are not required to use this exact file, but if you can, there are benefits 48 | for doing so: 49 | 50 | * You can regenerate the file at any time, to pick up style changes as the 51 | Boost CMake infrastructure evolves and Boostdep is updated to match; 52 | * Boostdep computes the library dependencies automatically (as this is its 53 | primary purpose as a tool), and if you make changes to the library that 54 | cause its dependencies to change, a simple regeneration can keep the list 55 | up to date; 56 | * You can add a CI job that compares the output of Boostdep to your current 57 | CMakeLists.txt file, which will inform you if the file needs to be 58 | regenerated. 59 | 60 | Even if you decide to make changes to your `CMakeLists.txt` file, the 61 | generated output provides a useful starting point. Its contents are explained 62 | below. 63 | 64 | ### Version Requirement 65 | ```cmake 66 | cmake_minimum_required(VERSION 3.5...3.16) 67 | ``` 68 | 69 | This directive sets the minimum required version of CMake and must be the 70 | first thing in it. If CMake is older than 3.5, the result will be a fatal 71 | error at configure time, and inability to proceed with building. 72 | 73 | In addition, this number changes the behavior of newer CMake versions to 74 | attempt to be compatible with the stated version. If this only said 75 | ```cmake 76 | cmake_minimum_required(VERSION 3.5) 77 | ``` 78 | a newer version of CMake would have emulated version 3.5. The additional 79 | `...3.16` suffix, however, requests newer versions to emulate 3.16 instead. 80 | This is typically the latest version of CMake with which the `CMakeLists.txt` 81 | file has been tested. If you make changes to the file for other reasons, you 82 | may want to update the directive to, say, 83 | ```cmake 84 | cmake_minimum_required(VERSION 3.5...3.20) 85 | ``` 86 | You should avoid increasing the minimal CMake requirement above the Boost 87 | minimum, which is at present tentatively and conservatively set to 3.5, but 88 | will likely be increased in the near future. If you use a higher minimum, 89 | configuring Boost will fail with earlier CMake versions, even if the user 90 | is not interested in your library. He will then be forced to manually exclude 91 | your library from the build with `-DBOOST_EXCLUDE_LIBRARIES`, which is not 92 | an ideal user experience. 93 | 94 | ### Project Declaration 95 | ```cmake 96 | project(boost_core VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX) 97 | ``` 98 | 99 | The project declaration must generally be preceded only by the above 100 | version requirement directive, and sets the project name, the project 101 | version, and the languages (C, C++) that the source files will use. 102 | 103 | Boost projects by convention are named `boost_libname`, in lowercase, 104 | as in the above. (Libraries in `numeric` such as `numeric/conversion` 105 | use an underscore in place of the slash: `boost_numeric_conversion`.) 106 | 107 | The version is set to match the variable `BOOST_SUPERPROJECT_VERSION`, 108 | which the Boost superproject `CMakeLists.txt` file sets to the current 109 | Boost version (such as `1.77.0`.) 110 | 111 | If your library is included directly in a user project with 112 | `add_subdirectory`, `BOOST_SUPERPROJECT_VERSION` will not be set and 113 | the project version will be empty, as if it weren't given: 114 | ```cmake 115 | project(boost_core LANGUAGES CXX) 116 | ``` 117 | This is usually what one wants. Since manually maintaining a version 118 | is time consuming and doesn't bring much, most libraries that do 119 | include one fail to maintain it properly. It's better to leave it empty; 120 | the version is of no significance in an `add_subdirectory` workflow. 121 | 122 | The `LANGUAGES` portion should be left at the default `CXX`, which 123 | enables the C++ language. If removed, CMake will configure both C and 124 | C++. C is only needed if the library has C source files, which a 125 | header-only library does not have. 126 | 127 | ### Library Target Declaration 128 | ```cmake 129 | add_library(boost_core INTERFACE) 130 | ``` 131 | 132 | The first `add_library` declares the library target, which by convention 133 | is `boost_libname`, same as the project name. `INTERFACE` means that 134 | this library is header-only and requires no building. 135 | 136 | ```cmake 137 | add_library(Boost::core ALIAS boost_core) 138 | ``` 139 | 140 | The second `add_library` declares an alternative name for the library, 141 | which by convention is `Boost::libname`. It's good CMake practice to 142 | only link to targets of this form (more specifically, to targets containing 143 | `::`), because they are unambiguously CMake target names, whereas the 144 | alphanumeric `boost_core` may refer to either a target or to a library 145 | on disk named f.ex. `libboost_core.so`. 146 | 147 | ### Include Directory Declaration 148 | ```cmake 149 | target_include_directories(boost_core INTERFACE include) 150 | ``` 151 | 152 | This directive declares the directory containing the library headers, which 153 | for Boost libraries is the `include` subdirectory. (A relative path is 154 | interpreted as relative to `CMAKE_CURRENT_SOURCE_DIR`, that is, to the 155 | location of the current `CMakeLists.txt` file.) 156 | 157 | If you are familiar with CMake, your first impulse would be to declare this 158 | line wrong, and replace it with 159 | ```cmake 160 | target_include_directories(boost_core INTERFACE 161 | $) 168 | ``` 169 | or perhaps 170 | ```cmake 171 | target_include_directories(boost_core INTERFACE 172 | $) 174 | ``` 175 | 176 | You shouldn't; the line is, in fact, correct. The Boost superproject will 177 | automatically invoke `boost_install` for your target, which will patch 178 | the value of the include path to something like that last alternative 179 | (but it will take into account the Boost-specific variables 180 | `BOOST_INSTALL_LAYOUT` and `BOOST_INSTALL_INCLUDE_SUBDIR`.) 181 | 182 | ### Dependencies 183 | ```cmake 184 | target_link_libraries(boost_core 185 | INTERFACE 186 | Boost::assert 187 | Boost::config 188 | Boost::static_assert 189 | ) 190 | ``` 191 | 192 | Traditionally, Boost has had all the headers copied (in a release) or 193 | linked (in a modular layout) into a single `boost/` directory. This made 194 | it possible to include headers from any library (A) into any other (B), 195 | without the need to declare that B depends on A. 196 | 197 | With CMake, we will no longer maintain a single `boost/` directory where 198 | all the headers are copied. Headers of A will remain in `libs/A/include`, 199 | and if this directory isn't in the include path of B, B will not be able 200 | to include a header from A. 201 | 202 | In order for the include path of B to contain `libs/A/include`, B must 203 | explicitly declare a dependency on A. In CMake, this is accomplished by 204 | "linking" to A, even when A is header-only. 205 | 206 | This is the purpose of the `target_link_libraries` directive above. In 207 | this specific case, it declares that `boost_core` depends on `Boost::assert`, 208 | `Boost::config`, and `Boost::static_assert`, and will result into 209 | `libs/assert/include`, `libs/config/include`, and `libs/static_assert/include` 210 | being added to the include path of Core. (More precisely, they will be added 211 | to the include paths of the users of `Boost::core`. Core itself needs no 212 | include path because it doesn't require any compilation. This is what the 213 | `INTERFACE` keyword means - it sets the "usage requirements" of the target, 214 | which are propagated upwards to its users.) 215 | 216 | Note that the exact form of the directive, with each `Boost::libname` target on 217 | its own line, is no longer necessary after Boost 1.89. 218 | You can as well put them on a singe line: 219 | `target_link_libraries(boost_core INTERFACE Boost::assert Boost::config Boost::static_assert)` 220 | This dependency specification influences the behavior of the user-settable 221 | `BOOST_INCLUDE_LIBRARIES` option of the superproject, which requests only the 222 | listed libraries and their dependencies to be configured, built, and/or 223 | installed. 224 | To determine the dependencies, a simple parser scans the `CMakeLists.txt` 225 | files, looking for strings matching `Boost::libname`, excluding the name of the 226 | current library and those appearing in comments. Additionally, you can use 227 | pragmas to influence the scanner: 228 | 229 | ```cmake 230 | # Ignored by parser if in library folder "core" 231 | add_library(Boost::core ALIAS boost_core) 232 | # Parser adds "Boost::assert" "Boost::dummy" 233 | target_link_libraries(boost_core INTERFACE Boost::assert Boost::dummy 234 | # Only "Boost::config added for those 2 lines 235 | Boost::config # Boost::static_assert 236 | # Boost::ignored 237 | ) 238 | 239 | # Current dependencies: Boost::assert, Boost::dummy Boost::config 240 | ... 241 | # Pragmas using Boost-Include, Boost-Exclude with or without colons and/or whitespace 242 | # Boost-Include: Boost::filesystem 243 | # Boost-Exclude Boost::dummy 244 | 245 | # Final dependencies: Boost::assert, Boost::config, Boost::filesystem 246 | ``` 247 | 248 | This is useful if the parser misdetects a dependency (please open an issue) 249 | or e.g. for optional dependencies. 250 | 251 | Dependencies in `test/CMakeLists.txt` (and subfolders) are handled in the same 252 | way, except their tests won't be build and those libraries won't be installed 253 | unless they are dependencies in the root CMakeLists.txt of the current library 254 | or any (transitive) dependency of those. 255 | 256 | ### Testing Support 257 | ```cmake 258 | if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt") 259 | 260 | add_subdirectory(test) 261 | 262 | endif() 263 | ``` 264 | 265 | The final portion of the generated `CMakeLists.txt` file adds support for 266 | invoking the library tests from the Boost superproject. Since not all 267 | libraries have one, this is only enabled when 268 | `libs/libname/test/CMakeLists.txt` exists. 269 | 270 | In principle, since you know whether this file exists for your library or 271 | not, you can either remove this condition or remove this entire section; but 272 | doing so will make your `CMakeLists.txt` file not match the generated output, 273 | which has its downsides. 274 | 275 | `BUILD_TESTING` is the standard CMake option (typically defined by the `CTest` 276 | CMake module) that allows the user to enable or disable tests for a project. 277 | It's used here to skip the inclusion of the `test` subproject in order to 278 | speed up the configure and build phases of Boost when testing is not required 279 | or desired. 280 | 281 | If your library has a `test/CMakeLists.txt` file that is not intended to be 282 | used from the Boost superproject, and is incompatible with it, replace this 283 | block with either 284 | ```cmake 285 | if(BUILD_TESTING AND CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) 286 | 287 | add_subdirectory(test) 288 | 289 | endif() 290 | ``` 291 | when your test suite is only intended to be used when your library is the 292 | root project (that's usually the case, so this option is the recommended one), 293 | or 294 | ```cmake 295 | if(BUILD_TESTING AND NOT BOOST_SUPERPROJECT_VERSION) 296 | 297 | add_subdirectory(test) 298 | 299 | endif() 300 | ``` 301 | when your test suite is also intended to be invoked when your library is 302 | a subproject of a user project. (This case is rare and user projects are 303 | typically not interested in running their subprojects' tests, so you 304 | probably don't want this.) 305 | 306 | ### Installation Support 307 | 308 | You may have noticed by now that no installation support is declared in the 309 | `CMakeLists.txt` file. Nevertheless, the library can in fact be installed. 310 | The Boost superproject automatically adds the necessary support to libraries 311 | which declare a target `boost_libname` that matches the directory of the 312 | `CMakeLists.txt` file (`libs/libname`) and whose `target_include_directories` 313 | directive matches the one above. 314 | 315 | It is recommended that you don't attempt to add your own installation support. 316 | Let the superproject handle it. 317 | 318 | ### Required C++ Standard 319 | 320 | If your library needs C++11 or above, you can declare this requirement by 321 | adding the following directive: 322 | ```cmake 323 | target_compile_features(boost_libname INTERFACE cxx_std_11) 324 | ``` 325 | (use `cxx_std_14` for C++14, `cxx_std_17` for C++17, and so on.) 326 | 327 | This will increase your CMake requirement to 3.8, so you should also update 328 | the preamble to reflect this. 329 | 330 | If your `meta/libraries.json` already declares the C++ requirement by means 331 | of `"cxxstd": "xx"`, Boostdep 1.77+ will automatically take this into 332 | account and add the above `target_compile_features`. 333 | 334 | ### Additional Functionality 335 | 336 | This is all you need to have a header-only library that integrates into the 337 | Boost CMake infrastructure. It is also a well-behaved suproject that can be 338 | included into user CMake projects via `add_subdirectory`. Avoid the urge to 339 | add more functionality unless it's really necessary, as it will compromise 340 | the usability of your library as a subproject. 341 | 342 | Many library authors who use CMake, however, add development-centric 343 | functionality to their `CMakeLists.txt` file; you might already have. In this 344 | case, try to keep the `CMakeLists.txt` portions described so far as close to 345 | unchanged as possible, and at the end, add a section guarded with 346 | ```cmake 347 | if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) 348 | 349 | # Functionality enabled only when we're the root project 350 | 351 | endif() 352 | ``` 353 | and put all your current developer-centric functionality there. This way, 354 | subproject use will be unaffected, and you can still use CMake from your 355 | library directory for development-related activities such as generating 356 | Visual Studio workspaces, or testing outside the Boost tree. 357 | 358 | ## Compiled Libraries 359 | 360 | ### A Starting Point 361 | 362 | Even if your library requires compilation, you can still use 363 | `boostdep --cmake libname` at least as a starting point. We'll take 364 | Timer as an example, with the output of `boostdep --cmake timer` given 365 | below: 366 | ```cmake 367 | # Generated by `boostdep --cmake timer` 368 | # Copyright 2020 Peter Dimov 369 | # Distributed under the Boost Software License, Version 1.0. 370 | # https://www.boost.org/LICENSE_1_0.txt 371 | 372 | cmake_minimum_required(VERSION 3.5...3.16) 373 | 374 | project(boost_timer VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX) 375 | 376 | add_library(boost_timer 377 | src/auto_timers_construction.cpp 378 | src/cpu_timer.cpp 379 | ) 380 | 381 | add_library(Boost::timer ALIAS boost_timer) 382 | 383 | target_include_directories(boost_timer PUBLIC include) 384 | 385 | target_link_libraries(boost_timer 386 | PUBLIC 387 | Boost::config 388 | Boost::core 389 | Boost::system 390 | PRIVATE 391 | Boost::chrono 392 | Boost::io 393 | Boost::predef 394 | Boost::throw_exception 395 | ) 396 | 397 | target_compile_definitions(boost_timer 398 | PUBLIC BOOST_TIMER_NO_LIB 399 | PRIVATE BOOST_TIMER_SOURCE 400 | ) 401 | 402 | if(BUILD_SHARED_LIBS) 403 | target_compile_definitions(boost_timer PUBLIC BOOST_TIMER_DYN_LINK) 404 | else() 405 | target_compile_definitions(boost_timer PUBLIC BOOST_TIMER_STATIC_LINK) 406 | endif() 407 | 408 | if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt") 409 | 410 | add_subdirectory(test) 411 | 412 | endif() 413 | ``` 414 | 415 | We won't be repeating the explanations of the sections that match the 416 | header-only case, and will only focus on the differences. 417 | 418 | ### Source Files 419 | ```cmake 420 | add_library(boost_timer 421 | src/auto_timers_construction.cpp 422 | src/cpu_timer.cpp 423 | ) 424 | ``` 425 | 426 | For a compiled library, you need to declare your source files. This is 427 | accomplished by listing them in the `add_library` directive. `boostdep` uses 428 | the contents of your `src` subdirectory (but ignores any subdirectories.) 429 | 430 | Since Timer is a simple library, this works as-is. Many compiled libraries 431 | however might require adjusting the source file list, or choosing it based 432 | on the platform. For example, Thread needs something like 433 | ```cmake 434 | if(BOOST_THREAD_THREADAPI STREQUAL win32) 435 | 436 | set(THREAD_SOURCES 437 | src/win32/thread.cpp 438 | src/win32/tss_dll.cpp 439 | src/win32/tss_pe.cpp 440 | src/win32/thread_primitives.cpp 441 | src/future.cpp 442 | ) 443 | 444 | else() 445 | 446 | set(THREAD_SOURCES 447 | src/pthread/thread.cpp 448 | src/pthread/once.cpp 449 | src/future.cpp 450 | ) 451 | 452 | endif() 453 | 454 | add_library(boost_thread ${THREAD_SOURCES}) 455 | ``` 456 | The logic for choosing the source files is already spelled out in your 457 | `Jamfile`, so you will need to port it to CMake. 458 | 459 | If your library has C source files, you'll need to also enable C as a 460 | language in your project declaration: 461 | ```cmake 462 | project(boost_container VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES C CXX) 463 | ``` 464 | although `boostdep` might already have done so for you. 465 | 466 | The `add_library(libname sources...)` declaration generates either a static 467 | or a shared library depending on whether `BUILD_SHARED_LIBS` is set to `ON` 468 | or `OFF`. This is idiomatic CMake behavior and is what we want. 469 | 470 | ### Directive Scope 471 | ```cmake 472 | target_include_directories(boost_timer PUBLIC include) 473 | ``` 474 | 475 | The only difference with the header-only case is the use of `PUBLIC` instead 476 | of `INTERFACE`. `PUBLIC` applies to both the library and its dependents; in 477 | `b2` terms it declares both a requirement and a usage-requirement. 478 | 479 | ```cmake 480 | target_link_libraries(boost_timer 481 | PUBLIC 482 | Boost::config 483 | Boost::core 484 | Boost::system 485 | PRIVATE 486 | Boost::chrono 487 | Boost::io 488 | Boost::predef 489 | Boost::throw_exception 490 | ) 491 | ``` 492 | 493 | Again, the difference here is in the use of the scope keywords `PUBLIC` and 494 | `PRIVATE` (applies only to the library, not to dependents) instead of 495 | `INTERFACE`. `boostdep` puts the dependencies referred to from the `include` 496 | subdirectory in the `PUBLIC` section, and those referred to from the `src` 497 | subdirectory in the `PRIVATE` section. 498 | 499 | ### Compile Definitions 500 | ```cmake 501 | target_compile_definitions(boost_timer 502 | PUBLIC BOOST_TIMER_NO_LIB 503 | PRIVATE BOOST_TIMER_SOURCE 504 | ) 505 | ``` 506 | 507 | The compile definitions are passed to the compiler with a `-D` option and 508 | define macros. In this case by Boost convention we define `BOOST_TIMER_NO_LIB` 509 | to disable autolink and `BOOST_TIMER_SOURCE` when compiling the library to 510 | properly declare exported functions as exported (as opposed to imported, 511 | which will be the case when using the library.) 512 | 513 | ```cmake 514 | if(BUILD_SHARED_LIBS) 515 | target_compile_definitions(boost_timer PUBLIC BOOST_TIMER_DYN_LINK) 516 | else() 517 | target_compile_definitions(boost_timer PUBLIC BOOST_TIMER_STATIC_LINK) 518 | endif() 519 | ``` 520 | 521 | When building shared libraries, we define `BOOST_TIMER_DYN_LINK`, and when 522 | building static libraries, we define `BOOST_TIMER_STATIC_LINK`. Again, this 523 | is needed to properly export and import functions from dynamic libraries, in 524 | particular on the Windows platform. 525 | 526 | These defines are described in the 527 | [Boost document about separate compilation](https://www.boost.org/development/separate_compilation.html) 528 | and you can look at how 529 | [the Timer library uses them](https://github.com/boostorg/timer/blob/e9387e4d9956074dffcc15bf15bd6d2625e91ebf/include/boost/timer/config.hpp) 530 | as an example. 531 | 532 | ### Building More Than One Library Target 533 | 534 | If your build results in more than one library being built, or if the name 535 | of your library target does not match your directory name, you need to invoke 536 | the installation support manually. As an example, Serialization builds two 537 | library targets, `boost_serialization` and `boost_wserialization`, and the 538 | procedure to install them entails adding 539 | [the following section](https://github.com/boostorg/serialization/blob/337b3fbc7c4648d6f95f863546b9482500c8dec5/CMakeLists.txt#L116-L118) 540 | to `CMakeLists.txt`: 541 | ```cmake 542 | if(BOOST_SUPERPROJECT_VERSION AND NOT CMAKE_VERSION VERSION_LESS 3.13) 543 | boost_install(TARGETS boost_serialization boost_wserialization 544 | VERSION ${BOOST_SUPERPROJECT_VERSION} HEADER_DIRECTORY include) 545 | endif() 546 | ``` 547 | The check for `BOOST_SUPERPROJECT_VERSION` is necessary because without the 548 | superproject, `boost_install` is not available. The check for the CMake 549 | version is needed because the automatic Boost installation support requires 550 | CMake 3.13. Even though `boost_install` will work on earlier CMake versions, 551 | you will likely get errors at generate time because the dependencies of your 552 | library will lack install support. 553 | 554 | For another example of a `CMakeLists.txt` file building and installing more 555 | than one library, see [Boost.Test](https://github.com/boostorg/test/blob/bce2d24c8b32f47f0403766fe4fee3e2e93af0a0/CMakeLists.txt#L102-L114). 556 | 557 | ### Using Threads 558 | 559 | If your library uses multiple threads or threading primitives, you need to 560 | add the following snippet to your `CMakeLists.txt` file: 561 | ```cmake 562 | set(THREADS_PREFER_PTHREAD_FLAG ON) 563 | find_package(Threads REQUIRED) 564 | ``` 565 | and then link to the target `Threads::Threads` in your 566 | `target_link_libraries` directive. Typically, this would go in the `PUBLIC` 567 | section (or `INTERFACE` if your library is header-only.) 568 | 569 | (`PRIVATE` would imply that your library needs threading, but the clients 570 | of your library do not, which is rarely the case.) 571 | 572 | Note that this will abort the CMake configure phase with an error if 573 | threading support can't be enabled. This is usually acceptable, but it's also 574 | possible to omit the `REQUIRED` in `find_package(Threads REQUIRED)` and then 575 | check `Threads_FOUND` and take some appropriate action when it's FALSE, such 576 | as setting a preprocessor definition via `target_compile_definitions`. 577 | 578 | ### Build Options 579 | 580 | Some libraries allow different functionality or backends. For example, 581 | Iostreams has optional support for compressed streams and can use one or more 582 | of the compression libraries ZLib, BZip2, LibLZMA, or Zstd, if these are 583 | present on the system when the library is built. Locale, for another example, 584 | can use Iconv, ICU, POSIX `newlocale`, or the Windows API, again depending on 585 | availability at build time. 586 | 587 | The recommended way to provide such optional functionality is to allow user 588 | configuration with sensible defaults, as shown in the following example that 589 | allows optional use of ZLib: 590 | 591 | ```cmake 592 | find_package(ZLIB QUIET) # Look for ZLib 593 | 594 | option(BOOST_MYLIB_ENABLE_ZLIB "Boost.MyLib: enable ZLib support" ${ZLIB_FOUND}) 595 | 596 | if(BOOST_MYLIB_ENABLE_ZLIB) 597 | 598 | find_package(ZLIB REQUIRED) # For real this time 599 | 600 | target_compile_definitions(boost_mylib PRIVATE BOOST_MYLIB_ENABLE_ZLIB=1) 601 | target_add_sources(boost_mylib PRIVATE src/zlib.cpp) 602 | target_link_libraries(boost_mylib PRIVATE ZLIB::ZLIB) 603 | 604 | endif() 605 | ``` 606 | 607 | The general pattern is 608 | 609 | * determine a sensible default 610 | * add a CMake option to allow user control and override 611 | * if the option is `ON`, enable functionality 612 | 613 | Avoid silently enabling functionality on the basis of autodetection; it's 614 | better to allow user control, in both directions. That is, the user should 615 | be allowed to disable the functionality even if it's possible to incorporate 616 | it, and the user should also be allowed to enable the functionality even if 617 | autodetection says it won't work. 618 | 619 | `find_package` in quiet mode is not the only possible way to determine the 620 | default. You can also use platform detection (`if(WIN32)`), the result of a 621 | configure check (`cxx_check_source_compiles`), and other measures. 622 | 623 | After all the build options have been declared and taken into account, the 624 | library should emit a single line of status output that shows the selected 625 | configuration. For Iostreams, this output is of the form 626 | ``` 627 | -- Boost.Iostreams: ZLIB OFF, BZip2 OFF, LZMA OFF, Zstd OFF 628 | ``` 629 | 630 | Other Boost libraries that allow configuration are Context, Fiber, Locale, 631 | Python, Stacktrace, Thread. For reference, their corresponding output is 632 | ``` 633 | -- Boost.Context: architecture x86_64, binary format pe, ABI ms, assembler masm, suffix .asm, implementation fcontext 634 | -- Boost.Fiber: NUMA target OS is windows 635 | -- Boost.Locale: iconv OFF, ICU OFF, POSIX OFF, std ON, winapi ON 636 | -- Boost.Python: using Python 3.9.5 with NumPy at C:/Python39/Lib/site-packages/numpy/core/include 637 | -- Boost.Stacktrace: noop ON, backtrace OFF, addr2line OFF, basic ON, windbg ON, windbg_cached ON 638 | -- Boost.Thread: threading API is win32 639 | ``` 640 | 641 | ## Guidelines and Best Practices 642 | 643 | ### Avoid Unnecessary Options 644 | 645 | When your library is built as part of Boost, it should only add CMake options 646 | and cache variables when they materially affect the way it's built or it will 647 | operate. 648 | 649 | Remember that Boost contains more than 140 libraries. If every such library 650 | adds four "nice to have" options, this will result in 560 options in total in 651 | `cmake-gui` for the user to wade through, most of which of no relevance for 652 | the use at hand. 653 | 654 | Either add the options only when `BOOST_SUPERPROJECT_VERSION` is not defined, 655 | or only add them when your project is the root project (recommended). 656 | 657 | (The difference is whether you insist on your options appearing when someone 658 | uses the library with `add_subdirectory`. Typically, the options people add 659 | to their libraries are only relevant when the library is the root project.) 660 | 661 | Definitely don't do this: 662 | ```cmake 663 | option(BOOST_MYLIB_MYOPTION "" ON) 664 | 665 | if(BOOST_MYLIB_MYOPTION AND NOT BOOST_SUPERPROJECT_VERSION) 666 | 667 | # Do highly valuable optional things 668 | 669 | endif() 670 | ``` 671 | 672 | This displays the option, but makes it do nothing. Instead, either put the 673 | option declaration inside an `if`, or use 674 | [`CMakeDependentOption`](https://cmake.org/cmake/help/latest/module/CMakeDependentOption.html): 675 | ```cmake 676 | include(CMakeDependentOption) 677 | cmake_dependent_option(BOOST_MYLIB_MYOPTION "" ON "NOT BOOST_SUPERPROJECT_VERSION" OFF) 678 | 679 | if(BOOST_MYLIB_MYOPTION) 680 | 681 | # Do highly valuable optional things 682 | 683 | endif() 684 | ``` 685 | 686 | ### Avoid Unnecessary Status Output 687 | 688 | When your library is built as part of Boost, avoid the urge to emit status 689 | output unless it's relevant. 690 | 691 | Remember that Boost contains more than 140 libraries. If every such library 692 | emits two lines of status output, this will result in 280 lines in total, most 693 | of them of no interest to the user. 694 | 695 | Status output should be reserved for information that is of importance to 696 | the user building and installing Boost, which usually means that it should 697 | only be emitted by libraries that materially alter their operation on the 698 | basis of user configuration or properties of the build environment. 699 | 700 | Starting with CMake 3.15, 701 | [`message`](https://cmake.org/cmake/help/latest/command/message.html) 702 | now supports `VERBOSE` and `DEBUG` message types, which would be ideal for 703 | the purpose of developer-centric output, if we could require CMake 3.15. 704 | We don't (yet), so the current convention is to only emit "debug" output when 705 | `Boost_DEBUG` is `ON`, and only emit "verbose" output when `Boost_DEBUG` is 706 | `ON` or `Boost_VERBOSE` is `ON`. 707 | 708 | (The rule of thumb separating "verbose" from "debug" is that the target 709 | audience of the "debug" output is the person authoring the `CMakeLists.txt` 710 | file, whereas the target audience of the "verbose" output is the user who 711 | prefers verbosity over conciseness.) 712 | 713 | ### Prefix Target Names 714 | 715 | Target names are global. Always prefix your target names with the name of your 716 | project/library, such as `boost_mylib-mytarget`. 717 | 718 | (This is typically only of relevance if you write your own tests by hand using 719 | `add_executable` and `add_test`.) 720 | 721 | ### Do Not Add Tests Unless BUILD_TESTING Is ON 722 | 723 | `BUILD_TESTING` is the standard CMake variable that controls whether 724 | `add_test` does anything. Unless `BUILD_TESTING` is `ON`, to save time, you 725 | should avoid creating any tests or targets on which they depend. Usually, this 726 | translates to 727 | ```cmake 728 | if(BUILD_TESTING) 729 | add_subdirectory(test) 730 | endif() 731 | ``` 732 | 733 | ### Do Not Overuse Generator Expressions 734 | 735 | Since CMake doesn't support any inline function calls or expressions, 736 | programmers are tempted to use generator expressions. In a situation where 737 | one would write in C++ `foo? "bar": "baz"`, one could write in CMake 738 | `$,BAR,BAZ>`. 739 | 740 | Don't do this. It's not the same. Generator expressions are evaluated in the 741 | generate phase, which happens after the configure phase. If you do 742 | ```cmake 743 | target_compile_definitions(boost_mylib PUBLIC $,BOOST_MYLIB_DYN_LINK,BOOST_MYLINK_STATIC_LINK>) 744 | ``` 745 | (and assuming `BUILD_SHARED_LIBS` is `ON`), you're not setting the 746 | `COMPILE_DEFINITIONS` property of `boost_mylib` to `BOOST_MYLIB_DYN_LINK`, but 747 | to `$,BOOST_MYLIB_DYN_LINK,BOOST_MYLINK_STATIC_LINK>`. 748 | 749 | Yes, it will still be evaluated to the right thing during generation, but it's 750 | better to perform evaluations that only depend on configuration-time values at 751 | configuration time and write the less "clever" 752 | ```cmake 753 | if(BUILD_SHARED_LIBS) 754 | target_compile_definitions(boost_mylib PUBLIC BOOST_MYLIB_DYN_LINK) 755 | else() 756 | target_compile_definitions(boost_mylib PUBLIC BOOST_MYLINK_STATIC_LINK) 757 | endif() 758 | ``` 759 | 760 | ## Usage Scenarios 761 | 762 | ### Building and Installing Boost 763 | 764 | The primary scenario we will support is, obviously, building and installing 765 | Boost with CMake (and optionally, running the tests, if one has a few days 766 | to spare). 767 | 768 | The building procedure would generally involve issuing (from the Boost root) 769 | ```bash 770 | mkdir __build 771 | cd __build 772 | cmake .. 773 | cmake --build . -j 774 | ``` 775 | 776 | which should result in Boost libraries being built with the specified 777 | configuration options in subdirectories of the "stage" directory, by default 778 | `stage/lib` and `stage/bin`. 779 | 780 | Subsequent installation would be performed with 781 | ```bash 782 | cmake --build . --target install 783 | ``` 784 | assuming that `CMAKE_INSTALL_PREFIX` was set beforehand to the desired 785 | destination directory. 786 | 787 | Under Windows, when using the default Visual Studio generator, the building 788 | and installation procedure would need to be performed twice, once with 789 | `--config Debug`, and once with `--config Release` (or perhaps with 790 | `--config RelWithDebInfo`, as desired.) 791 | 792 | Testing the entire Boost would be performed with 793 | ```bash 794 | cmake -DBUILD_TESTING=ON .. 795 | cmake --build . --target tests -j 796 | ctest --output-on-failure -j 797 | ``` 798 | 799 | Again, when using the Visual Studio generator, this would be 800 | ```bash 801 | cmake --build . --target tests -j --config Debug 802 | ctest --output-on-failure -j -C Debug 803 | ``` 804 | resp. 805 | ```bash 806 | cmake --build . --target tests -j --config Release 807 | ctest --output-on-failure -j -C Release 808 | ``` 809 | 810 | ### Using Boost libraries as Subprojects 811 | 812 | The secondary scenario we would like to support would be user projects 813 | "consuming" Boost libraries piecemeal without the superproject, by having 814 | them in subdirectories in their project (as Git submodules, or acquired 815 | with `FetchContent`), and then using `add_subdirectory` to incorporate them 816 | in the master CMake project. 817 | 818 | A sample project that demonstrates how users would consume individual Boost 819 | libraries in this manner is available at 820 | [github.com/pdimov/boost_cmake_demo](https://github.com/pdimov/boost_cmake_demo). 821 | 822 | Note that `BOOST_SUPERPROJECT_VERSION` is not set in this scenario, but all of 823 | the recommendations in the preceding sections still apply. Be sure to not 824 | degrade the experience of the users choosing to embed Boost libraries in this 825 | manner because your logic relies on checking `BOOST_SUPERPROJECT_VERSION`. 826 | 827 | ### Sole Boost Library as Subproject 828 | 829 | Some Boost developers wish to support a scenario in which their library is 830 | included via `add_subdirectory` into the user project, but other Boost 831 | libraries are not. To obtain access to their Boost dependencies, they rely 832 | on preexisting Boost installations, found using `find_package(Boost)`. 833 | 834 | This rarely makes sense. Since the library is a Boost library, if 835 | `find_package(Boost)` works for it, it will also work for the user, which 836 | will make that library available (it being part of Boost.) There is no 837 | need to incorporate it individually. 838 | 839 | The cases where this does make sense generally concern a new library that 840 | is not yet accepted into Boost, has not yet appeared in a Boost release, or 841 | is sufficiently new that the typical `find_package(Boost)` finds a Boost 842 | release that does not contain it. 843 | 844 | These conditions only apply in the short term, and supporting this use case 845 | is not recommended, because in the long term it's both a maintenance burden 846 | and a source of problems. (When `find_package(Boost)` does find a Boost 847 | release containing the library, it will rarely be the same version, which can 848 | easily lead to the user project containing two versions of the library, with 849 | the associated ODR violations which would at best manifest as link errors.) 850 | 851 | If you insist on supporting this scenario, please make sure to not compromise 852 | the user experience in the previous two cases. 853 | 854 | ### "Standalone" Installation 855 | 856 | Installing an individual Boost library, without the rest of Boost, is an even 857 | worse idea. It can easily lead to a broken Boost, and there's not much to be 858 | gained even if it "works". Don't do it. If you do, please don't use the same 859 | package name (`boost_libname`) or target names (`boost_libname`, 860 | `Boost::libname`) as the legitimate Boost installation; if possible, also do 861 | not use the `boost` namespace, to avoid link errors or ODR violations when 862 | the "standalone" library and the legitimate Boost library end up in the same 863 | binary (this happens more often than you might think.) 864 | 865 | ### "Standalone" Development and Testing 866 | - Creating IDE Projects 867 | 868 | ## CI Quick Testing 869 | 870 | ### Building the Library 871 | ### Testing add_subdirectory Use 872 | ### Testing Use after Installation 873 | 874 | ## Testing 875 | 876 | ### Using boost_test 877 | ### Using boost_test_jamfile 878 | ### Using "Plain" CMake Tests 879 | -------------------------------------------------------------------------------- /include/BoostFetch.cmake: -------------------------------------------------------------------------------- 1 | # Copyright 2018, 2019 Peter Dimov 2 | # Distributed under the Boost Software License, Version 1.0. 3 | # See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt 4 | 5 | if(NOT CMAKE_VERSION VERSION_LESS 3.10) 6 | include_guard() 7 | endif() 8 | 9 | if(NOT COMMAND FetchContent_Populate) 10 | 11 | if(CMAKE_VERSION VERSION_LESS 3.11) 12 | 13 | message(STATUS "Fetching FetchContent.cmake") 14 | 15 | file(DOWNLOAD 16 | "https://gitlab.kitware.com/cmake/cmake/raw/v3.11.3/Modules/FetchContent.cmake" 17 | "${CMAKE_BINARY_DIR}/Modules/FetchContent.cmake" 18 | ) 19 | 20 | file(DOWNLOAD 21 | "https://gitlab.kitware.com/cmake/cmake/raw/v3.11.3/Modules/FetchContent/CMakeLists.cmake.in" 22 | "${CMAKE_BINARY_DIR}/Modules/FetchContent/CMakeLists.cmake.in" 23 | ) 24 | 25 | include(${CMAKE_BINARY_DIR}/Modules/FetchContent.cmake) 26 | 27 | else() 28 | 29 | include(FetchContent) 30 | 31 | endif() 32 | 33 | endif() 34 | 35 | function(boost_fetch) 36 | 37 | cmake_parse_arguments(_ "EXCLUDE_FROM_ALL;NO_ADD_SUBDIR" "TAG" "" ${ARGN}) 38 | 39 | if(NOT __UNPARSED_ARGUMENTS) 40 | 41 | message(FATAL_ERROR "boost_fetch: missing required argument, repository name") 42 | return() 43 | 44 | endif() 45 | 46 | list(GET __UNPARSED_ARGUMENTS 0 REPO) 47 | list(REMOVE_AT __UNPARSED_ARGUMENTS 0) 48 | 49 | if(__UNPARSED_ARGUMENTS) 50 | 51 | message(AUTHOR_WARNING "boost_fetch: extra arguments ignored: ${__UNPARSED_ARGUMENTS}") 52 | 53 | endif() 54 | 55 | if(NOT __TAG) 56 | 57 | set(__TAG master) 58 | 59 | endif() 60 | 61 | string(MAKE_C_IDENTIFIER ${REPO} NAME) 62 | 63 | if(CMAKE_VERSION VERSION_LESS 3.6) 64 | 65 | FetchContent_Declare(${NAME} QUIET GIT_REPOSITORY "https://github.com/${REPO}" GIT_TAG ${__TAG}) 66 | 67 | else() 68 | 69 | FetchContent_Declare(${NAME} QUIET GIT_REPOSITORY "https://github.com/${REPO}" GIT_TAG ${__TAG} GIT_SHALLOW 1) 70 | 71 | endif() 72 | 73 | FetchContent_GetProperties(${NAME}) 74 | 75 | if(NOT ${NAME}_POPULATED) 76 | 77 | message(STATUS "Fetching ${REPO}:${__TAG}") 78 | 79 | FetchContent_Populate(${NAME}) 80 | 81 | if(__NO_ADD_SUBDIR) 82 | 83 | # Skip add_subdirectory 84 | 85 | elseif(__EXCLUDE_FROM_ALL) 86 | 87 | add_subdirectory(${${NAME}_SOURCE_DIR} ${${NAME}_BINARY_DIR} EXCLUDE_FROM_ALL) 88 | 89 | else() 90 | 91 | add_subdirectory(${${NAME}_SOURCE_DIR} ${${NAME}_BINARY_DIR}) 92 | 93 | endif() 94 | 95 | endif() 96 | 97 | endfunction(boost_fetch) 98 | -------------------------------------------------------------------------------- /include/BoostInstall.cmake: -------------------------------------------------------------------------------- 1 | # Copyright 2019-2023 Peter Dimov 2 | # Distributed under the Boost Software License, Version 1.0. 3 | # See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt 4 | 5 | if(NOT CMAKE_VERSION VERSION_LESS 3.10) 6 | include_guard() 7 | endif() 8 | 9 | include(BoostMessage) 10 | include(GNUInstallDirs) 11 | include(CMakePackageConfigHelpers) 12 | 13 | # Variables 14 | 15 | if(WIN32) 16 | set(__boost_default_layout "versioned") 17 | else() 18 | set(__boost_default_layout "system") 19 | endif() 20 | 21 | set(__boost_default_cmakedir "${CMAKE_INSTALL_LIBDIR}/cmake") 22 | set(__boost_default_include_subdir "/boost-${PROJECT_VERSION_MAJOR}_${PROJECT_VERSION_MINOR}") 23 | 24 | # Define cache variables when Boost is the root project 25 | 26 | if(CMAKE_SOURCE_DIR STREQUAL "${BOOST_SUPERPROJECT_SOURCE_DIR}") 27 | 28 | set(BOOST_INSTALL_LAYOUT "${__boost_default_layout}" CACHE STRING "Installation layout (versioned, tagged, or system)") 29 | set_property(CACHE BOOST_INSTALL_LAYOUT PROPERTY STRINGS versioned tagged system) 30 | 31 | set(BOOST_INSTALL_CMAKEDIR "${__boost_default_cmakedir}" CACHE STRING "Installation directory for CMake configuration files") 32 | set(BOOST_INSTALL_INCLUDE_SUBDIR "${__boost_default_include_subdir}" CACHE STRING "Header subdirectory when layout is versioned") 33 | 34 | else() 35 | 36 | # add_subdirectory use 37 | 38 | if(NOT DEFINED BOOST_INSTALL_LAYOUT) 39 | set(BOOST_INSTALL_LAYOUT "${__boost_default_layout}") 40 | endif() 41 | 42 | if(NOT DEFINED BOOST_INSTALL_CMAKEDIR) 43 | set(BOOST_INSTALL_CMAKEDIR "${__boost_default_cmakedir}") 44 | endif() 45 | 46 | if(NOT DEFINED BOOST_INSTALL_INCLUDE_SUBDIR) 47 | set(BOOST_INSTALL_INCLUDE_SUBDIR "${__boost_default_include_subdir}") 48 | endif() 49 | 50 | endif() 51 | 52 | if(BOOST_INSTALL_LAYOUT STREQUAL "versioned") 53 | string(APPEND CMAKE_INSTALL_INCLUDEDIR "${BOOST_INSTALL_INCLUDE_SUBDIR}") 54 | endif() 55 | 56 | # 57 | 58 | if(CMAKE_SOURCE_DIR STREQUAL "${BOOST_SUPERPROJECT_SOURCE_DIR}" AND NOT __boost_install_status_message_guard) 59 | message(STATUS "Boost: using ${BOOST_INSTALL_LAYOUT} layout: ${CMAKE_INSTALL_INCLUDEDIR}, ${CMAKE_INSTALL_BINDIR}, ${CMAKE_INSTALL_LIBDIR}, ${BOOST_INSTALL_CMAKEDIR}") 60 | set(__boost_install_status_message_guard TRUE) 61 | endif() 62 | 63 | # 64 | 65 | function(__boost_install_set_output_name LIB TYPE VERSION) 66 | 67 | set(name_debug ${LIB}) 68 | set(name_release ${LIB}) 69 | 70 | # prefix 71 | if(WIN32 AND TYPE STREQUAL "STATIC_LIBRARY") 72 | set_target_properties(${LIB} PROPERTIES PREFIX "lib") 73 | endif() 74 | 75 | # toolset 76 | if(BOOST_INSTALL_LAYOUT STREQUAL versioned) 77 | 78 | string(TOLOWER ${CMAKE_CXX_COMPILER_ID} toolset) 79 | 80 | if(toolset STREQUAL "msvc") 81 | 82 | set(toolset "vc") 83 | 84 | if(CMAKE_CXX_COMPILER_VERSION MATCHES "^([0-9]+)[.]([0-9]+)") 85 | 86 | if(CMAKE_MATCH_1 GREATER 18) 87 | math(EXPR major ${CMAKE_MATCH_1}-5) 88 | else() 89 | math(EXPR major ${CMAKE_MATCH_1}-6) 90 | endif() 91 | 92 | math(EXPR minor ${CMAKE_MATCH_2}/10) 93 | 94 | if(major EQUAL 14 AND minor EQUAL 4) 95 | # MSVC 19.40 is still vc143 96 | set(minor 3) 97 | endif() 98 | 99 | string(APPEND toolset ${major}${minor}) 100 | 101 | endif() 102 | 103 | else() 104 | 105 | if(toolset STREQUAL "gnu") 106 | 107 | set(toolset "gcc") 108 | 109 | elseif(toolset STREQUAL "clang") 110 | 111 | if(MSVC) 112 | set(toolset "clangw") 113 | endif() 114 | 115 | endif() 116 | 117 | if(CMAKE_CXX_COMPILER_VERSION MATCHES "^([0-9]+)[.]") 118 | string(APPEND toolset ${CMAKE_MATCH_1}) 119 | endif() 120 | 121 | endif() 122 | 123 | string(APPEND name_debug "-${toolset}") 124 | string(APPEND name_release "-${toolset}") 125 | 126 | endif() 127 | 128 | if(BOOST_INSTALL_LAYOUT STREQUAL versioned OR BOOST_INSTALL_LAYOUT STREQUAL tagged) 129 | 130 | # threading 131 | string(APPEND name_debug "-mt") 132 | string(APPEND name_release "-mt") 133 | 134 | # ABI tag 135 | 136 | if(MSVC) 137 | 138 | get_target_property(MSVC_RUNTIME_LIBRARY ${LIB} MSVC_RUNTIME_LIBRARY) 139 | 140 | if(MSVC_RUNTIME_LIBRARY STREQUAL "MultiThreaded$<$:Debug>") 141 | 142 | string(APPEND name_debug "-sgd") 143 | string(APPEND name_release "-s") 144 | 145 | else() 146 | 147 | string(APPEND name_debug "-gd") 148 | 149 | endif() 150 | 151 | else() 152 | 153 | string(APPEND name_debug "-d") 154 | 155 | endif() 156 | 157 | # Arch and model 158 | math(EXPR bits ${CMAKE_SIZEOF_VOID_P}*8) 159 | 160 | set(arch "x") 161 | 162 | if(MSVC) 163 | 164 | if(CMAKE_CXX_COMPILER_ARCHITECTURE_ID MATCHES "^ARM") 165 | set(arch "a") 166 | endif() 167 | 168 | else() 169 | 170 | if(CMAKE_SYSTEM_PROCESSOR MATCHES "(i[3-6]86|amd64|AMD64)") 171 | set(arch "x") 172 | else() 173 | string(SUBSTRING "${CMAKE_SYSTEM_PROCESSOR}" 0 1 arch) 174 | string(TOLOWER "${arch}" arch) 175 | endif() 176 | 177 | endif() 178 | 179 | string(APPEND name_debug "-${arch}${bits}") 180 | string(APPEND name_release "-${arch}${bits}") 181 | 182 | endif() 183 | 184 | if(BOOST_INSTALL_LAYOUT STREQUAL versioned) 185 | 186 | string(REGEX REPLACE "^([0-9]+)[.]([0-9]+).*" "\\1_\\2" __ver ${VERSION}) 187 | 188 | string(APPEND name_debug "-${__ver}") 189 | string(APPEND name_release "-${__ver}") 190 | 191 | endif() 192 | 193 | set_target_properties(${LIB} PROPERTIES OUTPUT_NAME_DEBUG ${name_debug}) 194 | set_target_properties(${LIB} PROPERTIES OUTPUT_NAME ${name_release}) 195 | 196 | if(TYPE STREQUAL "STATIC_LIBRARY") 197 | 198 | set_target_properties(${LIB} PROPERTIES COMPILE_PDB_NAME_DEBUG "${name_debug}") 199 | set_target_properties(${LIB} PROPERTIES COMPILE_PDB_NAME "${name_release}") 200 | 201 | endif() 202 | 203 | endfunction() 204 | 205 | function(__boost_install_update_include_directory lib incdir prop) 206 | 207 | get_target_property(value ${lib} ${prop}) 208 | 209 | if("${value}" STREQUAL "${incdir}" OR "${value}" STREQUAL "$") 210 | 211 | set_target_properties(${lib} PROPERTIES ${prop} "$;$") 212 | 213 | endif() 214 | 215 | endfunction() 216 | 217 | # Installs a single target 218 | # boost_install_target(TARGET target VERSION version [HEADER_DIRECTORY directory]) 219 | 220 | function(boost_install_target) 221 | 222 | cmake_parse_arguments(_ "" "TARGET;VERSION;HEADER_DIRECTORY" "" ${ARGN}) 223 | 224 | if(NOT __TARGET) 225 | 226 | message(SEND_ERROR "boost_install_target: TARGET not given.") 227 | return() 228 | 229 | endif() 230 | 231 | if(NOT __VERSION) 232 | 233 | message(SEND_ERROR "boost_install_target: VERSION not given, but is required for installation.") 234 | return() 235 | 236 | endif() 237 | 238 | set(LIB ${__TARGET}) 239 | 240 | if(NOT __HEADER_DIRECTORY) 241 | 242 | set(__HEADER_DIRECTORY "${PROJECT_SOURCE_DIR}/include") 243 | 244 | endif() 245 | 246 | get_target_property(TYPE ${LIB} TYPE) 247 | 248 | __boost_install_update_include_directory(${LIB} "${__HEADER_DIRECTORY}" INTERFACE_INCLUDE_DIRECTORIES) 249 | 250 | if(TYPE STREQUAL "STATIC_LIBRARY" OR TYPE STREQUAL "SHARED_LIBRARY") 251 | 252 | __boost_install_update_include_directory(${LIB} "${__HEADER_DIRECTORY}" INCLUDE_DIRECTORIES) 253 | 254 | get_target_property(OUTPUT_NAME ${LIB} OUTPUT_NAME) 255 | 256 | if(NOT OUTPUT_NAME) 257 | __boost_install_set_output_name(${LIB} ${TYPE} ${__VERSION}) 258 | endif() 259 | 260 | endif() 261 | 262 | if(TYPE STREQUAL "SHARED_LIBRARY" OR TYPE STREQUAL "EXECUTABLE") 263 | 264 | get_target_property(VERSION ${LIB} VERSION) 265 | 266 | if(NOT VERSION) 267 | set_target_properties(${LIB} PROPERTIES VERSION ${__VERSION}) 268 | endif() 269 | 270 | endif() 271 | 272 | if(LIB MATCHES "^boost_(.*)$") 273 | set_target_properties(${LIB} PROPERTIES EXPORT_NAME ${CMAKE_MATCH_1}) 274 | endif() 275 | 276 | if(BOOST_SKIP_INSTALL_RULES) 277 | 278 | boost_message(DEBUG "boost_install_target: not installing target '${__TARGET}' due to BOOST_SKIP_INSTALL_RULES=${BOOST_SKIP_INSTALL_RULES}") 279 | return() 280 | 281 | endif() 282 | 283 | if(CMAKE_SKIP_INSTALL_RULES) 284 | 285 | boost_message(DEBUG "boost_install_target: not installing target '${__TARGET}' due to CMAKE_SKIP_INSTALL_RULES=${CMAKE_SKIP_INSTALL_RULES}") 286 | return() 287 | 288 | endif() 289 | 290 | set(CONFIG_INSTALL_DIR "${BOOST_INSTALL_CMAKEDIR}/${LIB}-${__VERSION}") 291 | 292 | if(TYPE STREQUAL "SHARED_LIBRARY") 293 | string(APPEND CONFIG_INSTALL_DIR "-shared") 294 | endif() 295 | 296 | if(TYPE STREQUAL "STATIC_LIBRARY") 297 | string(APPEND CONFIG_INSTALL_DIR "-static") 298 | endif() 299 | 300 | install(TARGETS ${LIB} EXPORT ${LIB}-targets 301 | # explicit destination specification required for 3.13, 3.14 no longer needs it 302 | RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" 303 | LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" 304 | ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" 305 | PRIVATE_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" 306 | PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" 307 | ) 308 | 309 | export(TARGETS ${LIB} NAMESPACE Boost:: FILE export/${LIB}-targets.cmake) 310 | 311 | if(MSVC) 312 | if(TYPE STREQUAL "SHARED_LIBRARY") 313 | install(FILES $ DESTINATION ${CMAKE_INSTALL_BINDIR} OPTIONAL) 314 | endif() 315 | 316 | if(TYPE STREQUAL "STATIC_LIBRARY" AND NOT CMAKE_VERSION VERSION_LESS 3.15) 317 | install(FILES "$/$$.pdb" DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL) 318 | endif() 319 | endif() 320 | 321 | install(EXPORT ${LIB}-targets DESTINATION "${CONFIG_INSTALL_DIR}" NAMESPACE Boost:: FILE ${LIB}-targets.cmake) 322 | 323 | set_target_properties(${LIB} PROPERTIES _boost_is_installed ON) 324 | 325 | set(CONFIG_FILE_NAME "${CMAKE_CURRENT_BINARY_DIR}/tmpinst/${LIB}-config.cmake") 326 | set(CONFIG_FILE_CONTENTS "# Generated by BoostInstall.cmake for ${LIB}-${__VERSION}\n\n") 327 | 328 | string(APPEND CONFIG_FILE_CONTENTS "if(Boost_VERBOSE OR Boost_DEBUG)\n") 329 | string(APPEND CONFIG_FILE_CONTENTS " message(STATUS \"Found ${LIB} \${${LIB}_VERSION} at \${${LIB}_DIR}\")\n") 330 | string(APPEND CONFIG_FILE_CONTENTS "endif()\n\n") 331 | 332 | get_target_property(INTERFACE_LINK_LIBRARIES ${LIB} INTERFACE_LINK_LIBRARIES) 333 | 334 | set(LINK_LIBRARIES "") 335 | 336 | if(TYPE STREQUAL "STATIC_LIBRARY" OR TYPE STREQUAL "SHARED_LIBRARY") 337 | get_target_property(LINK_LIBRARIES ${LIB} LINK_LIBRARIES) 338 | endif() 339 | 340 | if(INTERFACE_LINK_LIBRARIES OR LINK_LIBRARIES) 341 | 342 | string(APPEND CONFIG_FILE_CONTENTS "include(CMakeFindDependencyMacro)\n\n") 343 | 344 | set(link_libraries ${INTERFACE_LINK_LIBRARIES} ${LINK_LIBRARIES}) 345 | list(REMOVE_DUPLICATES link_libraries) 346 | 347 | set(python_components "") 348 | set(icu_components "") 349 | 350 | foreach(dep IN LISTS link_libraries) 351 | 352 | if(dep MATCHES "^Boost::(.*)$") 353 | 354 | string(APPEND CONFIG_FILE_CONTENTS "if(NOT boost_${CMAKE_MATCH_1}_FOUND)\n") 355 | string(APPEND CONFIG_FILE_CONTENTS " find_dependency(boost_${CMAKE_MATCH_1} ${__VERSION} EXACT HINTS \"\${CMAKE_CURRENT_LIST_DIR}/..\")\n") 356 | string(APPEND CONFIG_FILE_CONTENTS "endif()\n") 357 | 358 | elseif(dep MATCHES "^\\$$") 359 | 360 | string(APPEND CONFIG_FILE_CONTENTS "if(NOT boost_${CMAKE_MATCH_1}_FOUND)\n") 361 | string(APPEND CONFIG_FILE_CONTENTS " find_package(boost_${CMAKE_MATCH_1} ${__VERSION} EXACT QUIET HINTS \"\${CMAKE_CURRENT_LIST_DIR}/..\")\n") 362 | string(APPEND CONFIG_FILE_CONTENTS "endif()\n") 363 | 364 | elseif(dep STREQUAL "Threads::Threads") 365 | 366 | string(APPEND CONFIG_FILE_CONTENTS "set(THREADS_PREFER_PTHREAD_FLAG ON)\n") 367 | string(APPEND CONFIG_FILE_CONTENTS "find_dependency(Threads)\n") 368 | 369 | elseif(dep STREQUAL "ZLIB::ZLIB") 370 | 371 | string(APPEND CONFIG_FILE_CONTENTS "find_dependency(ZLIB)\n") 372 | 373 | elseif(dep STREQUAL "BZip2::BZip2") 374 | 375 | string(APPEND CONFIG_FILE_CONTENTS "find_dependency(BZip2)\n") 376 | 377 | elseif(dep STREQUAL "LibLZMA::LibLZMA") 378 | 379 | string(APPEND CONFIG_FILE_CONTENTS "find_dependency(LibLZMA)\n") 380 | 381 | elseif(dep MATCHES "zstd::libzstd_(shared|static)") 382 | 383 | string(APPEND CONFIG_FILE_CONTENTS "find_dependency(zstd CONFIG)\n") 384 | 385 | elseif(dep STREQUAL "MPI::MPI_CXX") 386 | 387 | # COMPONENTS requires 3.9, but the imported target also requires 3.9 388 | string(APPEND CONFIG_FILE_CONTENTS "set(MPI_CXX_SKIP_MPICXX ON)\n") 389 | string(APPEND CONFIG_FILE_CONTENTS "find_dependency(MPI COMPONENTS CXX)\n") 390 | 391 | elseif(dep STREQUAL "Iconv::Iconv") 392 | 393 | string(APPEND CONFIG_FILE_CONTENTS "find_dependency(Iconv)\n") 394 | 395 | elseif(dep STREQUAL "Python::Module") 396 | 397 | string(APPEND python_components " Development") 398 | 399 | elseif(dep STREQUAL "Python::NumPy") 400 | 401 | string(APPEND python_components " NumPy") 402 | 403 | elseif(dep STREQUAL "ICU::data") 404 | 405 | string(APPEND icu_components " data") 406 | 407 | elseif(dep STREQUAL "ICU::i18n") 408 | 409 | string(APPEND icu_components " i18n") 410 | 411 | elseif(dep STREQUAL "ICU::uc") 412 | 413 | string(APPEND icu_components " uc") 414 | 415 | elseif (dep MATCHES "^OpenSSL::(.*)$") 416 | 417 | string(APPEND CONFIG_FILE_CONTENTS "find_dependency(OpenSSL)\n") 418 | 419 | endif() 420 | 421 | endforeach() 422 | 423 | if(python_components) 424 | 425 | string(APPEND CONFIG_FILE_CONTENTS "find_dependency(Python COMPONENTS ${python_components})\n") 426 | 427 | endif() 428 | 429 | if(icu_components) 430 | 431 | string(APPEND CONFIG_FILE_CONTENTS "find_dependency(ICU COMPONENTS ${icu_components})\n") 432 | 433 | endif() 434 | 435 | string(APPEND CONFIG_FILE_CONTENTS "\n") 436 | 437 | endif() 438 | 439 | string(APPEND CONFIG_FILE_CONTENTS "include(\"\${CMAKE_CURRENT_LIST_DIR}/${LIB}-targets.cmake\")\n") 440 | 441 | file(WRITE "${CONFIG_FILE_NAME}" "${CONFIG_FILE_CONTENTS}") 442 | install(FILES "${CONFIG_FILE_NAME}" DESTINATION "${CONFIG_INSTALL_DIR}") 443 | 444 | set(CONFIG_VERSION_FILE_NAME "${CMAKE_CURRENT_BINARY_DIR}/tmpinst/${LIB}-config-version.cmake") 445 | 446 | if(TYPE STREQUAL "INTERFACE_LIBRARY") 447 | 448 | # Header-only libraries are architecture-independent 449 | 450 | if(NOT CMAKE_VERSION VERSION_LESS 3.14) 451 | 452 | write_basic_package_version_file("${CONFIG_VERSION_FILE_NAME}" COMPATIBILITY SameMajorVersion ARCH_INDEPENDENT) 453 | 454 | else() 455 | 456 | set(OLD_CMAKE_SIZEOF_VOID_P ${CMAKE_SIZEOF_VOID_P}) 457 | set(CMAKE_SIZEOF_VOID_P "") 458 | 459 | write_basic_package_version_file("${CONFIG_VERSION_FILE_NAME}" COMPATIBILITY SameMajorVersion) 460 | 461 | set(CMAKE_SIZEOF_VOID_P ${OLD_CMAKE_SIZEOF_VOID_P}) 462 | 463 | endif() 464 | 465 | else() 466 | 467 | write_basic_package_version_file("${CONFIG_VERSION_FILE_NAME}" COMPATIBILITY SameMajorVersion) 468 | 469 | endif() 470 | 471 | if("${LIB}" STREQUAL "boost_exception" OR "${LIB}" STREQUAL "boost_test_exec_monitor") 472 | 473 | # These two libraries are hardcoded to STATIC 474 | 475 | else() 476 | 477 | if(TYPE STREQUAL "SHARED_LIBRARY") 478 | 479 | file(APPEND "${CONFIG_VERSION_FILE_NAME}" 480 | 481 | "\n" 482 | "# Do not return shared libraries when Boost_USE_STATIC_LIBS is ON\n" 483 | "if(NOT PACKAGE_VERSION_UNSUITABLE AND Boost_USE_STATIC_LIBS)\n" 484 | " set(PACKAGE_VERSION_UNSUITABLE TRUE)\n" 485 | " set(PACKAGE_VERSION \"\${PACKAGE_VERSION} (shared)\")\n" 486 | " return()\n" 487 | "endif()\n" 488 | ) 489 | 490 | endif() 491 | 492 | if(TYPE STREQUAL "STATIC_LIBRARY") 493 | 494 | file(APPEND "${CONFIG_VERSION_FILE_NAME}" 495 | 496 | "\n" 497 | "# Do not return static libraries when Boost_USE_STATIC_LIBS is OFF\n" 498 | "if(NOT PACKAGE_VERSION_UNSUITABLE AND DEFINED Boost_USE_STATIC_LIBS AND NOT Boost_USE_STATIC_LIBS)\n" 499 | " set(PACKAGE_VERSION_UNSUITABLE TRUE)\n" 500 | " set(PACKAGE_VERSION \"\${PACKAGE_VERSION} (static)\")\n" 501 | " return()\n" 502 | "endif()\n" 503 | ) 504 | 505 | endif() 506 | 507 | endif() 508 | 509 | install(FILES "${CONFIG_VERSION_FILE_NAME}" DESTINATION "${CONFIG_INSTALL_DIR}") 510 | 511 | endfunction() 512 | 513 | # boost_install([VERSION version] [TARGETS targets...] [HEADER_DIRECTORY directory]) 514 | 515 | function(boost_install) 516 | 517 | cmake_parse_arguments(_ "" "VERSION;HEADER_DIRECTORY" "TARGETS" ${ARGN}) 518 | 519 | if(NOT __VERSION) 520 | 521 | if(NOT PROJECT_VERSION) 522 | 523 | message(AUTHOR_WARNING "boost_install: VERSION not given, PROJECT_VERSION not set, but a version is required for installation.") 524 | return() 525 | 526 | else() 527 | 528 | boost_message(DEBUG "boost_install: VERSION not given, assuming PROJECT_VERSION ('${PROJECT_VERSION}')") 529 | set(__VERSION ${PROJECT_VERSION}) 530 | 531 | endif() 532 | 533 | endif() 534 | 535 | if(__UNPARSED_ARGUMENTS) 536 | 537 | message(AUTHOR_WARNING "boost_install: extra arguments ignored: ${__UNPARSED_ARGUMENTS}") 538 | 539 | endif() 540 | 541 | if(__HEADER_DIRECTORY AND NOT BOOST_SKIP_INSTALL_RULES AND NOT CMAKE_SKIP_INSTALL_RULES) 542 | 543 | get_filename_component(__HEADER_DIRECTORY "${__HEADER_DIRECTORY}" ABSOLUTE) 544 | install(DIRECTORY "${__HEADER_DIRECTORY}/" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") 545 | 546 | endif() 547 | 548 | foreach(target IN LISTS __TARGETS) 549 | 550 | boost_install_target(TARGET ${target} VERSION ${__VERSION} HEADER_DIRECTORY ${__HEADER_DIRECTORY}) 551 | 552 | endforeach() 553 | 554 | endfunction() 555 | -------------------------------------------------------------------------------- /include/BoostMessage.cmake: -------------------------------------------------------------------------------- 1 | # Copyright 2019 Peter Dimov 2 | # Distributed under the Boost Software License, Version 1.0. 3 | # See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt 4 | 5 | if(NOT CMAKE_VERSION VERSION_LESS 3.10) 6 | include_guard() 7 | endif() 8 | 9 | # boost_message( 10 | # [FATAL_ERROR|SEND_ERROR|WARNING|AUTHOR_WARNING|DEPRECATION|NOTICE|STATUS 11 | # |VERBOSE|DEBUG] 12 | # messages...) 13 | 14 | function(boost_message type) 15 | 16 | if(type STREQUAL "VERBOSE") 17 | if(Boost_VERBOSE OR Boost_DEBUG) 18 | set(type STATUS) 19 | elseif(CMAKE_VERSION VERSION_LESS 3.15) 20 | return() 21 | endif() 22 | endif() 23 | 24 | if(type STREQUAL "DEBUG") 25 | if(Boost_DEBUG) 26 | set(type STATUS) 27 | elseif(CMAKE_VERSION VERSION_LESS 3.15) 28 | return() 29 | endif() 30 | endif() 31 | 32 | if(type STREQUAL "NOTICE" AND CMAKE_VERSION VERSION_LESS 3.15) 33 | set(type "") 34 | endif() 35 | 36 | set(m "") 37 | math(EXPR last "${ARGC}-1") 38 | 39 | foreach(i RANGE 1 ${last}) 40 | string(APPEND m "${ARGV${i}}") 41 | endforeach() 42 | 43 | message(${type} "${m}") 44 | 45 | endfunction() 46 | -------------------------------------------------------------------------------- /include/BoostRoot.cmake: -------------------------------------------------------------------------------- 1 | # Copyright 2019-2023 Peter Dimov 2 | # Copyright 2025 Alexander Grund 3 | # Distributed under the Boost Software License, Version 1.0. 4 | # See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt 5 | 6 | if(CMAKE_SOURCE_DIR STREQUAL Boost_SOURCE_DIR AND WIN32 AND CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) 7 | 8 | set(CMAKE_INSTALL_PREFIX "C:/Boost" CACHE PATH "Installation path prefix, prepended to installation directories" FORCE) 9 | 10 | endif() 11 | 12 | include(BoostMessage) 13 | include(BoostInstall) 14 | 15 | # 16 | 17 | if(CMAKE_SOURCE_DIR STREQUAL Boost_SOURCE_DIR) 18 | boost_message(STATUS "Boost: using CMake ${CMAKE_VERSION}") 19 | else() 20 | boost_message(VERBOSE "Boost: using CMake ${CMAKE_VERSION}") 21 | endif() 22 | 23 | # 24 | 25 | set(__boost_incompatible_libraries "") 26 | 27 | # Define cache variables if root project 28 | 29 | if(CMAKE_SOURCE_DIR STREQUAL Boost_SOURCE_DIR) 30 | 31 | # --with- 32 | set(BOOST_INCLUDE_LIBRARIES "" CACHE STRING 33 | "List of libraries to build (default: all but excluded and incompatible)") 34 | 35 | # --without- 36 | set(BOOST_EXCLUDE_LIBRARIES "" CACHE STRING 37 | "List of libraries to exclude from build") 38 | 39 | set(BOOST_INCOMPATIBLE_LIBRARIES 40 | "${__boost_incompatible_libraries}" 41 | CACHE STRING 42 | "List of libraries with incompatible CMakeLists.txt files") 43 | 44 | option(BOOST_ENABLE_MPI 45 | "Build and enable installation of Boost.MPI and its dependents (requires MPI, CMake 3.10)") 46 | 47 | option(BOOST_ENABLE_PYTHON 48 | "Build and enable installation of Boost.Python and its dependents (requires Python, CMake 3.14)") 49 | 50 | # --layout, --libdir, --cmakedir, --includedir in BoostInstall 51 | 52 | # runtime-link=static|shared 53 | 54 | set(BOOST_RUNTIME_LINK shared CACHE STRING "Runtime library selection for the MS ABI (shared or static)") 55 | set_property(CACHE BOOST_RUNTIME_LINK PROPERTY STRINGS shared static) 56 | 57 | option(BUILD_TESTING "Build the tests." OFF) 58 | include(CTest) 59 | 60 | if(NOT TARGET tests) 61 | add_custom_target(tests) 62 | endif() 63 | 64 | add_custom_target(check VERBATIM COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure --no-tests=error -C $) 65 | add_dependencies(check tests) 66 | 67 | if(NOT TARGET tests-quick) 68 | add_custom_target(tests-quick) 69 | endif() 70 | 71 | add_custom_target(check-quick VERBATIM COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure --no-tests=error -C $ -R quick) 72 | add_dependencies(check-quick tests-quick) 73 | 74 | # link=static|shared 75 | option(BUILD_SHARED_LIBS "Build shared libraries") 76 | 77 | # --stagedir 78 | set(BOOST_STAGEDIR "${CMAKE_CURRENT_BINARY_DIR}/stage" CACHE STRING "Build output directory") 79 | 80 | if(NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY) 81 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${BOOST_STAGEDIR}/bin") 82 | endif() 83 | 84 | if(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY) 85 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${BOOST_STAGEDIR}/lib") 86 | endif() 87 | 88 | if(NOT CMAKE_ARCHIVE_OUTPUT_DIRECTORY) 89 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${BOOST_STAGEDIR}/lib") 90 | endif() 91 | 92 | # Set default visibility to hidden to match b2 93 | 94 | set(CMAKE_C_VISIBILITY_PRESET hidden CACHE STRING "Symbol visibility for C") 95 | set_property(CACHE CMAKE_C_VISIBILITY_PRESET PROPERTY STRINGS default hidden protected internal) 96 | 97 | set(CMAKE_CXX_VISIBILITY_PRESET hidden CACHE STRING "Symbol visibility for C++") 98 | set_property(CACHE CMAKE_CXX_VISIBILITY_PRESET PROPERTY STRINGS default hidden protected internal) 99 | 100 | option(CMAKE_VISIBILITY_INLINES_HIDDEN "Inline function have hidden visibility" ON) 101 | 102 | # Enable IDE folders for Visual Studio 103 | 104 | set_property(GLOBAL PROPERTY USE_FOLDERS ON) 105 | 106 | else() 107 | 108 | # add_subdirectory use 109 | 110 | if(NOT DEFINED BOOST_INCOMPATIBLE_LIBRARIES) 111 | set(BOOST_INCOMPATIBLE_LIBRARIES ${__boost_incompatible_libraries}) 112 | endif() 113 | 114 | if(NOT DEFINED BOOST_ENABLE_MPI) 115 | set(BOOST_ENABLE_MPI OFF) 116 | endif() 117 | 118 | if(NOT DEFINED BOOST_ENABLE_PYTHON) 119 | set(BOOST_ENABLE_PYTHON OFF) 120 | endif() 121 | 122 | if(NOT DEFINED BOOST_SKIP_INSTALL_RULES) 123 | set(BOOST_SKIP_INSTALL_RULES ON) 124 | endif() 125 | 126 | set(BUILD_TESTING OFF) 127 | 128 | endif() 129 | 130 | if(NOT CMAKE_MSVC_RUNTIME_LIBRARY) 131 | 132 | set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") 133 | 134 | if(NOT BOOST_RUNTIME_LINK STREQUAL "static") 135 | string(APPEND CMAKE_MSVC_RUNTIME_LIBRARY "DLL") 136 | endif() 137 | 138 | endif() 139 | 140 | # Output configuration status lines 141 | 142 | set(_msg "") 143 | 144 | if(NOT CMAKE_CONFIGURATION_TYPES AND CMAKE_BUILD_TYPE) 145 | string(APPEND _msg "${CMAKE_BUILD_TYPE} build, ") 146 | endif() 147 | 148 | if(BUILD_SHARED_LIBS) 149 | string(APPEND _msg "shared libraries, ") 150 | else() 151 | string(APPEND _msg "static libraries, ") 152 | endif() 153 | 154 | if(MSVC) 155 | if(CMAKE_MSVC_RUNTIME_LIBRARY STREQUAL "MultiThreaded$<$:Debug>") 156 | string(APPEND _msg "static runtime, ") 157 | elseif(CMAKE_MSVC_RUNTIME_LIBRARY STREQUAL "MultiThreaded$<$:Debug>DLL") 158 | string(APPEND _msg "shared runtime, ") 159 | endif() 160 | endif() 161 | 162 | string(APPEND _msg "MPI ${BOOST_ENABLE_MPI}, Python ${BOOST_ENABLE_PYTHON}, testing ${BUILD_TESTING}") 163 | 164 | message(STATUS "Boost: ${_msg}") 165 | 166 | unset(_msg) 167 | 168 | if(BOOST_INCLUDE_LIBRARIES) 169 | message(STATUS "Boost: libraries included: ${BOOST_INCLUDE_LIBRARIES}") 170 | endif() 171 | 172 | if(BOOST_EXCLUDE_LIBRARIES) 173 | message(STATUS "Boost: libraries excluded: ${BOOST_EXCLUDE_LIBRARIES}") 174 | endif() 175 | 176 | # Define functions 177 | 178 | function(__boost_auto_install __boost_lib) 179 | if(NOT CMAKE_VERSION VERSION_LESS 3.13) 180 | 181 | string(MAKE_C_IDENTIFIER "${__boost_lib}" __boost_lib_target) 182 | 183 | if(TARGET "Boost::${__boost_lib_target}" AND TARGET "boost_${__boost_lib_target}") 184 | 185 | get_target_property(is_installed "boost_${__boost_lib_target}" _boost_is_installed) 186 | if(is_installed) 187 | return() # Ignore libraries for which boost_install was already called 188 | endif() 189 | 190 | get_target_property(__boost_lib_incdir "boost_${__boost_lib_target}" INTERFACE_INCLUDE_DIRECTORIES) 191 | 192 | set(incdir "${BOOST_SUPERPROJECT_SOURCE_DIR}/libs/${__boost_lib}/include") 193 | 194 | if("${__boost_lib_incdir}" STREQUAL "${incdir}" OR "${__boost_lib_incdir}" STREQUAL "$") 195 | 196 | boost_message(DEBUG "Enabling installation for '${__boost_lib}'") 197 | boost_install(TARGETS "boost_${__boost_lib_target}" VERSION "${BOOST_SUPERPROJECT_VERSION}" HEADER_DIRECTORY "${incdir}") 198 | 199 | else() 200 | boost_message(DEBUG "Not enabling installation for '${__boost_lib}'; interface include directory '${__boost_lib_incdir}' does not equal '${incdir}' or '$'") 201 | endif() 202 | 203 | else() 204 | boost_message(DEBUG "Not enabling installation for '${__boost_lib}'; targets 'Boost::${__boost_lib_target}' and 'boost_${__boost_lib_target}' weren't found") 205 | endif() 206 | 207 | endif() 208 | endfunction() 209 | 210 | function(__boost_scan_dependencies lib var sub_folder) 211 | 212 | # Libraries that define at least one library with a name like "_" 213 | set(prefix_names "asio" "dll" "fiber" "log" "regex" "stacktrace") 214 | set(result "") 215 | 216 | set(cml_files "${BOOST_SUPERPROJECT_SOURCE_DIR}/libs/${lib}") 217 | if(sub_folder) 218 | file(GLOB_RECURSE cml_files "${cml_files}/${sub_folder}/CMakeLists.txt") 219 | else() 220 | string(APPEND cml_files "/CMakeLists.txt") 221 | endif() 222 | 223 | foreach(cml_file IN LISTS cml_files) 224 | if(NOT EXISTS "${cml_file}") 225 | CONTINUE() 226 | endif() 227 | set(libs_to_exclude "") 228 | 229 | file(STRINGS "${cml_file}" data) 230 | 231 | foreach(line IN LISTS data) 232 | if(line MATCHES "^ *# *Boost-(Include|Exclude):? *(.*)$") 233 | set(type ${CMAKE_MATCH_1}) 234 | set(line ${CMAKE_MATCH_2}) 235 | else() 236 | set(type "Include") 237 | endif() 238 | if(line MATCHES "^([^#]*Boost::[A-Za-z0-9_]+[^#]*)(#.*)?$") 239 | string(REGEX MATCHALL "Boost::[A-Za-z0-9_]+" libs "${CMAKE_MATCH_1}") 240 | 241 | foreach(dep IN LISTS libs) 242 | string(REGEX REPLACE "^Boost::" "" dep ${dep}) 243 | if(dep STREQUAL "headers" OR dep STREQUAL "boost" OR dep MATCHES "linking") 244 | continue() 245 | endif() 246 | if(dep MATCHES "unit_test_framework|prg_exec_monitor|test_exec_monitor") 247 | set(dep "test") 248 | elseif(dep STREQUAL "numpy") 249 | set(dep "python") 250 | elseif(dep MATCHES "serialization") 251 | set(dep "serialization") 252 | else() 253 | string(REGEX REPLACE "^numeric_" "numeric/" dep ${dep}) 254 | foreach(prefix IN LISTS prefix_names) 255 | if(dep MATCHES "^${prefix}_") 256 | set(dep ${prefix}) 257 | break() 258 | endif() 259 | endforeach() 260 | endif() 261 | if(NOT dep STREQUAL lib) 262 | if(type STREQUAL "Exclude") 263 | list(APPEND libs_to_exclude ${dep}) 264 | else() 265 | list(APPEND result ${dep}) 266 | endif() 267 | endif() 268 | endforeach() 269 | 270 | endif() 271 | 272 | endforeach() 273 | 274 | endforeach() 275 | 276 | if(libs_to_exclude) 277 | list(REMOVE_ITEM result ${libs_to_exclude}) 278 | endif() 279 | list(REMOVE_DUPLICATES result) 280 | set(${var} ${result} PARENT_SCOPE) 281 | 282 | endfunction() 283 | 284 | macro(__boost_add_header_only lib) 285 | 286 | if(TARGET "boost_${lib}" AND TARGET "Boost::${lib}") 287 | 288 | get_target_property(__boost_lib_type "boost_${lib}" TYPE) 289 | 290 | if(__boost_lib_type STREQUAL "INTERFACE_LIBRARY") 291 | 292 | list(APPEND __boost_header_only "Boost::${lib}") 293 | 294 | endif() 295 | 296 | set(__boost_lib_type) 297 | endif() 298 | 299 | endmacro() 300 | 301 | # 302 | 303 | file(GLOB __boost_libraries RELATIVE "${BOOST_SUPERPROJECT_SOURCE_DIR}/libs" "${BOOST_SUPERPROJECT_SOURCE_DIR}/libs/*/CMakeLists.txt" "${BOOST_SUPERPROJECT_SOURCE_DIR}/libs/numeric/*/CMakeLists.txt") 304 | 305 | # Check for mistakes in BOOST_INCLUDE_LIBRARIES 306 | if(BOOST_INCLUDE_LIBRARIES) 307 | set(__boost_any_library_found OFF) 308 | foreach(__boost_included_lib IN LISTS BOOST_INCLUDE_LIBRARIES) 309 | 310 | if(NOT "${__boost_included_lib}/CMakeLists.txt" IN_LIST __boost_libraries) 311 | 312 | message(WARNING "Library '${__boost_included_lib}' given in BOOST_INCLUDE_LIBRARIES has not been found.") 313 | 314 | else() 315 | set(__boost_any_library_found ON) 316 | endif() 317 | 318 | endforeach() 319 | if(NOT __boost_any_library_found) 320 | message(FATAL_ERROR "None of the libraries given in BOOST_INCLUDE_LIBRARIES has been found so no libraries would be build. Verify BOOST_INCLUDE_LIBRARIES (${BOOST_INCLUDE_LIBRARIES})") 321 | endif() 322 | endif() 323 | 324 | # Scan for dependencies 325 | 326 | function(__boost_gather_dependencies var input_list with_test) 327 | set(result "") 328 | 329 | set(libs_to_scan ${input_list}) 330 | while(libs_to_scan) 331 | 332 | boost_message(DEBUG "Scanning dependencies: ${libs_to_scan}") 333 | 334 | set(cur_dependencies "") 335 | 336 | foreach(lib IN LISTS libs_to_scan) 337 | 338 | __boost_scan_dependencies(${lib} new_deps "") 339 | list(APPEND cur_dependencies ${new_deps}) 340 | # Only consider test dependencies of the input libraries, not transitively as those tests aren't build 341 | if(with_test AND lib IN_LIST input_list) 342 | __boost_scan_dependencies(${lib} new_deps "test") 343 | list(APPEND cur_dependencies ${new_deps}) 344 | __boost_scan_dependencies(${lib} new_deps "example") 345 | list(APPEND cur_dependencies ${new_deps}) 346 | endif() 347 | 348 | endforeach() 349 | 350 | list(REMOVE_DUPLICATES cur_dependencies) 351 | 352 | if(cur_dependencies) 353 | list(REMOVE_ITEM cur_dependencies ${libs_to_scan} ${result}) 354 | list(APPEND result ${cur_dependencies}) 355 | endif() 356 | 357 | set(libs_to_scan ${cur_dependencies}) 358 | 359 | endwhile() 360 | 361 | list(REMOVE_ITEM result ${input_list}) 362 | set(${var} ${result} PARENT_SCOPE) 363 | endfunction() 364 | 365 | if(BOOST_INCLUDE_LIBRARIES) 366 | list(REMOVE_DUPLICATES BOOST_INCLUDE_LIBRARIES) 367 | __boost_gather_dependencies(__boost_dependencies "${BOOST_INCLUDE_LIBRARIES}" OFF) 368 | if(BUILD_TESTING) 369 | __boost_gather_dependencies(__boost_test_dependencies "${BOOST_INCLUDE_LIBRARIES}" ON) 370 | if(__boost_dependencies) 371 | list(REMOVE_ITEM __boost_test_dependencies ${__boost_dependencies}) 372 | endif() 373 | endif() 374 | else() 375 | set(__boost_dependencies "") 376 | set(__boost_test_dependencies "") 377 | endif() 378 | 379 | # Installing targets created in other directories requires CMake 3.13 380 | if(CMAKE_VERSION VERSION_LESS 3.13) 381 | 382 | boost_message(STATUS "Boost installation support requires CMake 3.13 (have ${CMAKE_VERSION})") 383 | 384 | endif() 385 | 386 | set(__boost_mpi_libs mpi graph_parallel property_map_parallel) 387 | set(__boost_python_libs python parameter_python) 388 | 389 | set(__boost_header_only "") 390 | 391 | foreach(__boost_lib_cml IN LISTS __boost_libraries) 392 | 393 | get_filename_component(__boost_lib "${__boost_lib_cml}" DIRECTORY) 394 | 395 | if(__boost_lib IN_LIST BOOST_INCOMPATIBLE_LIBRARIES) 396 | 397 | boost_message(DEBUG "Skipping incompatible Boost library ${__boost_lib}") 398 | 399 | elseif(__boost_lib IN_LIST BOOST_EXCLUDE_LIBRARIES) 400 | 401 | boost_message(DEBUG "Skipping excluded Boost library ${__boost_lib}") 402 | 403 | elseif(NOT BOOST_ENABLE_MPI AND __boost_lib IN_LIST __boost_mpi_libs) 404 | 405 | boost_message(DEBUG "Skipping Boost library ${__boost_lib}, BOOST_ENABLE_MPI is OFF") 406 | 407 | elseif(NOT BOOST_ENABLE_PYTHON AND __boost_lib IN_LIST __boost_python_libs) 408 | 409 | boost_message(DEBUG "Skipping Boost library ${__boost_lib}, BOOST_ENABLE_PYTHON is OFF") 410 | 411 | elseif(NOT BOOST_INCLUDE_LIBRARIES OR __boost_lib IN_LIST BOOST_INCLUDE_LIBRARIES) 412 | 413 | boost_message(VERBOSE "Adding Boost library ${__boost_lib}") 414 | add_subdirectory(libs/${__boost_lib}) 415 | 416 | __boost_auto_install(${__boost_lib}) 417 | __boost_add_header_only(${__boost_lib}) 418 | 419 | elseif(__boost_lib IN_LIST __boost_dependencies OR __boost_lib STREQUAL "headers") 420 | 421 | # Disable tests for dependencies 422 | 423 | set(__boost_build_testing ${BUILD_TESTING}) 424 | set(BUILD_TESTING OFF) # hide cache variable 425 | 426 | set(__boost_cmake_folder ${CMAKE_FOLDER}) 427 | 428 | if("${CMAKE_FOLDER}" STREQUAL "") 429 | set(CMAKE_FOLDER "Dependencies") 430 | endif() 431 | 432 | boost_message(VERBOSE "Adding Boost dependency ${__boost_lib}") 433 | add_subdirectory(libs/${__boost_lib}) 434 | 435 | __boost_auto_install(${__boost_lib}) 436 | __boost_add_header_only(${__boost_lib}) 437 | 438 | set(BUILD_TESTING ${__boost_build_testing}) 439 | set(CMAKE_FOLDER ${__boost_cmake_folder}) 440 | 441 | elseif(__boost_lib IN_LIST __boost_test_dependencies) 442 | 443 | # Disable tests and installation for libraries not included but used as test dependencies 444 | 445 | set(__boost_build_testing ${BUILD_TESTING}) 446 | set(BUILD_TESTING OFF) # hide cache variable 447 | 448 | set(__boost_skip_install ${BOOST_SKIP_INSTALL_RULES}) 449 | set(BOOST_SKIP_INSTALL_RULES ON) 450 | 451 | set(__boost_cmake_folder ${CMAKE_FOLDER}) 452 | 453 | if("${CMAKE_FOLDER}" STREQUAL "") 454 | set(CMAKE_FOLDER "Test Dependencies") 455 | endif() 456 | 457 | boost_message(DEBUG "Adding Boost test dependency ${__boost_lib} with EXCLUDE_FROM_ALL") 458 | add_subdirectory(libs/${__boost_lib} EXCLUDE_FROM_ALL) 459 | 460 | set(BUILD_TESTING ${__boost_build_testing}) 461 | set(BOOST_SKIP_INSTALL_RULES ${__boost_skip_install}) 462 | set(CMAKE_FOLDER ${__boost_cmake_folder}) 463 | 464 | endif() 465 | 466 | endforeach() 467 | 468 | # Compatibility targets for use with add_subdirectory/FetchContent 469 | 470 | if(BOOST_ENABLE_COMPATIBILITY_TARGETS) 471 | 472 | # Boost::headers 473 | 474 | list(REMOVE_ITEM __boost_header_only Boost::headers) 475 | target_link_libraries(boost_headers INTERFACE ${__boost_header_only}) 476 | 477 | # Boost::boost 478 | 479 | add_library(boost_comptarget_boost INTERFACE) 480 | add_library(Boost::boost ALIAS boost_comptarget_boost) 481 | target_link_libraries(boost_comptarget_boost INTERFACE Boost::headers) 482 | 483 | # Boost::diagnostic_definitions 484 | 485 | add_library(boost_comptarget_diagnostic_definitions INTERFACE) 486 | add_library(Boost::diagnostic_definitions ALIAS boost_comptarget_diagnostic_definitions) 487 | target_compile_definitions(boost_comptarget_diagnostic_definitions INTERFACE BOOST_LIB_DIAGNOSTIC) 488 | 489 | # Boost::disable_autolinking 490 | 491 | add_library(boost_comptarget_disable_autolinking INTERFACE) 492 | add_library(Boost::disable_autolinking ALIAS boost_comptarget_disable_autolinking) 493 | target_compile_definitions(boost_comptarget_disable_autolinking INTERFACE BOOST_ALL_NO_LIB) 494 | 495 | # Boost::dynamic_linking 496 | 497 | add_library(boost_comptarget_dynamic_linking INTERFACE) 498 | add_library(Boost::dynamic_linking ALIAS boost_comptarget_dynamic_linking) 499 | target_compile_definitions(boost_comptarget_dynamic_linking INTERFACE BOOST_ALL_DYN_LINK) 500 | 501 | endif() 502 | 503 | # Install BoostConfig.cmake 504 | 505 | if(BOOST_SKIP_INSTALL_RULES) 506 | 507 | boost_message(DEBUG "Boost: not installing BoostConfig.cmake due to BOOST_SKIP_INSTALL_RULES=${BOOST_SKIP_INSTALL_RULES}") 508 | return() 509 | 510 | endif() 511 | 512 | if(CMAKE_SKIP_INSTALL_RULES) 513 | 514 | boost_message(DEBUG "Boost: not installing BoostConfig.cmake due to CMAKE_SKIP_INSTALL_RULES=${CMAKE_SKIP_INSTALL_RULES}") 515 | return() 516 | 517 | endif() 518 | 519 | set(CONFIG_INSTALL_DIR "${BOOST_INSTALL_CMAKEDIR}/Boost-${BOOST_SUPERPROJECT_VERSION}") 520 | set(CONFIG_FILE_NAME "${CMAKE_CURRENT_LIST_DIR}/../config/BoostConfig.cmake") 521 | 522 | install(FILES "${CONFIG_FILE_NAME}" DESTINATION "${CONFIG_INSTALL_DIR}") 523 | 524 | set(CONFIG_VERSION_FILE_NAME "${CMAKE_CURRENT_BINARY_DIR}/tmpinst/BoostConfigVersion.cmake") 525 | 526 | if(NOT CMAKE_VERSION VERSION_LESS 3.14) 527 | 528 | write_basic_package_version_file("${CONFIG_VERSION_FILE_NAME}" COMPATIBILITY SameMajorVersion ARCH_INDEPENDENT) 529 | 530 | else() 531 | 532 | set(OLD_CMAKE_SIZEOF_VOID_P ${CMAKE_SIZEOF_VOID_P}) 533 | set(CMAKE_SIZEOF_VOID_P "") 534 | 535 | write_basic_package_version_file("${CONFIG_VERSION_FILE_NAME}" COMPATIBILITY SameMajorVersion) 536 | 537 | set(CMAKE_SIZEOF_VOID_P ${OLD_CMAKE_SIZEOF_VOID_P}) 538 | 539 | endif() 540 | 541 | install(FILES "${CONFIG_VERSION_FILE_NAME}" DESTINATION "${CONFIG_INSTALL_DIR}") 542 | 543 | set(CPACK_PACKAGE_VENDOR "Boost") 544 | set(CPACK_GENERATOR "TGZ") 545 | set(CPACK_RESOURCE_FILE_LICENSE "${Boost_SOURCE_DIR}/LICENSE_1_0.txt") 546 | set(CPACK_RESOURCE_FILE_README "${Boost_SOURCE_DIR}/README.md") 547 | include(CPack) 548 | -------------------------------------------------------------------------------- /include/BoostTest.cmake: -------------------------------------------------------------------------------- 1 | # Copyright 2018-2023 Peter Dimov 2 | # Distributed under the Boost Software License, Version 1.0. 3 | # See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt 4 | 5 | # Clear global variables on each `include(BoostTest)` 6 | 7 | set(BOOST_TEST_LINK_LIBRARIES "") 8 | set(BOOST_TEST_COMPILE_DEFINITIONS "") 9 | set(BOOST_TEST_COMPILE_OPTIONS "") 10 | set(BOOST_TEST_COMPILE_FEATURES "") 11 | set(BOOST_TEST_INCLUDE_DIRECTORIES "") 12 | set(BOOST_TEST_SOURCES "") 13 | set(BOOST_TEST_WORKING_DIRECTORY "") 14 | set(BOOST_TEST_PREFIX "") 15 | 16 | # Include guard 17 | 18 | if(NOT CMAKE_VERSION VERSION_LESS 3.10) 19 | include_guard() 20 | endif() 21 | 22 | include(BoostMessage) 23 | 24 | # Private helper functions 25 | 26 | function(__boost_test_list_replace list what with) 27 | 28 | set(result "") 29 | 30 | foreach(x IN LISTS ${list}) 31 | 32 | if(x STREQUAL what) 33 | set(x ${with}) 34 | endif() 35 | 36 | list(APPEND result ${x}) 37 | 38 | endforeach() 39 | 40 | set(${list} ${result} PARENT_SCOPE) 41 | 42 | endfunction() 43 | 44 | # boost_test( [TYPE type] [PREFIX prefix] [NAME name] [WORKING_DIRECTORY wd] [IGNORE_TEST_GLOBALS] 45 | # SOURCES sources... 46 | # ARGUMENTS args... 47 | # LINK_LIBRARIES libs... 48 | # COMPILE_DEFINITIONS defs... 49 | # COMPILE_OPTIONS opts... 50 | # COMPILE_FEATURES features... 51 | # INCLUDE_DIRECTORIES dirs... 52 | # ) 53 | 54 | function(boost_test) 55 | 56 | cmake_parse_arguments(_ 57 | "IGNORE_TEST_GLOBALS" 58 | "TYPE;PREFIX;NAME;WORKING_DIRECTORY" 59 | "SOURCES;ARGUMENTS;LIBRARIES;LINK_LIBRARIES;COMPILE_DEFINITIONS;COMPILE_OPTIONS;COMPILE_FEATURES;INCLUDE_DIRECTORIES" 60 | ${ARGN}) 61 | 62 | if(NOT __TYPE) 63 | set(__TYPE run) 64 | endif() 65 | 66 | if(NOT __NAME) 67 | list(GET __SOURCES 0 __NAME) 68 | get_filename_component(__NAME ${__NAME} NAME_WE) 69 | string(MAKE_C_IDENTIFIER ${__NAME} __NAME) 70 | endif() 71 | 72 | if(__UNPARSED_ARGUMENTS) 73 | message(AUTHOR_WARNING "Extra arguments for test '${__NAME}' ignored: ${__UNPARSED_ARGUMENTS}") 74 | endif() 75 | 76 | if(__LIBRARIES) 77 | boost_message(VERBOSE "Test '${__NAME}' uses deprecated parameter LIBRARIES; use LINK_LIBRARIES") 78 | endif() 79 | 80 | if(DEFINED BUILD_TESTING AND NOT BUILD_TESTING) 81 | return() 82 | endif() 83 | 84 | if(__IGNORE_TEST_GLOBALS) 85 | 86 | set(BOOST_TEST_LINK_LIBRARIES "") 87 | set(BOOST_TEST_COMPILE_DEFINITIONS "") 88 | set(BOOST_TEST_COMPILE_OPTIONS "") 89 | set(BOOST_TEST_COMPILE_FEATURES "") 90 | set(BOOST_TEST_INCLUDE_DIRECTORIES "") 91 | set(BOOST_TEST_SOURCES "") 92 | set(BOOST_TEST_WORKING_DIRECTORY "") 93 | set(BOOST_TEST_PREFIX "") 94 | 95 | endif() 96 | 97 | list(APPEND BOOST_TEST_LINK_LIBRARIES ${__LIBRARIES} ${__LINK_LIBRARIES}) 98 | list(APPEND BOOST_TEST_COMPILE_DEFINITIONS ${__COMPILE_DEFINITIONS}) 99 | list(APPEND BOOST_TEST_COMPILE_OPTIONS ${__COMPILE_OPTIONS}) 100 | list(APPEND BOOST_TEST_COMPILE_FEATURES ${__COMPILE_FEATURES}) 101 | list(APPEND BOOST_TEST_INCLUDE_DIRECTORIES ${__INCLUDE_DIRECTORIES}) 102 | list(APPEND BOOST_TEST_SOURCES ${__SOURCES}) 103 | 104 | if(__WORKING_DIRECTORY) 105 | set(BOOST_TEST_WORKING_DIRECTORY ${__WORKING_DIRECTORY}) 106 | endif() 107 | 108 | if(__PREFIX) 109 | set(BOOST_TEST_PREFIX ${__PREFIX}) 110 | endif() 111 | 112 | if(NOT BOOST_TEST_PREFIX) 113 | set(BOOST_TEST_PREFIX ${PROJECT_NAME}) 114 | endif() 115 | 116 | set(__NAME ${BOOST_TEST_PREFIX}-${__NAME}) 117 | 118 | if(MSVC) 119 | 120 | __boost_test_list_replace(BOOST_TEST_COMPILE_OPTIONS "-fexceptions" "/GX") 121 | __boost_test_list_replace(BOOST_TEST_COMPILE_OPTIONS "-fno-exceptions" "/GX-") 122 | 123 | __boost_test_list_replace(BOOST_TEST_COMPILE_OPTIONS "-frtti" "/GR") 124 | __boost_test_list_replace(BOOST_TEST_COMPILE_OPTIONS "-fno-rtti" "/GR-") 125 | 126 | __boost_test_list_replace(BOOST_TEST_COMPILE_OPTIONS "-w" "/W0") 127 | __boost_test_list_replace(BOOST_TEST_COMPILE_OPTIONS "-Wall" "/W4") 128 | __boost_test_list_replace(BOOST_TEST_COMPILE_OPTIONS "-Wextra" "") 129 | __boost_test_list_replace(BOOST_TEST_COMPILE_OPTIONS "-pedantic" "") 130 | __boost_test_list_replace(BOOST_TEST_COMPILE_OPTIONS "-Wpedantic" "") 131 | 132 | __boost_test_list_replace(BOOST_TEST_COMPILE_OPTIONS "-Werror" "/WX") 133 | __boost_test_list_replace(BOOST_TEST_COMPILE_OPTIONS "-Wno-error" "/WX-") 134 | 135 | endif() 136 | 137 | foreach(feature IN LISTS BOOST_TEST_COMPILE_FEATURES) 138 | if(NOT feature IN_LIST CMAKE_CXX_COMPILE_FEATURES) 139 | 140 | boost_message(VERBOSE "Test '${__NAME}' skipped, '${feature}' is not supported") 141 | return() 142 | 143 | endif() 144 | endforeach() 145 | 146 | foreach(library IN LISTS BOOST_TEST_LINK_LIBRARIES) 147 | 148 | if(TARGET ${library}) 149 | get_target_property(features ${library} INTERFACE_COMPILE_FEATURES) 150 | 151 | if(features) # need to check because features-NOTFOUND is a valid list 152 | foreach(feature IN LISTS features) 153 | if(NOT feature IN_LIST CMAKE_CXX_COMPILE_FEATURES) 154 | 155 | boost_message(VERBOSE "Test '${__NAME}' skipped, '${feature}' required by '${library}' is not supported") 156 | return() 157 | 158 | endif() 159 | endforeach() 160 | endif() 161 | endif() 162 | endforeach() 163 | 164 | if(NOT TARGET tests) 165 | add_custom_target(tests) 166 | endif() 167 | 168 | if(NOT TARGET tests-quick) 169 | add_custom_target(tests-quick) 170 | endif() 171 | 172 | if(__TYPE STREQUAL "compile") 173 | 174 | add_library(${__NAME} STATIC EXCLUDE_FROM_ALL ${BOOST_TEST_SOURCES}) 175 | target_link_libraries(${__NAME} ${BOOST_TEST_LINK_LIBRARIES}) 176 | target_compile_definitions(${__NAME} PRIVATE ${BOOST_TEST_COMPILE_DEFINITIONS}) 177 | target_compile_options(${__NAME} PRIVATE ${BOOST_TEST_COMPILE_OPTIONS}) 178 | target_compile_features(${__NAME} PRIVATE ${BOOST_TEST_COMPILE_FEATURES}) 179 | target_include_directories(${__NAME} PRIVATE ${BOOST_TEST_INCLUDE_DIRECTORIES}) 180 | 181 | add_dependencies(tests ${__NAME}) 182 | 183 | if("${__NAME}" MATCHES "quick") 184 | add_dependencies(tests-quick ${__NAME}) 185 | endif() 186 | 187 | elseif(__TYPE STREQUAL "compile-fail") 188 | 189 | add_library(${__NAME} STATIC EXCLUDE_FROM_ALL ${BOOST_TEST_SOURCES}) 190 | target_link_libraries(${__NAME} ${BOOST_TEST_LINK_LIBRARIES}) 191 | target_compile_definitions(${__NAME} PRIVATE ${BOOST_TEST_COMPILE_DEFINITIONS}) 192 | target_compile_options(${__NAME} PRIVATE ${BOOST_TEST_COMPILE_OPTIONS}) 193 | target_compile_features(${__NAME} PRIVATE ${BOOST_TEST_COMPILE_FEATURES}) 194 | target_include_directories(${__NAME} PRIVATE ${BOOST_TEST_INCLUDE_DIRECTORIES}) 195 | 196 | add_test(NAME ${__TYPE}-${__NAME} COMMAND "${CMAKE_COMMAND}" --build ${CMAKE_BINARY_DIR} --target ${__NAME} --config $) 197 | 198 | set_tests_properties(${__TYPE}-${__NAME} PROPERTIES WILL_FAIL TRUE RUN_SERIAL TRUE) 199 | 200 | elseif(__TYPE STREQUAL "link") 201 | 202 | add_executable(${__NAME} EXCLUDE_FROM_ALL ${BOOST_TEST_SOURCES}) 203 | target_link_libraries(${__NAME} ${BOOST_TEST_LINK_LIBRARIES}) 204 | target_compile_definitions(${__NAME} PRIVATE ${BOOST_TEST_COMPILE_DEFINITIONS}) 205 | target_compile_options(${__NAME} PRIVATE ${BOOST_TEST_COMPILE_OPTIONS}) 206 | target_compile_features(${__NAME} PRIVATE ${BOOST_TEST_COMPILE_FEATURES}) 207 | target_include_directories(${__NAME} PRIVATE ${BOOST_TEST_INCLUDE_DIRECTORIES}) 208 | 209 | add_dependencies(tests ${__NAME}) 210 | 211 | if("${__NAME}" MATCHES "quick") 212 | add_dependencies(tests-quick ${__NAME}) 213 | endif() 214 | 215 | elseif(__TYPE STREQUAL "link-fail") 216 | 217 | add_library(compile-${__NAME} OBJECT EXCLUDE_FROM_ALL ${BOOST_TEST_SOURCES}) 218 | target_link_libraries(compile-${__NAME} ${BOOST_TEST_LINK_LIBRARIES}) 219 | target_compile_definitions(compile-${__NAME} PRIVATE ${BOOST_TEST_COMPILE_DEFINITIONS}) 220 | target_compile_options(compile-${__NAME} PRIVATE ${BOOST_TEST_COMPILE_OPTIONS}) 221 | target_compile_features(compile-${__NAME} PRIVATE ${BOOST_TEST_COMPILE_FEATURES}) 222 | target_include_directories(compile-${__NAME} PRIVATE ${BOOST_TEST_INCLUDE_DIRECTORIES}) 223 | 224 | add_dependencies(tests compile-${__NAME}) 225 | 226 | if("${__NAME}" MATCHES "quick") 227 | add_dependencies(tests-quick compile-${__NAME}) 228 | endif() 229 | 230 | add_executable(${__NAME} EXCLUDE_FROM_ALL $) 231 | target_link_libraries(${__NAME} ${BOOST_TEST_LINK_LIBRARIES}) 232 | target_compile_definitions(${__NAME} PRIVATE ${BOOST_TEST_COMPILE_DEFINITIONS}) 233 | target_compile_options(${__NAME} PRIVATE ${BOOST_TEST_COMPILE_OPTIONS}) 234 | target_compile_features(${__NAME} PRIVATE ${BOOST_TEST_COMPILE_FEATURES}) 235 | target_include_directories(${__NAME} PRIVATE ${BOOST_TEST_INCLUDE_DIRECTORIES}) 236 | 237 | add_test(NAME ${__TYPE}-${__NAME} COMMAND "${CMAKE_COMMAND}" --build ${CMAKE_BINARY_DIR} --target ${__NAME} --config $) 238 | set_tests_properties(${__TYPE}-${__NAME} PROPERTIES WILL_FAIL TRUE RUN_SERIAL TRUE) 239 | 240 | elseif(__TYPE STREQUAL "run" OR __TYPE STREQUAL "run-fail") 241 | 242 | add_executable(${__NAME} EXCLUDE_FROM_ALL ${BOOST_TEST_SOURCES}) 243 | target_link_libraries(${__NAME} ${BOOST_TEST_LINK_LIBRARIES}) 244 | target_compile_definitions(${__NAME} PRIVATE ${BOOST_TEST_COMPILE_DEFINITIONS}) 245 | target_compile_options(${__NAME} PRIVATE ${BOOST_TEST_COMPILE_OPTIONS}) 246 | target_compile_features(${__NAME} PRIVATE ${BOOST_TEST_COMPILE_FEATURES}) 247 | target_include_directories(${__NAME} PRIVATE ${BOOST_TEST_INCLUDE_DIRECTORIES}) 248 | 249 | add_dependencies(tests ${__NAME}) 250 | 251 | if("${__NAME}" MATCHES "quick") 252 | add_dependencies(tests-quick ${__NAME}) 253 | endif() 254 | 255 | add_test(NAME ${__TYPE}-${__NAME} COMMAND ${__NAME} ${__ARGUMENTS}) 256 | 257 | if(__TYPE STREQUAL "run-fail") 258 | set_tests_properties(${__TYPE}-${__NAME} PROPERTIES WILL_FAIL TRUE) 259 | endif() 260 | 261 | if(BOOST_TEST_WORKING_DIRECTORY) 262 | set_target_properties(${__NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${BOOST_TEST_WORKING_DIRECTORY}") 263 | set_tests_properties(${__TYPE}-${__NAME} PROPERTIES WORKING_DIRECTORY "${BOOST_TEST_WORKING_DIRECTORY}") 264 | endif() 265 | 266 | else() 267 | 268 | message(AUTHOR_WARNING "Unknown test type '${__TYPE}' for test '${__NAME}'") 269 | 270 | endif() 271 | 272 | endfunction(boost_test) 273 | -------------------------------------------------------------------------------- /include/BoostTestJamfile.cmake: -------------------------------------------------------------------------------- 1 | # Copyright 2018, 2019 Peter Dimov 2 | # Distributed under the Boost Software License, Version 1.0. 3 | # See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt 4 | 5 | # Include BoostTest outside the include guard for it to clear its global variables 6 | include(BoostTest) 7 | 8 | if(NOT CMAKE_VERSION VERSION_LESS 3.10) 9 | include_guard() 10 | endif() 11 | 12 | if(BUILD_TESTING AND CMAKE_VERSION VERSION_LESS 3.9) 13 | message(AUTHOR_WARNING "BoostTestJamfile requires CMake 3.9") # CMAKE_MATCH_x 14 | endif() 15 | 16 | include(BoostMessage) 17 | 18 | # boost_test_jamfile( FILE jamfile [PREFIX prefix] 19 | # LINK_LIBRARIES libs... 20 | # COMPILE_DEFINITIONS defs... 21 | # COMPILE_OPTIONS opts... 22 | # COMPILE_FEATURES features... 23 | # INCLUDE_DIRECTORIES dirs... 24 | # ) 25 | 26 | function(boost_test_jamfile) 27 | 28 | cmake_parse_arguments(_ 29 | "" 30 | "FILE;PREFIX" 31 | "LIBRARIES;LINK_LIBRARIES;COMPILE_DEFINITIONS;COMPILE_OPTIONS;COMPILE_FEATURES;INCLUDE_DIRECTORIES" 32 | ${ARGN}) 33 | 34 | if(__UNPARSED_ARGUMENTS) 35 | message(AUTHOR_WARNING "boost_test_jamfile: extra arguments ignored: ${__UNPARSED_ARGUMENTS}") 36 | endif() 37 | 38 | if(__LIBRARIES) 39 | message(AUTHOR_WARNING "boost_test_jamfile: LIBRARIES is deprecated, use LINK_LIBRARIES") 40 | endif() 41 | 42 | if(NOT __FILE) 43 | message(AUTHOR_WARNING "boost_test_jamfile: required argument FILE is missing") 44 | return() 45 | endif() 46 | 47 | if(DEFINED BUILD_TESTING AND NOT BUILD_TESTING) 48 | return() 49 | endif() 50 | 51 | file(STRINGS "${__FILE}" data) 52 | 53 | set(types "compile|compile-fail|link|link-fail|run|run-fail") 54 | 55 | foreach(line IN LISTS data) 56 | # Extract type and remaining part, (silently) ignore any other line 57 | if(line MATCHES "^[ \t]*(${types})([ \t].*|$)") 58 | set(type ${CMAKE_MATCH_1}) 59 | set(args ${CMAKE_MATCH_2}) # This starts with a space 60 | 61 | if(args MATCHES "^[ \t]+([^ \t]+)[ \t]*(;[ \t]*)?$") 62 | # Single source, e.g. 'run foo.c ;' 63 | # Semicolon is optional to support e.g. 'run mytest.cpp\n : : : something ;' (ignore 'something') 64 | set(sources ${CMAKE_MATCH_1}) 65 | elseif(args MATCHES "^(([ \t]+[a-zA-Z0-9_]+\.cpp)+)[ \t]*(;[ \t]*)?$") 66 | # Multiple sources with restricted names to avoid false positives, e.g. 'run foo.cpp bar.cpp ;' 67 | # Again with optional semicolon 68 | string(STRIP "${CMAKE_MATCH_1}" sources) 69 | # Convert space-separated list into CMake list 70 | string(REGEX REPLACE "\.cpp[ \t]+" ".cpp;" sources "${sources}") 71 | else() 72 | boost_message(VERBOSE "boost_test_jamfile: Jamfile line ignored: ${line}") 73 | continue() 74 | endif() 75 | 76 | boost_test(PREFIX "${__PREFIX}" TYPE "${type}" 77 | SOURCES ${sources} 78 | LINK_LIBRARIES ${__LIBRARIES} ${__LINK_LIBRARIES} 79 | COMPILE_DEFINITIONS ${__COMPILE_DEFINITIONS} 80 | COMPILE_OPTIONS ${__COMPILE_OPTIONS} 81 | COMPILE_FEATURES ${__COMPILE_FEATURES} 82 | INCLUDE_DIRECTORIES ${__INCLUDE_DIRECTORIES} 83 | ) 84 | endif() 85 | 86 | endforeach() 87 | endfunction() 88 | -------------------------------------------------------------------------------- /test/add_subdir/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2018-2021 Peter Dimov 2 | # Distributed under the Boost Software License, Version 1.0. 3 | # https://www.boost.org/LICENSE_1_0.txt 4 | 5 | cmake_minimum_required(VERSION 3.5...3.20) 6 | 7 | project(boost_add_sibdir_test LANGUAGES CXX) 8 | 9 | include(CTest) 10 | 11 | set(BOOST_INCLUDE_LIBRARIES timer) 12 | 13 | add_subdirectory(../../../.. deps/boost) 14 | 15 | add_executable(main main.cpp) 16 | target_link_libraries(main Boost::timer) 17 | 18 | add_test(NAME main COMMAND main) 19 | 20 | install(TARGETS main) 21 | -------------------------------------------------------------------------------- /test/add_subdir/main.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Peter Dimov 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt 4 | 5 | #include 6 | 7 | int main() 8 | { 9 | boost::timer::cpu_timer timer; 10 | timer.stop(); 11 | } 12 | -------------------------------------------------------------------------------- /test/add_subdir_compat/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2018-2024 Peter Dimov 2 | # Distributed under the Boost Software License, Version 1.0. 3 | # https://www.boost.org/LICENSE_1_0.txt 4 | 5 | cmake_minimum_required(VERSION 3.5...3.20) 6 | 7 | project(boost_add_sibdir_compat_test LANGUAGES CXX) 8 | 9 | include(CTest) 10 | 11 | set(BOOST_INCLUDE_LIBRARIES smart_ptr timer) 12 | set(BOOST_ENABLE_COMPATIBILITY_TARGETS ON) 13 | 14 | add_subdirectory(../../../.. deps/boost) 15 | 16 | add_executable(main main.cpp) 17 | target_link_libraries(main Boost::boost Boost::timer Boost::disable_autolinking) 18 | 19 | add_test(NAME main COMMAND main) 20 | 21 | install(TARGETS main) 22 | -------------------------------------------------------------------------------- /test/add_subdir_compat/main.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2019, 2024 Peter Dimov 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // https://www.boost.org/LICENSE_1_0.txt 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | int main() 10 | { 11 | boost::shared_ptr timer = boost::make_shared(); 12 | timer->stop(); 13 | } 14 | -------------------------------------------------------------------------------- /test/add_subdir_exc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2018-2021 Peter Dimov 2 | # Distributed under the Boost Software License, Version 1.0. 3 | # https://www.boost.org/LICENSE_1_0.txt 4 | 5 | cmake_minimum_required(VERSION 3.5...3.20) 6 | 7 | project(boost_add_sibdir_exc_test LANGUAGES CXX) 8 | 9 | include(CTest) 10 | 11 | # set(BOOST_INCLUDE_LIBRARIES timer) 12 | 13 | add_subdirectory(../../../.. deps/boost EXCLUDE_FROM_ALL) 14 | 15 | add_executable(main main.cpp) 16 | target_link_libraries(main Boost::timer) 17 | 18 | add_test(NAME main COMMAND main) 19 | 20 | install(TARGETS main) 21 | -------------------------------------------------------------------------------- /test/add_subdir_exc/main.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Peter Dimov 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt 4 | 5 | #include 6 | 7 | int main() 8 | { 9 | boost::timer::cpu_timer timer; 10 | timer.stop(); 11 | } 12 | -------------------------------------------------------------------------------- /test/add_subdir_exc_compat/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2018-2024 Peter Dimov 2 | # Distributed under the Boost Software License, Version 1.0. 3 | # https://www.boost.org/LICENSE_1_0.txt 4 | 5 | cmake_minimum_required(VERSION 3.5...3.20) 6 | 7 | project(boost_add_sibdir_exc_compat_test LANGUAGES CXX) 8 | 9 | include(CTest) 10 | 11 | set(BOOST_ENABLE_COMPATIBILITY_TARGETS ON) 12 | 13 | add_subdirectory(../../../.. deps/boost EXCLUDE_FROM_ALL) 14 | 15 | add_executable(main main.cpp) 16 | target_link_libraries(main Boost::boost Boost::timer Boost::disable_autolinking) 17 | 18 | add_test(NAME main COMMAND main) 19 | 20 | install(TARGETS main) 21 | -------------------------------------------------------------------------------- /test/add_subdir_exc_compat/main.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2019, 2024 Peter Dimov 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // https://www.boost.org/LICENSE_1_0.txt 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | int main() 10 | { 11 | boost::shared_ptr timer = boost::make_shared(); 12 | timer->stop(); 13 | } 14 | -------------------------------------------------------------------------------- /test/assert/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2018, 2019 Peter Dimov 2 | # Distributed under the Boost Software License, Version 1.0. 3 | # See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt 4 | 5 | cmake_minimum_required(VERSION 3.5...3.16) 6 | 7 | project(boost_assert_install_test LANGUAGES CXX) 8 | 9 | find_package(boost_assert REQUIRED) 10 | 11 | add_executable(main main.cpp) 12 | target_link_libraries(main Boost::assert) 13 | 14 | enable_testing() 15 | add_test(NAME main COMMAND main) 16 | 17 | add_custom_target(check VERBATIM COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure --no-tests=error -C $) 18 | -------------------------------------------------------------------------------- /test/assert/main.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Peter Dimov 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt 4 | 5 | #include 6 | 7 | int main() 8 | { 9 | int x = 5; 10 | BOOST_ASSERT( x > 4 ); 11 | } 12 | -------------------------------------------------------------------------------- /test/atomic/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2018, 2019 Peter Dimov 2 | # Distributed under the Boost Software License, Version 1.0. 3 | # See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt 4 | 5 | cmake_minimum_required(VERSION 3.5...3.16) 6 | 7 | project(boost_atomic_install_test LANGUAGES CXX) 8 | 9 | if(BOOST_RUNTIME_LINK STREQUAL "static") 10 | set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") 11 | endif() 12 | 13 | find_package(boost_atomic REQUIRED) 14 | 15 | add_executable(main main.cpp) 16 | target_link_libraries(main Boost::atomic) 17 | 18 | enable_testing() 19 | add_test(NAME main COMMAND main) 20 | 21 | add_custom_target(check VERBATIM COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure --no-tests=error -C $) 22 | -------------------------------------------------------------------------------- /test/atomic/main.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Peter Dimov 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt 4 | 5 | #include 6 | 7 | struct X 8 | { 9 | double v[ 8 ]; 10 | }; 11 | 12 | int main() 13 | { 14 | boost::atomic a; 15 | a.store( X() ); 16 | } 17 | -------------------------------------------------------------------------------- /test/bind/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2018, 2019, 2023 Peter Dimov 2 | # Distributed under the Boost Software License, Version 1.0. 3 | # https://www.boost.org/LICENSE_1_0.txt 4 | 5 | cmake_minimum_required(VERSION 3.5...3.16) 6 | 7 | project(boost_bind_install_test LANGUAGES CXX) 8 | 9 | # Test use of Boost::headers instead of Boost::bind 10 | 11 | find_package(boost_headers REQUIRED) 12 | 13 | add_executable(main main.cpp) 14 | target_link_libraries(main Boost::headers) 15 | 16 | enable_testing() 17 | add_test(NAME main COMMAND main) 18 | 19 | add_custom_target(check VERBATIM COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure --no-tests=error -C $) 20 | -------------------------------------------------------------------------------- /test/bind/main.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2019, 2023 Peter Dimov 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // https://www.boost.org/LICENSE_1_0.txt 4 | 5 | #include 6 | 7 | int f( int x, int y ) 8 | { 9 | return x + y; 10 | } 11 | 12 | int main() 13 | { 14 | return boost::bind( f, 1, 2 )() == 3? 0: 1; 15 | } 16 | -------------------------------------------------------------------------------- /test/boost_fetch/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2018, 2019 Peter Dimov 2 | # Distributed under the Boost Software License, Version 1.0. 3 | # See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt 4 | 5 | cmake_minimum_required(VERSION 3.5...3.16) 6 | 7 | project(boost_fetch_test LANGUAGES CXX) 8 | 9 | include("${CMAKE_CURRENT_SOURCE_DIR}/../../include/BoostFetch.cmake") 10 | 11 | include(CTest) 12 | add_custom_target(check VERBATIM COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure --no-tests=error -C $) 13 | 14 | set(BUILD_TESTING OFF) # hide cache variable 15 | 16 | boost_fetch(boostorg/assert TAG develop EXCLUDE_FROM_ALL) 17 | boost_fetch(boostorg/config TAG develop EXCLUDE_FROM_ALL) 18 | boost_fetch(boostorg/core TAG develop EXCLUDE_FROM_ALL) 19 | boost_fetch(boostorg/static_assert TAG develop EXCLUDE_FROM_ALL) 20 | boost_fetch(boostorg/throw_exception TAG develop EXCLUDE_FROM_ALL) 21 | 22 | unset(BUILD_TESTING) 23 | 24 | add_executable(main main.cpp) 25 | target_link_libraries(main Boost::core) 26 | 27 | add_test(NAME main COMMAND main) 28 | -------------------------------------------------------------------------------- /test/boost_fetch/main.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Peter Dimov 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt 4 | 5 | #include 6 | 7 | int main() 8 | { 9 | int x = 5; 10 | 11 | BOOST_TEST_GT( x, 4 ); 12 | 13 | return boost::report_errors(); 14 | } 15 | -------------------------------------------------------------------------------- /test/boost_test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2018, 2019 Peter Dimov 2 | # Distributed under the Boost Software License, Version 1.0. 3 | # See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt 4 | 5 | cmake_minimum_required(VERSION 3.5...3.16) 6 | 7 | project(boost_cmake_test LANGUAGES CXX) 8 | 9 | include(CTest) 10 | 11 | set(BUILD_TESTING OFF) # hide cache variable 12 | 13 | add_subdirectory(../../../../libs/assert EXCLUDE_FROM_ALL boostorg/assert) 14 | add_subdirectory(../../../../libs/config EXCLUDE_FROM_ALL boostorg/config) 15 | add_subdirectory(../../../../libs/core EXCLUDE_FROM_ALL boostorg/core) 16 | add_subdirectory(../../../../libs/static_assert EXCLUDE_FROM_ALL boostorg/static_assert) 17 | add_subdirectory(../../../../libs/throw_exception EXCLUDE_FROM_ALL boostorg/throw_exception) 18 | 19 | unset(BUILD_TESTING) 20 | 21 | list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../include) 22 | 23 | # boost_test 24 | 25 | include(BoostTest) 26 | 27 | boost_test(TYPE compile SOURCES compile.cpp) 28 | boost_test(TYPE compile-fail SOURCES compile_fail.cpp) 29 | boost_test(TYPE link SOURCES link.cpp) 30 | boost_test(TYPE link-fail SOURCES link_fail.cpp) 31 | boost_test(TYPE run SOURCES run.cpp) 32 | boost_test(TYPE run-fail SOURCES run_fail.cpp) 33 | 34 | boost_test(TYPE run SOURCES arguments.cpp ARGUMENTS pumpkin LINK_LIBRARIES Boost::core) 35 | 36 | boost_test(TYPE run NAME return_exit_code_pass SOURCES return_exit_code.cpp COMPILE_DEFINITIONS EXIT_CODE=0) 37 | boost_test(TYPE run-fail NAME return_exit_code_fail SOURCES return_exit_code.cpp COMPILE_DEFINITIONS EXIT_CODE=1) 38 | 39 | boost_test(TYPE run SOURCES requires_variadic_templates.cpp COMPILE_FEATURES cxx_variadic_templates) 40 | 41 | boost_test(TYPE run SOURCES requires_no_rtti.cpp COMPILE_OPTIONS -fno-rtti LINK_LIBRARIES Boost::config) 42 | boost_test(TYPE run SOURCES requires_no_exceptions.cpp COMPILE_OPTIONS -fno-exceptions LINK_LIBRARIES Boost::config) 43 | 44 | boost_test(TYPE compile-fail SOURCES emits_warning.cpp COMPILE_OPTIONS -Wall -Werror) 45 | 46 | boost_test(TYPE compile NAME compile_subdir SOURCES include_subdir.cpp INCLUDE_DIRECTORIES subdir) 47 | boost_test(TYPE link NAME link_subdir SOURCES include_subdir.cpp INCLUDE_DIRECTORIES subdir) 48 | boost_test(TYPE run NAME run_subdir SOURCES include_subdir.cpp INCLUDE_DIRECTORIES subdir) 49 | 50 | # boost_test, w/ globals 51 | 52 | set(BOOST_TEST_COMPILE_OPTIONS -fno-rtti -fno-exceptions) 53 | set(BOOST_TEST_LINK_LIBRARIES Boost::config) 54 | set(BOOST_TEST_INCLUDE_DIRECTORIES subdir) 55 | set(BOOST_TEST_PREFIX boost_cmake_test_globals) 56 | 57 | boost_test(SOURCES requires_no_rtti.cpp) 58 | boost_test(SOURCES requires_no_exceptions.cpp) 59 | boost_test(SOURCES include_subdir.cpp) 60 | 61 | # boost_test_jamfile 62 | 63 | include(BoostTestJamfile) 64 | 65 | boost_test_jamfile(FILE Jamfile PREFIX boost_cmake_test_jamfile) 66 | -------------------------------------------------------------------------------- /test/boost_test/Jamfile: -------------------------------------------------------------------------------- 1 | # Copyright 2018, 2019 Peter Dimov 2 | # Copyright 2023 Alexander Grund 3 | # Distributed under the Boost Software License, Version 1.0. 4 | # See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt 5 | 6 | import testing ; 7 | 8 | project 9 | : default-build on 10 | ; 11 | 12 | compile compile.cpp ; 13 | compile-fail compile_fail.cpp ; 14 | link link.cpp ; 15 | link-fail link_fail.cpp ; 16 | run run.cpp ; 17 | # Multiple sources 18 | run run_multi.cpp run_multi_2.cpp ; 19 | # Similar but with semicolon on next line with B2 specifics (ignored in CMake) 20 | link run_multi_2.cpp run_multi.cpp 21 | : : : always_show_run_output ; 22 | run-fail run_fail.cpp 23 | : ; 24 | 25 | # Those should be skipped in CMake although valid B2 26 | run 27 | arguments.cpp : 28 | pumpkin ; 29 | run test_message.cpp : $(BOOST_ROOT)/subdir ; 30 | run run_multi.cpp windows:non_existant.cpp ; 31 | -------------------------------------------------------------------------------- /test/boost_test/arguments.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Peter Dimov 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt 4 | 5 | #include 6 | #include 7 | 8 | int main( int ac, char const* av[] ) 9 | { 10 | BOOST_TEST_EQ( ac, 2 ); 11 | 12 | if( ac >= 2 ) 13 | { 14 | BOOST_TEST_CSTR_EQ( av[1], "pumpkin" ); 15 | } 16 | 17 | return boost::report_errors(); 18 | } 19 | -------------------------------------------------------------------------------- /test/boost_test/compile.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Peter Dimov 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt 4 | 5 | int f() 6 | { 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /test/boost_test/compile_fail.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Peter Dimov 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt 4 | 5 | int f() 6 | { 7 | return x; 8 | } 9 | -------------------------------------------------------------------------------- /test/boost_test/emits_warning.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Peter Dimov 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt 4 | 5 | int main() 6 | { 7 | int x, y; 8 | return x; 9 | } 10 | -------------------------------------------------------------------------------- /test/boost_test/include_subdir.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Peter Dimov 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // https://www.boost.org/LICENSE_1_0.txt 4 | 5 | #include "header.hpp" 6 | 7 | int main() 8 | { 9 | return f(); 10 | } 11 | -------------------------------------------------------------------------------- /test/boost_test/link.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Peter Dimov 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt 4 | 5 | int f() 6 | { 7 | return 0; 8 | } 9 | 10 | int main() 11 | { 12 | return f(); 13 | } 14 | -------------------------------------------------------------------------------- /test/boost_test/link_fail.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Peter Dimov 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt 4 | 5 | int f(); 6 | 7 | int main() 8 | { 9 | return f(); 10 | } 11 | -------------------------------------------------------------------------------- /test/boost_test/requires_no_exceptions.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Peter Dimov 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt 4 | 5 | #include 6 | 7 | int main() 8 | { 9 | #if defined(BOOST_NO_EXCEPTIONS) 10 | 11 | return 0; 12 | 13 | #else 14 | 15 | return 1; 16 | 17 | #endif 18 | } 19 | -------------------------------------------------------------------------------- /test/boost_test/requires_no_rtti.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Peter Dimov 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt 4 | 5 | #include 6 | 7 | int main() 8 | { 9 | #if defined(BOOST_NO_RTTI) 10 | 11 | return 0; 12 | 13 | #else 14 | 15 | return 1; 16 | 17 | #endif 18 | } 19 | -------------------------------------------------------------------------------- /test/boost_test/requires_variadic_templates.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Peter Dimov 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt 4 | 5 | template int f() 6 | { 7 | return sizeof...(T); 8 | } 9 | 10 | int main() 11 | { 12 | return f() == 3? 0: 1; 13 | } 14 | -------------------------------------------------------------------------------- /test/boost_test/return_exit_code.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Peter Dimov 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt 4 | 5 | int main() 6 | { 7 | return EXIT_CODE; 8 | } 9 | -------------------------------------------------------------------------------- /test/boost_test/run.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Peter Dimov 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt 4 | 5 | int main() 6 | { 7 | } 8 | -------------------------------------------------------------------------------- /test/boost_test/run_fail.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Peter Dimov 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt 4 | 5 | int main() 6 | { 7 | return 1; 8 | } 9 | -------------------------------------------------------------------------------- /test/boost_test/run_multi.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Alexander Grund 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt 4 | 5 | int g() 6 | { 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /test/boost_test/run_multi_2.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Alexander Grund 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt 4 | 5 | //Maybe in a header: 6 | int g(); 7 | 8 | int main() 9 | { 10 | return g(); 11 | } 12 | -------------------------------------------------------------------------------- /test/boost_test/subdir/header.hpp: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_HPP_INCLUDED 2 | #define HEADER_HPP_INCLUDED 3 | 4 | // Copyright 2023 Peter Dimov 5 | // Distributed under the Boost Software License, Version 1.0. 6 | // https://www.boost.org/LICENSE_1_0.txt 7 | 8 | inline int f() 9 | { 10 | return 0; 11 | } 12 | 13 | #endif // #ifndef HEADER_HPP_INCLUDED 14 | -------------------------------------------------------------------------------- /test/endian/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2018, 2019, 2023 Peter Dimov 2 | # Distributed under the Boost Software License, Version 1.0. 3 | # https://www.boost.org/LICENSE_1_0.txt 4 | 5 | cmake_minimum_required(VERSION 3.5...3.16) 6 | 7 | project(boost_endian_install_test LANGUAGES CXX) 8 | 9 | # test find_package(Boost) instead of find_package(boost_endian) 10 | 11 | find_package(Boost 1.82 REQUIRED) 12 | 13 | add_executable(main main.cpp) 14 | target_link_libraries(main Boost::boost) 15 | 16 | enable_testing() 17 | add_test(NAME main COMMAND main) 18 | 19 | add_custom_target(check VERBATIM COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure --no-tests=error -C $) 20 | -------------------------------------------------------------------------------- /test/endian/main.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2019, 2023 Peter Dimov 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // https://www.boost.org/LICENSE_1_0.txt 4 | 5 | #undef NDEBUG 6 | 7 | #include 8 | #include 9 | 10 | #define BOOST_TEST_EQ(x, y) assert((x) == (y)) 11 | 12 | int main() 13 | { 14 | using namespace boost::endian; 15 | 16 | { 17 | little_uint32_t v( 0x01020304 ); 18 | 19 | BOOST_TEST_EQ( v.data()[ 0 ], 0x04 ); 20 | BOOST_TEST_EQ( v.data()[ 1 ], 0x03 ); 21 | BOOST_TEST_EQ( v.data()[ 2 ], 0x02 ); 22 | BOOST_TEST_EQ( v.data()[ 3 ], 0x01 ); 23 | } 24 | 25 | { 26 | big_uint32_t v( 0x01020304 ); 27 | 28 | BOOST_TEST_EQ( v.data()[ 0 ], 0x01 ); 29 | BOOST_TEST_EQ( v.data()[ 1 ], 0x02 ); 30 | BOOST_TEST_EQ( v.data()[ 2 ], 0x03 ); 31 | BOOST_TEST_EQ( v.data()[ 3 ], 0x04 ); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /test/iostreams/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2018, 2019, 2021 Peter Dimov 2 | # Distributed under the Boost Software License, Version 1.0. 3 | # See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt 4 | 5 | cmake_minimum_required(VERSION 3.5...3.16) 6 | 7 | project(boost_iostreams_install_test LANGUAGES CXX) 8 | 9 | if(BOOST_RUNTIME_LINK STREQUAL "static") 10 | set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") 11 | endif() 12 | 13 | find_package(boost_iostreams REQUIRED) 14 | 15 | add_executable(test_fd test_fd.cpp) 16 | target_link_libraries(test_fd Boost::iostreams Boost::core) 17 | 18 | enable_testing() 19 | add_test(NAME test_fd COMMAND test_fd WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) 20 | 21 | add_custom_target(check VERBATIM COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure --no-tests=error -C $) 22 | -------------------------------------------------------------------------------- /test/iostreams/test.txt: -------------------------------------------------------------------------------- 1 | === reference output === -------------------------------------------------------------------------------- /test/iostreams/test_fd.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Peter Dimov 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | namespace io = boost::iostreams; 11 | 12 | int main() 13 | { 14 | io::file_descriptor_source fs( "test.txt" ); 15 | 16 | std::string s; 17 | io::copy( fs, io::back_inserter( s ) ); 18 | 19 | BOOST_TEST( s == "=== reference output ===" ); 20 | 21 | return boost::report_errors(); 22 | } 23 | -------------------------------------------------------------------------------- /test/locale/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2018, 2019, 2021 Peter Dimov 2 | # Distributed under the Boost Software License, Version 1.0. 3 | # See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt 4 | 5 | cmake_minimum_required(VERSION 3.5...3.16) 6 | 7 | project(boost_locale_install_test LANGUAGES CXX) 8 | 9 | if(BOOST_RUNTIME_LINK STREQUAL "static") 10 | set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") 11 | endif() 12 | 13 | find_package(boost_locale REQUIRED) 14 | 15 | add_executable(main main.cpp) 16 | target_link_libraries(main Boost::locale) 17 | 18 | enable_testing() 19 | add_test(NAME main COMMAND main) 20 | 21 | add_custom_target(check VERBATIM COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure --no-tests=error -C $) 22 | -------------------------------------------------------------------------------- /test/locale/main.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2009-2011 Artyom Beilis (Tonkikh) 2 | // Copyright 2021 Peter Dimov 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | int main() 11 | { 12 | boost::locale::generator gen; 13 | 14 | std::locale loc = gen( "en_US.UTF-8" ); 15 | 16 | std::cout.imbue( loc ); 17 | 18 | std::cout << boost::locale::format( "Today {1,date} at {1,time} we had run our first localization example" ) % std::time( 0 ) << std::endl; 19 | 20 | std::cout << "This is how we show numbers in this locale " << boost::locale::as::number << 103.34 << std::endl; 21 | std::cout << "This is how we show currency in this locale " << boost::locale::as::currency << 103.34 << std::endl; 22 | 23 | std::cout << "This is typical date in the locale " << boost::locale::as::date << std::time( 0 ) << std::endl; 24 | std::cout << "This is typical time in the locale " << boost::locale::as::time << std::time( 0 ) << std::endl; 25 | 26 | std::string str( "Hello World!" ); 27 | 28 | std::cout << "This is upper case " << boost::locale::to_upper( str, loc ) << std::endl; 29 | std::cout << "This is lower case " << boost::locale::to_lower( str, loc ) << std::endl; 30 | std::cout << "This is title case " << boost::locale::to_title( str, loc ) << std::endl; 31 | std::cout << "This is fold case " << boost::locale::fold_case( str, loc ) << std::endl; 32 | } 33 | -------------------------------------------------------------------------------- /test/mp11/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2018 Peter Dimov 2 | # Distributed under the Boost Software License, Version 1.0. 3 | # See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt 4 | 5 | cmake_minimum_required(VERSION 3.5...3.16) 6 | 7 | project(boost_mp11_install_test LANGUAGES CXX) 8 | 9 | find_package(boost_mp11 REQUIRED) 10 | 11 | add_executable(main main.cpp) 12 | target_link_libraries(main Boost::mp11) 13 | 14 | enable_testing() 15 | add_test(NAME main COMMAND main) 16 | 17 | add_custom_target(check VERBATIM COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure --no-tests=error -C $) 18 | -------------------------------------------------------------------------------- /test/mp11/main.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Peter Dimov 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt 4 | 5 | #include 6 | using namespace boost::mp11; 7 | 8 | int main() 9 | { 10 | using L1 = mp_list; 11 | return mp_size>::value == 2? 0: 1; 12 | } 13 | -------------------------------------------------------------------------------- /test/mysql/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2023 Peter Dimov 2 | # Distributed under the Boost Software License, Version 1.0. 3 | # See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt 4 | 5 | # Boost.MySQL requires OpenSSL to work 6 | 7 | cmake_minimum_required(VERSION 3.5...3.16) 8 | 9 | project(boost_mysql_install_test LANGUAGES CXX) 10 | 11 | find_package(boost_mysql REQUIRED) 12 | 13 | add_executable(main main.cpp) 14 | target_link_libraries(main Boost::mysql) 15 | 16 | enable_testing() 17 | add_test(NAME main COMMAND main) 18 | 19 | add_custom_target(check VERBATIM COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure --no-tests=error -C $) 20 | -------------------------------------------------------------------------------- /test/mysql/main.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Peter Dimov 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt 4 | 5 | 6 | #include 7 | 8 | #include 9 | 10 | using namespace boost::mysql; 11 | 12 | int main() 13 | { 14 | tcp_connection conn(boost::asio::system_executor{}); 15 | 16 | // This is always false for a non-connected connection 17 | return static_cast(conn.uses_ssl()); 18 | } 19 | -------------------------------------------------------------------------------- /test/preprocessor/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2018, 2019 Peter Dimov 2 | # Distributed under the Boost Software License, Version 1.0. 3 | # See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt 4 | 5 | cmake_minimum_required(VERSION 3.5...3.16) 6 | 7 | project(boost_preprocessor_install_test LANGUAGES CXX) 8 | 9 | find_package(boost_preprocessor REQUIRED) 10 | 11 | add_executable(main main.cpp) 12 | target_link_libraries(main Boost::preprocessor) 13 | 14 | enable_testing() 15 | add_test(NAME main COMMAND main) 16 | 17 | add_custom_target(check VERBATIM COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure --no-tests=error -C $) 18 | -------------------------------------------------------------------------------- /test/preprocessor/main.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2001 Housemarque Oy 2 | // Copyright 2002 Paul Mensonides 3 | // Copyright 2019 Peter Dimov 4 | // Distributed under the Boost Software License, Version 1.0. 5 | // https://www.boost.org/LICENSE_1_0.txt 6 | 7 | #include 8 | #include 9 | 10 | #define BEGIN typedef int BOOST_PP_CAT(test_, __LINE__)[(( 11 | #define END )==1) ? 1 : -1]; 12 | 13 | /* equality */ 14 | 15 | BEGIN BOOST_PP_EQUAL(2, 0) == 0 END 16 | BEGIN BOOST_PP_EQUAL(2, 2) == 1 END 17 | 18 | /* inequality */ 19 | 20 | BEGIN BOOST_PP_NOT_EQUAL(2, 0) == 1 END 21 | BEGIN BOOST_PP_NOT_EQUAL(2, 2) == 0 END 22 | 23 | /* less */ 24 | 25 | BEGIN BOOST_PP_LESS(2, 1) == 0 END 26 | BEGIN BOOST_PP_LESS(1, 2) == 1 END 27 | 28 | /* less_equal */ 29 | 30 | BEGIN BOOST_PP_LESS_EQUAL(2, 1) == 0 END 31 | BEGIN BOOST_PP_LESS_EQUAL(1, 2) == 1 END 32 | BEGIN BOOST_PP_LESS_EQUAL(2, 2) == 1 END 33 | 34 | /* greater */ 35 | 36 | BEGIN BOOST_PP_GREATER(2, 1) == 1 END 37 | BEGIN BOOST_PP_GREATER(1, 2) == 0 END 38 | 39 | /* greater_equal */ 40 | 41 | BEGIN BOOST_PP_GREATER_EQUAL(2, 1) == 1 END 42 | BEGIN BOOST_PP_GREATER_EQUAL(1, 2) == 0 END 43 | BEGIN BOOST_PP_GREATER_EQUAL(2, 2) == 1 END 44 | 45 | int main() 46 | { 47 | } 48 | -------------------------------------------------------------------------------- /test/system/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2018, 2019, 2023 Peter Dimov 2 | # Distributed under the Boost Software License, Version 1.0. 3 | # https://www.boost.org/LICENSE_1_0.txt 4 | 5 | cmake_minimum_required(VERSION 3.5...3.16) 6 | 7 | project(boost_system_install_test LANGUAGES CXX) 8 | 9 | # test find_package(Boost) instead of find_package(boost_system) 10 | 11 | find_package(Boost 1.82 REQUIRED COMPONENTS system) 12 | 13 | add_executable(main main.cpp) 14 | target_link_libraries(main Boost::system) 15 | 16 | enable_testing() 17 | add_test(NAME main COMMAND main) 18 | 19 | add_custom_target(check VERBATIM COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure --no-tests=error -C $) 20 | -------------------------------------------------------------------------------- /test/system/main.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2017, 2021 Peter Dimov. 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // https://www.boost.org/LICENSE_1_0.txt 4 | 5 | // See library home page at http://www.boost.org/libs/system 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #define BOOST_TEST(expr) assert(expr) 12 | #define BOOST_TEST_EQ(x1, x2) assert((x1)==(x2)) 13 | 14 | int main() 15 | { 16 | boost::system::error_category const & bt = boost::system::generic_category(); 17 | 18 | int ev = ENOENT; 19 | 20 | boost::system::error_code bc( ev, bt ); 21 | 22 | BOOST_TEST_EQ( bc.value(), ev ); 23 | BOOST_TEST_EQ( &bc.category(), &bt ); 24 | 25 | boost::system::error_condition bn = bt.default_error_condition( ev ); 26 | 27 | BOOST_TEST_EQ( bn.value(), ev ); 28 | BOOST_TEST_EQ( &bn.category(), &bt ); 29 | 30 | BOOST_TEST( bt.equivalent( ev, bn ) ); 31 | 32 | BOOST_TEST( bc == bn ); 33 | 34 | boost::system::error_code bc2 = make_error_code( boost::system::errc::no_such_file_or_directory ); 35 | 36 | BOOST_TEST_EQ( bc2, bc ); 37 | BOOST_TEST_EQ( bc2.value(), ev ); 38 | BOOST_TEST_EQ( &bc.category(), &bt ); 39 | 40 | boost::system::system_error x( bc, "prefix" ); 41 | 42 | BOOST_TEST_EQ( x.code(), bc ); 43 | BOOST_TEST_EQ( std::string( x.what() ), "prefix: " + bc.what() ); 44 | } 45 | -------------------------------------------------------------------------------- /test/timer/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2018, 2019 Peter Dimov 2 | # Distributed under the Boost Software License, Version 1.0. 3 | # See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt 4 | 5 | cmake_minimum_required(VERSION 3.5...3.16) 6 | 7 | project(boost_timer_install_test LANGUAGES CXX) 8 | 9 | if(BOOST_RUNTIME_LINK STREQUAL "static") 10 | set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") 11 | endif() 12 | 13 | find_package(boost_timer REQUIRED) 14 | 15 | add_executable(main main.cpp) 16 | target_link_libraries(main Boost::timer) 17 | 18 | enable_testing() 19 | add_test(NAME main COMMAND main) 20 | 21 | add_custom_target(check VERBATIM COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure --no-tests=error -C $) 22 | -------------------------------------------------------------------------------- /test/timer/main.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Peter Dimov 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt 4 | 5 | #include 6 | 7 | int main() 8 | { 9 | boost::timer::cpu_timer timer; 10 | timer.stop(); 11 | } 12 | --------------------------------------------------------------------------------