Tutorial: Step 5-6 log/exp checks do not work when re-run
The logic added by !4375 (merged) is broken when the project is configured more than once:
check_symbol_exists(log "math.h" HAVE_LOG)
check_symbol_exists(exp "math.h" HAVE_EXP)
if(NOT (HAVE_LOG AND HAVE_EXP))
unset(HAVE_LOG CACHE)
unset(HAVE_EXP CACHE)
set(CMAKE_REQUIRED_LIBRARIES "m")
check_symbol_exists(log "math.h" HAVE_LOG)
check_symbol_exists(exp "math.h" HAVE_EXP)
if(HAVE_LOG AND HAVE_EXP)
target_link_libraries(MathFunctions PRIVATE m)
endif()
endif()
If the m
library is required, HAVE_{LOG,EXP}
will fail the first time and the branch will be taken. The second checks will pass, and m
will be linked. On re-configure, the branch will not be taken because the checks are recorded as passing, and m
will not be linked.