FindBoost.cmake regression with CMake 3.13, broken for C projects
After upgrading from 3.12.3 to 3.13 I immediately stumbled upon the following issue. Here's a minimum example of the problem.
Given following simple CMakeLists.txt
:
PROJECT(Test C)
FIND_PACKAGE(Boost REQUIRED)
Running cmake
fails with:
-- The C compiler identification is GNU 7.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
CMake Error at /usr/share/cmake/Modules/FindBoost.cmake:417 (string):
string sub-command REGEX, mode REPLACE needs at least 6 arguments total to
command.
Call Stack (most recent call first):
/usr/share/cmake/Modules/FindBoost.cmake:495 (_Boost_COMPILER_DUMPVERSION)
/usr/share/cmake/Modules/FindBoost.cmake:1461 (_Boost_GUESS_COMPILER_PREFIX)
CMakeLists.txt:3 (FIND_PACKAGE)
-- Boost version: 1.65.0
CMake Warning (dev) in CMakeLists.txt:
No cmake_minimum_required command is present. A line of code such as
cmake_minimum_required(VERSION 3.13)
should be added at the top of the file. The version specified may be lower
if you wish to support older CMake versions for this project. For more
information run "cmake --help-policy CMP0000".
This warning is for project developers. Use -Wno-dev to suppress it.
-- Configuring incomplete, errors occurred!
See also "/home/user/test/b/CMakeFiles/CMakeOutput.log".
The problem seems to be that in C projects ${CMAKE_CXX_COMPILER_VERSION}
expands to nothing. I guess the Modules/FindBoost.cmake
script should instead use ${CMAKE_C_COMPILER_VERSION}
for C projects.
Note that Boost also contains at least 3 different preprocessor libraries, of which at least one, the Boost.Preprocessor library, also supports C.