mirror of https://github.com/aap/librw.git
cmake: need SDL2main on Windows (and other platforms) + link to m on GNU/clang
This commit is contained in:
parent
7f0b98f960
commit
4d260a631b
|
@ -1,16 +1,19 @@
|
|||
find_package(PkgConfig QUIET)
|
||||
if(PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(SDL2 IMPORTED_TARGET "sdl2")
|
||||
if(TARGET PkgConfig::SDL2 AND NOT TARGET sdl2::sdl2)
|
||||
add_library(_sdl2 INTERFACE)
|
||||
target_link_libraries(_sdl2 INTERFACE PkgConfig::SDL2)
|
||||
add_library(SDL2::SDL2 ALIAS _sdl2)
|
||||
if(TARGET PkgConfig::SDL2 AND NOT TARGET SDL2::SDL2)
|
||||
add_library(SDL2::SDL2 INTERFACE IMPORTED)
|
||||
set_property(TARGET SDL2::SDL2 PROPERTY INTERFACE_LINK_LIBRARIES PkgConfig::SDL2)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
find_library(SDL2main_LIBRARY SDL2main)
|
||||
|
||||
if(NOT SDL2_FOUND)
|
||||
find_path(SDL2_INCLUDE_DIR sdl2.h)
|
||||
find_library(SDL2_LIBRARY sdl2)
|
||||
find_library(SDL2_LIBRARY SDL2 SDL2d)
|
||||
|
||||
find_library(SDL2main_LIBRARY SDL2main)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(libuv
|
||||
|
@ -25,3 +28,11 @@ if(NOT SDL2_FOUND)
|
|||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(SDL2main_LIBRARY AND NOT TARGET SDL2::SDL2main)
|
||||
add_library(SDL2::SDL2main UNKNOWN IMPORTED)
|
||||
set_target_properties(SDL2::SDL2main PROPERTIES
|
||||
IMPORTED_LOCATION "${SDL2main_LIBRARY}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${SDL2_INCLUDE_DIR}"
|
||||
)
|
||||
endif()
|
||||
|
|
|
@ -107,6 +107,12 @@ target_compile_definitions(librw
|
|||
"RW_${LIBRW_PLATFORM}"
|
||||
)
|
||||
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||
target_link_libraries(librw
|
||||
PRIVATE
|
||||
m
|
||||
)
|
||||
endif()
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
|
||||
target_compile_options(librw
|
||||
PRIVATE
|
||||
|
@ -161,6 +167,12 @@ if(LIBRW_PLATFORM_GL3)
|
|||
PUBLIC
|
||||
SDL2::SDL2
|
||||
)
|
||||
if(TARGET SDL2::SDL2main)
|
||||
target_link_libraries(librw
|
||||
PUBLIC
|
||||
SDL2::SDL2main
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
elseif(LIBRW_PLATFORM_D3D9)
|
||||
target_link_libraries(librw
|
||||
|
|
Loading…
Reference in New Issue