Hello. I’m a bit stuck on step 5 of the CMake tutorial. Specifically, when I build the project I get:
Looking for log
Looking for log - not found
Looking for exp
Looking for exp - not found
Configuring done
Generating done
No matter what I have tried, I can’t get CMake to find the log and exp. I tried replacing check_symbol_exists(log “math.h” HAVE_LOG) with check_cxx_symbol_exists(std::log “cmath” HAVE_LOG), but nothing changed. I also tried building step 6, but I have the same issue there. I also tested the example on the CHECK_CXX_SYMBOL_EXISTS documentation page, and those didn’t find the target symbol either. I could use some help.
I’m using the latest version of CMake (3.17.0-rc1), and I am using Visual Studio 2019 on Windows 10 to build the tutorial.
Just clarifying, the original question was about the logged messages that log and exp were not found, but it seems that the project still configures and likely builds successfully, right? In that case, the fact that these were not found is not a problem, it’s perhaps just confusing for users. The merge request linked to by Betsy currently won’t change this behaviour, so I’ll follow-up there.
While the project builds successfully, the issue is that check_symbol_exists does not find anything when I build. I tried building the tutorial, and I tried using the examples on the check_symbol_exists and check_cxx_symbol_exists documentation pages, and they did not work either. Removing the set(CMAKE_REQUIRED_LIBRARIES "m") line does not fix my issue with check_symbol_exists unfortunately. However, judging by the GitLab thread, it seems like a solution has already been found. I’m eager to test it with the next release of CMake.
The math library, libm, is always a cross-platform issue since
Windows has no separate (libm) math library (as you just
discovered) while Unix does. Here is the stanza I use to deal with
this issue for PLplot.
if(NOT (WIN32 OR CYGWIN))
find_library(MATH_LIB NAMES m PATHS /usr/local/lib /usr/lib)
if(NOT MATH_LIB)
message(FATAL_ERROR “Cannot find required math library”)
endif(NOT MATH_LIB)
endif(NOT(WIN32 OR CYGWIN))
Then PLplot adds (the sometimes empty, depending on platform)
${MATH_LIB} to target_link_libraries commands whenever a target
depends on math functions.