Skip to content

Commit

Permalink
cmake: simplify try_run result comparisons (#950) (#952)
Browse files Browse the repository at this point in the history
Instead of looking at `MATCHES 0` which runs a regex and returns a false
positive for any result such as `10`, check if they are equal to `0`.
Also quote `0` to avoid looking it up as a variable (which was left
behind prior to the fix to use `${RETURN_VAR}` in the `c_run` macro).

Co-authored-by: Ben Boeckel <mathstuf@users.noreply.github.com>
  • Loading branch information
lrknox and mathstuf authored Aug 24, 2021
1 parent b80d633 commit 9424fa2
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions config/cmake/ConfigureChecks.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ if (NOT WINDOWS)
OUTPUT_VARIABLE OUTPUT
)
if (TEST_DIRECT_VFD_WORKS_COMPILE)
if (TEST_DIRECT_VFD_WORKS_RUN MATCHES 0)
if (TEST_DIRECT_VFD_WORKS_RUN EQUAL "0")
HDF_FUNCTION_TEST (HAVE_DIRECT)
set (CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} -D_GNU_SOURCE")
add_definitions ("-D_GNU_SOURCE")
Expand Down Expand Up @@ -261,8 +261,8 @@ macro (C_RUN FUNCTION_NAME SOURCE_CODE RETURN_VAR)
message (VERBOSE "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ")
endif ()

if (${COMPILE_RESULT_VAR})
if (${RUN_RESULT_VAR} MATCHES 0)
if (COMPILE_RESULT_VAR)
if (RUN_RESULT_VAR EQUAL "0")
set (${RETURN_VAR} 1 CACHE INTERNAL "Have C function ${FUNCTION_NAME}")
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0")
message (VERBOSE "Testing C ${FUNCTION_NAME} - OK")
Expand Down Expand Up @@ -320,7 +320,7 @@ message (STATUS "Testing maximum decimal precision for C - ${PROG_OUTPUT4}")
list (GET PROG_OUTPUT4 0 H5_LDBL_DIG)
list (GET PROG_OUTPUT4 1 H5_FLT128_DIG)

if (${HDF_PREFIX}_SIZEOF___FLOAT128 EQUAL 0 OR FLT128_DIG EQUAL 0)
if (${HDF_PREFIX}_SIZEOF___FLOAT128 EQUAL "0" OR FLT128_DIG EQUAL "0")
set (${HDF_PREFIX}_HAVE_FLOAT128 0)
set (${HDF_PREFIX}_SIZEOF___FLOAT128 0)
set (_PAC_C_MAX_REAL_PRECISION ${H5_LDBL_DIG})
Expand All @@ -346,7 +346,7 @@ macro (H5ConversionTests TEST msg)
OUTPUT_VARIABLE OUTPUT
)
if (${TEST}_COMPILE)
if (${TEST}_RUN MATCHES 0)
if (${TEST}_RUN EQUAL "0")
set (${TEST} 1 CACHE INTERNAL ${msg})
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0")
message (VERBOSE "${msg}... yes")
Expand Down

0 comments on commit 9424fa2

Please sign in to comment.