Explorar o código

FindBoost: Restore finding without CXX language enabled

Since commit v3.13.0~7^2 (FindBoost: Improve compiler prefix
detection for GCC 5+ and clang 4+, 2018-11-07) we run the internal
`_Boost_COMPILER_DUMPVERSION` macro on all UNIX platforms.  Teach
the macro to tolerate missing `CMAKE_CXX_COMPILER_VERSION`, which
occurs when the CXX language is not enabled.

Fixes: #18624
Brad King %!s(int64=7) %!d(string=hai) anos
pai
achega
0369362132

+ 3 - 6
Modules/FindBoost.cmake

@@ -409,15 +409,12 @@ endmacro()
 
 #-------------------------------------------------------------------------------
 
-#
-# Runs compiler with "-dumpversion" and parses major/minor
-# version with a regex.
-#
+# Convert CMAKE_CXX_COMPILER_VERSION to boost compiler suffix version.
 function(_Boost_COMPILER_DUMPVERSION _OUTPUT_VERSION _OUTPUT_VERSION_MAJOR _OUTPUT_VERSION_MINOR)
   string(REGEX REPLACE "([0-9]+)\\.([0-9]+)(\\.[0-9]+)?" "\\1"
-    _boost_COMPILER_VERSION_MAJOR ${CMAKE_CXX_COMPILER_VERSION})
+    _boost_COMPILER_VERSION_MAJOR "${CMAKE_CXX_COMPILER_VERSION}")
   string(REGEX REPLACE "([0-9]+)\\.([0-9]+)(\\.[0-9]+)?" "\\2"
-    _boost_COMPILER_VERSION_MINOR ${CMAKE_CXX_COMPILER_VERSION})
+    _boost_COMPILER_VERSION_MINOR "${CMAKE_CXX_COMPILER_VERSION}")
 
   set(_boost_COMPILER_VERSION "${_boost_COMPILER_VERSION_MAJOR}${_boost_COMPILER_VERSION_MINOR}")
 

+ 1 - 0
Tests/RunCMake/FindBoost/NoCXX-stderr.txt

@@ -0,0 +1 @@
+.*

+ 1 - 0
Tests/RunCMake/FindBoost/NoCXX.cmake

@@ -0,0 +1 @@
+find_package(Boost)

+ 1 - 0
Tests/RunCMake/FindBoost/RunCMakeTest.cmake

@@ -1,3 +1,4 @@
 include(RunCMake)
 
 run_cmake(CMakePackage)
+run_cmake(NoCXX)