Skip to content

Commit 8fe0687

Browse files
committed
CMake: Detect libm with find_library
1 parent 78b1be3 commit 8fe0687

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

CMakeLists.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ include (CheckCCompilerFlag)
8181
include (CheckCXXSymbolExists)
8282
include (CheckCSourceCompiles)
8383
include (CheckCXXCompilerFlag)
84-
include (CheckLibraryExists)
8584

8685
#==============================================================================
8786
# COMPILATION CHECKINGS and CONFIGURATION GENERATION
@@ -108,9 +107,8 @@ set (HAVE_UINT32_T ${SIZEOF_UINT32_T})
108107
check_type_size ("unsigned int" SIZEOF_UNSIGNED_INT)
109108
check_type_size ("unsigned long" SIZEOF_UNSIGNED_LONG)
110109

111-
check_library_exists ("m" sqrt "" HAVE_LIBM)
112-
if (HAVE_LIBM)
113-
set (M_LIBRARY m)
110+
find_library(M_LIBRARY m)
111+
if (M_LIBRARY)
114112
set (LIBS_PRIVATE "-l${M_LIBRARY}")
115113
endif()
116114

@@ -258,7 +256,9 @@ if (NLOPT_LUKSAN)
258256
target_include_directories(${nlopt_lib} PRIVATE src/algs/luksan)
259257
target_compile_definitions (${nlopt_lib} PRIVATE NLOPT_LUKSAN)
260258
endif ()
261-
target_link_libraries (${nlopt_lib} ${M_LIBRARY})
259+
if (M_LIBRARY)
260+
target_link_libraries (${nlopt_lib} ${M_LIBRARY})
261+
endif ()
262262
set_target_properties (${nlopt_lib} PROPERTIES SOVERSION ${SO_MAJOR})
263263
set_target_properties (${nlopt_lib} PROPERTIES VERSION "${SO_MAJOR}.${SO_MINOR}.${SO_PATCH}")
264264

0 commit comments

Comments
 (0)