Skip to content

Commit

Permalink
Boost: libs: pass BOOST_USE_WINAPI_VERSION as define (#583)
Browse files Browse the repository at this point in the history
When `add_compile_definitions()` is used in a cmake toolchain file the
directory property COMPILE_DEFINITIONS is set. Use this property to pass
those definitions to the `boost-user.jam` file.

This is introduced to pass the `BOOST_USE_WINAPI_VERSION` as define
to the bjam build command.

This fixes Boost.Log usage when the project is explicitly built for Windows 8
or newer. Boost.Log builds per default build for Windows 7, which breaks
the build because the boost-header will be used in a Windows 8 context,
but the Windows 8 specific functions are not compiled into the library.

The changelog for Boost 1.78 mentions `BOOST_USE_WINAPI_VERSION` for
`Atomic` and `Log` libraries https://www.boost.org/users/history/version_1_78_0.html

> ### Atomic:
> - On Windows, corrected discrepancy between `atomic-type::always_has_native_wait_notify` and the corresponding capability macros when targeting Windows 8 or later. The library will now directly use `WaitOnAddress` and related APIs from public headers and therefore require user to link with `synchronization.lib` if the user requires Windows 8 or later by defining `BOOST_USE_WINAPI_VERSION`, `_WIN32_WINNT` or similar macros. The library is linked automatically on compilers that support auto-linking (e.g. MSVC).

> ### Log:
> - On Windows, when building the library for Windows 8 or later, the library will use `nt62` tag in the version namespace to denote the target OS ABI. For example, the version namespace could be named as `v2_mt_nt62`. This name will be part of all symbols exported by the library. Use the `BOOST_USE_WINAPI_VERSION` macro consistenly when building Boost and your code to request the minimum target Windows version.

As an explicit override the CMake variable `BOOST_USE_WINAPI_VERSION`
can be set (either by CMAKE_ARGS or in a toolchain file) to bjam using the
`define=` bjam commandline. This overrides the define set by `add_compile_definitions()`.

The `define=` usage is documented at
https://www.boost.org/doc/libs/1_79_0/libs/log/doc/html/log/installation/config.html

The `BOOST_USE_WINAPI_VERSION` define is documented for WinAPI and Log:
- https://www.boost.org/doc/libs/1_79_0/libs/winapi/doc/html/winapi/config.html
- https://www.boost.org/doc/libs/1_79_0/libs/log/doc/html/log/installation/config.html

Also push the internal schema version number to trigger a rebuild, as the
schema is changed.
  • Loading branch information
NeroBurner committed Jul 6, 2022
1 parent 08b2aa3 commit 36588ef
Show file tree
Hide file tree
Showing 35 changed files with 57 additions and 36 deletions.
2 changes: 1 addition & 1 deletion cmake/projects/Boost/atomic/hunter.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
atomic
PACKAGE_INTERNAL_DEPS_ID "49"
PACKAGE_INTERNAL_DEPS_ID "50"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/chrono/hunter.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
chrono
PACKAGE_INTERNAL_DEPS_ID "49"
PACKAGE_INTERNAL_DEPS_ID "50"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/container/hunter.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
container
PACKAGE_INTERNAL_DEPS_ID "49"
PACKAGE_INTERNAL_DEPS_ID "50"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/context/hunter.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
context
PACKAGE_INTERNAL_DEPS_ID "49"
PACKAGE_INTERNAL_DEPS_ID "50"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/contract/hunter.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
contract
PACKAGE_INTERNAL_DEPS_ID "49"
PACKAGE_INTERNAL_DEPS_ID "50"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/coroutine/hunter.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
coroutine
PACKAGE_INTERNAL_DEPS_ID "49"
PACKAGE_INTERNAL_DEPS_ID "50"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/date_time/hunter.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
date_time
PACKAGE_INTERNAL_DEPS_ID "49"
PACKAGE_INTERNAL_DEPS_ID "50"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/exception/hunter.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
exception
PACKAGE_INTERNAL_DEPS_ID "49"
PACKAGE_INTERNAL_DEPS_ID "50"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/fiber/hunter.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
fiber
PACKAGE_INTERNAL_DEPS_ID "49"
PACKAGE_INTERNAL_DEPS_ID "50"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/filesystem/hunter.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
filesystem
PACKAGE_INTERNAL_DEPS_ID "49"
PACKAGE_INTERNAL_DEPS_ID "50"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/graph/hunter.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
graph
PACKAGE_INTERNAL_DEPS_ID "49"
PACKAGE_INTERNAL_DEPS_ID "50"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/graph_parallel/hunter.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
graph_parallel
PACKAGE_INTERNAL_DEPS_ID "49"
PACKAGE_INTERNAL_DEPS_ID "50"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/hunter.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
boost_component
PACKAGE_INTERNAL_DEPS_ID "49"
PACKAGE_INTERNAL_DEPS_ID "50"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/iostreams/hunter.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
iostreams
PACKAGE_INTERNAL_DEPS_ID "49"
PACKAGE_INTERNAL_DEPS_ID "50"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/json/hunter.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
json
PACKAGE_INTERNAL_DEPS_ID "49"
PACKAGE_INTERNAL_DEPS_ID "50"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/locale/hunter.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
locale
PACKAGE_INTERNAL_DEPS_ID "49"
PACKAGE_INTERNAL_DEPS_ID "50"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/log/hunter.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
log
PACKAGE_INTERNAL_DEPS_ID "49"
PACKAGE_INTERNAL_DEPS_ID "50"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/math/hunter.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
math
PACKAGE_INTERNAL_DEPS_ID "49"
PACKAGE_INTERNAL_DEPS_ID "50"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/mpi/hunter.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
mpi
PACKAGE_INTERNAL_DEPS_ID "49"
PACKAGE_INTERNAL_DEPS_ID "50"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/nowide/hunter.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
nowide
PACKAGE_INTERNAL_DEPS_ID "49"
PACKAGE_INTERNAL_DEPS_ID "50"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/program_options/hunter.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
program_options
PACKAGE_INTERNAL_DEPS_ID "49"
PACKAGE_INTERNAL_DEPS_ID "50"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/python/hunter.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
python
PACKAGE_INTERNAL_DEPS_ID "49"
PACKAGE_INTERNAL_DEPS_ID "50"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/random/hunter.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
random
PACKAGE_INTERNAL_DEPS_ID "49"
PACKAGE_INTERNAL_DEPS_ID "50"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/regex/hunter.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
regex
PACKAGE_INTERNAL_DEPS_ID "49"
PACKAGE_INTERNAL_DEPS_ID "50"
)
14 changes: 14 additions & 0 deletions cmake/projects/Boost/schemes/url_sha1_boost_library.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,14 @@ else()
)
endif()

# pass defines set by `add_compile_definitions()` in cmake toolchain to boost-user.jam
get_directory_property(dir_COMPILE_DEFINITIONS COMPILE_DEFINITIONS)
foreach(compile_def ${dir_COMPILE_DEFINITIONS})
# Note: Flags should be quoted:
# - https://github.com/boostorg/build/issues/426#issuecomment-482564740
file( APPEND ${boost_user_jam} " <compileflags>\"-D${compile_def}\"\n")
endforeach()

if(use_cmake_archiver)
# We need custom '<archiver>' and '<ranlib>' for
# Android LTO ('*-gcc-ar' instead of '*-ar')
Expand Down Expand Up @@ -424,6 +432,12 @@ if(have_jobs)
endif()
endif()

if("@WIN32@")
if(NOT "${BOOST_USE_WINAPI_VERSION}" STREQUAL "")
list(APPEND build_opts "define=BOOST_USE_WINAPI_VERSION=${BOOST_USE_WINAPI_VERSION}")
endif()
endif()

if(@HUNTER_STATUS_DEBUG@)
set(verbose_output "-d+2 --debug-configuration")
endif()
Expand Down
2 changes: 1 addition & 1 deletion cmake/projects/Boost/serialization/hunter.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
serialization
PACKAGE_INTERNAL_DEPS_ID "49"
PACKAGE_INTERNAL_DEPS_ID "50"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/signals/hunter.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
signals
PACKAGE_INTERNAL_DEPS_ID "49"
PACKAGE_INTERNAL_DEPS_ID "50"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/stacktrace/hunter.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
stacktrace
PACKAGE_INTERNAL_DEPS_ID "49"
PACKAGE_INTERNAL_DEPS_ID "50"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/system/hunter.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
system
PACKAGE_INTERNAL_DEPS_ID "49"
PACKAGE_INTERNAL_DEPS_ID "50"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/test/hunter.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
test
PACKAGE_INTERNAL_DEPS_ID "49"
PACKAGE_INTERNAL_DEPS_ID "50"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/thread/hunter.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
thread
PACKAGE_INTERNAL_DEPS_ID "49"
PACKAGE_INTERNAL_DEPS_ID "50"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/timer/hunter.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
timer
PACKAGE_INTERNAL_DEPS_ID "49"
PACKAGE_INTERNAL_DEPS_ID "50"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/type_erasure/hunter.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
type_erasure
PACKAGE_INTERNAL_DEPS_ID "49"
PACKAGE_INTERNAL_DEPS_ID "50"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/wave/hunter.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
wave
PACKAGE_INTERNAL_DEPS_ID "49"
PACKAGE_INTERNAL_DEPS_ID "50"
)
13 changes: 10 additions & 3 deletions docs/packages/pkg/Boost.rst
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,18 @@ config file (``boost/config/user.hpp``):

- `Boost-log-useBoostConfig <https://github.com/cpp-pm/hunter/blob/master/examples/Boost-log-useBoostConfig/CMakeLists.txt>`__

- Option ``BOOST_BUILD_DYNAMIC_VSRUNTIME=OFF`` use on Windows to build the boost libraries with the static runtime.
- Option ``BOOST_USE_WINAPI_VERSION=<API_VERSION>`` use on Windows in order to set the Windows API version used for building the boost libraries.

Should be used together with ``USE_CONFIG_FROM_BOOST=ON``.
Otherwise the generated library filenames won't be found by the provided ``FindBoost.cmake`` module.
Since Boost 1.78.0 Boost.Log exports additional symbols when building for Windows 8 or newer.
So it is recommended to set the CMake variable ``BOOST_USE_WINAPI_VERSION`` in the CMake-toolchain file (or the ``CMAKE_ARGS``) to the same value as the defines ``_WIN32_WINNT`` and ``WINVER``.

- `Boost.WinAPI documentation <https://www.boost.org/doc/libs/1_79_0/libs/winapi/doc/html/winapi/config.html>`__

The version passed must match the hexadecimal integer values used for ``_WIN32_WINNT`` and ``WINVER``.
The version numbers are described in
`Windows Headers documentation <https://docs.microsoft.com/en-us/windows/win32/winprog/using-the-windows-headers?redirectedfrom=MSDN#macros_for_conditional_declarations>`__.

``API_VERSION`` is passed as a hexadecimal integer e.g. ``BOOST_USE_WINAPI_VERSION=0x0603`` sets the Windows API version to Windows 8.1.

Python
------
Expand Down

0 comments on commit 36588ef

Please sign in to comment.