link to libm if necessary
This commit is contained in:
parent
1acc29c724
commit
8d65cce75f
@ -24,7 +24,28 @@ set(HEADER_FILES conv.h
|
||||
)
|
||||
|
||||
add_library(wavelib STATIC ${SOURCE_FILES} ${HEADER_FILES})
|
||||
|
||||
|
||||
include(CheckSymbolExists)
|
||||
|
||||
# https://stackoverflow.com/questions/32816646/can-cmake-detect-if-i-need-to-link-to-libm-when-using-pow-in-c
|
||||
if(NOT POW_FUNCTION_EXISTS AND NOT NEED_LINKING_AGAINST_LIBM)
|
||||
check_symbol_exists(pow "math.h" POW_FUNCTION_EXISTS)
|
||||
if(NOT POW_FUNCTION_EXISTS)
|
||||
unset(POW_FUNCTION_EXISTS CACHE)
|
||||
list(APPEND CMAKE_REQUIRED_LIBRARIES m)
|
||||
check_symbol_exists(pow "math.h" POW_FUNCTION_EXISTS)
|
||||
if(POW_FUNCTION_EXISTS)
|
||||
set(NEED_LINKING_AGAINST_LIBM True CACHE BOOL "" FORCE)
|
||||
else()
|
||||
message(FATAL_ERROR "Failed making the pow() function available")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NEED_LINKING_AGAINST_LIBM)
|
||||
target_link_libraries(wavelib PUBLIC m)
|
||||
endif()
|
||||
|
||||
set_property(TARGET wavelib PROPERTY FOLDER "lib")
|
||||
|
||||
target_include_directories(wavelib PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}../header)
|
||||
|
Loading…
Reference in New Issue
Block a user