Skip to content

Commit f2d2aca

Browse files
committed
Update method of detecting and linking quadmath
1 parent 007ac06 commit f2d2aca

1 file changed

Lines changed: 17 additions & 3 deletions

File tree

CMakeLists.txt

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,22 @@ target_include_directories(boost_charconv PUBLIC include)
1919

2020
# find_library for quadmath does not always work so attempt
2121
# to compile the trivial test case we use with B2
22-
include(CheckCXXSourceCompiles)
23-
check_cxx_source_compiles(config/has_float128.cpp QUADMATH_FOUND)
22+
include(CheckCXXSourceRuns)
23+
set(BOOST_CHARCONV_QUADMATH_TEST_SOURCE
24+
"
25+
#include <quadmath.h>
26+
int main()
27+
{
28+
__float128 f = -2.0Q;
29+
f = fabsq(f);
30+
31+
return 0;
32+
}
33+
")
34+
35+
set(CMAKE_REQUIRED_LIBRARIES "quadmath")
36+
check_cxx_source_runs("${BOOST_CHARCONV_QUADMATH_TEST_SOURCE}" BOOST_CHARCONV_QUADMATH_FOUND)
37+
set(CMAKE_REQUIRED_LIBRARIES "")
2438

2539
target_link_libraries(boost_charconv
2640
PUBLIC
@@ -29,7 +43,7 @@ target_link_libraries(boost_charconv
2943
Boost::core
3044
)
3145

32-
if(NOT QUADMATH_FOUND)
46+
if(NOT BOOST_CHARCONV_QUADMATH_FOUND)
3347
message(STATUS "Boost.Charconv: quadmath support OFF")
3448
target_compile_definitions(boost_charconv PUBLIC BOOST_CHARCONV_NO_QUADMATH)
3549
else()

0 commit comments

Comments
 (0)