FindBoost: Improve compiler prefix detection for GCC 5+ and clang 4+
FindBoost: Improve compiler prefix detection for GCC 5+ and clang 4+
Add recognition of compiler version and prefix for clang.
Accommodate changes to version numbering scheme for GCC 5+ and clang 4+
- Minor number becomes patch, so excluded it from compiler prefix.
- Improves searching for Boost 1.69+ libraries built with GCC 5+ and clang 4+, where library names are generated with compiler tag based on major version only eg. -gcc5 for GC 5.5.0 or -clang6 for clang 6.0.0
- Follows up related changes in upcoming Boost 1.69 https://github.com/boostorg/build/pull/349
Dump detected compiler version in Boost_DEBUG message.
Replace use of CMAKE_COMPILER_IS_GNUCXX with CMAKE_CXX_COMPILER_ID.
Problem Example
Let's consider building Boost 1.69+ (current master or later) with GCC 5.5.0 and clang 6.0.0 on Linux:
b2 toolset=gcc variant=debug,release address-model=64 --layout=versioned --with-system stage
b2 toolset=clang variant=debug,release address-model=64 --layout=versioned --with-system stage
This will generate the following libraries:
$ ls -1 libboost_system*
libboost_system-clang6-mt-d-x64-1_69.a
libboost_system-clang6-mt-d-x64-1_69.so
libboost_system-clang6-mt-d-x64-1_69.so.1.69.0
libboost_system-clang6-mt-x64-1_69.a
libboost_system-clang6-mt-x64-1_69.so
libboost_system-clang6-mt-x64-1_69.so.1.69.0
libboost_system-gcc5-mt-d-x64-1_69.a
libboost_system-gcc5-mt-d-x64-1_69.so
libboost_system-gcc5-mt-d-x64-1_69.so.1.69.0
libboost_system-gcc5-mt-x64-1_69.a
libboost_system-gcc5-mt-x64-1_69.so
libboost_system-gcc5-mt-x64-1_69.so.1.69.0
Now, we run CMake for a project that find_package
for Boost:
cmake -DBOOST_ROOT=/mnt/d/boost.wsl -DBoost_ARCHITECTURE=-x64 ..
This will fail because Boost_COMPILER
is guessed as -gcc55
.
Obvious but inconvenient workaround is to fix the compiler tag manually:
cmake -DBOOST_ROOT=/mnt/d/boost.wsl -DBoost_ARCHITECTURE=-x64 -DBoost_COMPILER=-gcc5 ..
The changes propose in this MR improve the lookup and free users from manually specifying the compiler tag.
Topic-rename: FindBoost-compiler-guess-update