diff options
| author | Albrecht Schlosser <albrechts.fltk@online.de> | 2024-04-05 17:06:27 +0200 |
|---|---|---|
| committer | Albrecht Schlosser <albrechts.fltk@online.de> | 2024-04-05 18:45:59 +0200 |
| commit | 2f1b8fc726cf428165c6feeeb9e3b9ab8d403291 (patch) | |
| tree | d30d0ccbc3ea7afb3ea5432c566bf055ddeb39d5 /CMake | |
| parent | fe6ab4ebc2c106fb135b26c1d7234b1591c383a5 (diff) | |
CMake: Fix detection of trunc() for Windows
Diffstat (limited to 'CMake')
| -rw-r--r-- | CMake/resources.cmake | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/CMake/resources.cmake b/CMake/resources.cmake index c483a113e..e5d6f8c9f 100644 --- a/CMake/resources.cmake +++ b/CMake/resources.cmake @@ -167,12 +167,16 @@ mark_as_advanced(LIB_m) # functions include(CheckFunctionExists) -# save CMAKE_REQUIRED_LIBRARIES (is this really necessary ?) +# Save CMAKE_REQUIRED_LIBRARIES +# Note: CMAKE_REQUIRED_LIBRARIES must be set for each search and +# reset after the search to avoid to influence subsequent searches. +# The original value is restored after all searches. + if(DEFINED CMAKE_REQUIRED_LIBRARIES) set(SAVED_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES}) -else(DEFINED CMAKE_REQUIRED_LIBRARIES) +else() unset(SAVED_REQUIRED_LIBRARIES) -endif(DEFINED CMAKE_REQUIRED_LIBRARIES) +endif() set(CMAKE_REQUIRED_LIBRARIES) if(HAVE_DLFCN_H) @@ -208,11 +212,12 @@ check_function_exists(vsnprintf HAVE_VSNPRINTF) check_function_exists(setenv HAVE_SETENV) -if(LIB_m) +# Windows doesn't require '-lm' for trunc(), other platforms do +if(LIB_m AND NOT WIN32) set(CMAKE_REQUIRED_LIBRARIES ${LIB_m}) - check_function_exists(trunc HAVE_TRUNC) - set(CMAKE_REQUIRED_LIBRARIES) -endif(LIB_m) +endif() +check_function_exists(trunc HAVE_TRUNC) +set(CMAKE_REQUIRED_LIBRARIES) if(HAVE_SCANDIR AND NOT HAVE_SCANDIR_POSIX) set(MSG "POSIX compatible scandir") @@ -231,19 +236,19 @@ if(HAVE_SCANDIR AND NOT HAVE_SCANDIR_POSIX) endif(HAVE_SCANDIR AND NOT HAVE_SCANDIR_POSIX) mark_as_advanced(HAVE_SCANDIR_POSIX) -# restore CMAKE_REQUIRED_LIBRARIES (is this really necessary ?) +# restore CMAKE_REQUIRED_LIBRARIES if(DEFINED SAVED_REQUIRED_LIBRARIES) set(CMAKE_REQUIRED_LIBRARIES ${SAVED_REQUIRED_LIBRARIES}) unset(SAVED_REQUIRED_LIBRARIES) -else(DEFINED SAVED_REQUIRED_LIBRARIES) +else() unset(CMAKE_REQUIRED_LIBRARIES) -endif(DEFINED SAVED_REQUIRED_LIBRARIES) +endif() ####################################################################### # packages # Doxygen: necessary for HTML and PDF docs -find_package (Doxygen) +find_package(Doxygen) # LaTex: necessary for PDF docs (note: FindLATEX doesn't return LATEX_FOUND) @@ -252,7 +257,7 @@ find_package (Doxygen) set(LATEX_FOUND) if(DOXYGEN_FOUND) - find_package (LATEX) + find_package(LATEX) if(LATEX_COMPILER AND NOT LATEX_FOUND) set(LATEX_FOUND YES) endif(LATEX_COMPILER AND NOT LATEX_FOUND) |
