Tutorial Step 5: log and exp not found

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.


The tutorial is tested as part of nightly builds, so it should work in general. Perhaps @betsy.mcphail has some ideas?

If you remove the line set(CMAKE_REQUIRED_LIBRARIES "m") does it work on your system?

I submitted a change so that this step works on Windows in the future (see https://gitlab.kitware.com/cmake/cmake/merge_requests/4375)

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.

Same problem here. (CMake 3.17.2, Windows 10, Visual Studio 2017).

Removing the set(CMAKE_REQUIRED_LIBRARIES "m") part allowed me to find log and exp symbols. What could be the explanation for this?

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.

find_library(MATH_LIB NAMES m PATHS /usr/local/lib /usr/lib)
message(FATAL_ERROR “Cannot find required math library”)

Then PLplot adds (the sometimes empty, depending on platform)
${MATH_LIB} to target_link_libraries commands whenever a target
depends on math functions.