CMakeLists.txt: Make libm dep conditional on UNIX

This commit is contained in:
Walter Schell 2021-01-11 20:13:09 -05:00
parent d6c62f3fcf
commit f3d2772ec0

View File

@ -32,17 +32,20 @@ set(LUA_LIB_SRCS
"src/lutf8lib.c" "src/lutf8lib.c"
"src/linit.c" "src/linit.c"
) )
#TODO: Redo this with find_package
find_library(LIBM m)
if(NOT LIBM)
message(FATAL_ERROR "libm not found and requred by lua")
endif()
add_library(lua_static STATIC ${LUA_LIB_SRCS}) add_library(lua_static STATIC ${LUA_LIB_SRCS})
set_target_properties(lua_static PROPERTIES OUTPUT_NAME "lua") set_target_properties(lua_static PROPERTIES OUTPUT_NAME "lua")
target_link_libraries(lua_static INTERFACE ${LIBM})
target_include_directories(lua_static PUBLIC "include") target_include_directories(lua_static PUBLIC "include")
set(LUA_DEFINITIONS) set(LUA_DEFINITIONS)
if(UNIX) if(UNIX)
find_library(LIBM m)
#TODO: Redo this with find_package
if(NOT LIBM)
message(FATAL_ERROR "libm not found and requred by lua")
endif()
target_link_libraries(lua_static INTERFACE ${LIBM})
list(APPEND LUA_DEFINITIONS LUA_USE_POSIX) list(APPEND LUA_DEFINITIONS LUA_USE_POSIX)
if(LUA_SUPPORT_DL) if(LUA_SUPPORT_DL)
target_compile_definitions(lua_static PRIVATE "LUA_USE_DLOPEN") target_compile_definitions(lua_static PRIVATE "LUA_USE_DLOPEN")