2017-04-07 00:00:39 +08:00
|
|
|
cmake_minimum_required(VERSION 3.0)
|
|
|
|
project(SDL2_NET C)
|
|
|
|
|
2018-05-23 11:55:25 +08:00
|
|
|
if (MSVC)
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4244 /wd4996")
|
|
|
|
endif()
|
2017-04-07 00:00:39 +08:00
|
|
|
|
|
|
|
find_path(SDL_INCLUDE_DIR SDL2/SDL.h)
|
2019-05-02 04:36:57 +08:00
|
|
|
find_package(SDL2 CONFIG REQUIRED)
|
2017-04-07 00:00:39 +08:00
|
|
|
|
2018-01-10 04:44:37 +08:00
|
|
|
add_library(SDL2_net SDLnet.c SDLnetselect.c SDLnetTCP.c SDLnetUDP.c version.rc)
|
2017-04-07 00:00:39 +08:00
|
|
|
|
2017-07-21 19:01:00 +08:00
|
|
|
set_target_properties(SDL2_net PROPERTIES DEFINE_SYMBOL SDL2_EXPORTS)
|
2017-04-07 00:00:39 +08:00
|
|
|
target_compile_definitions(SDL2_net PRIVATE _WINSOCK_DEPRECATED_NO_WARNINGS)
|
|
|
|
target_include_directories(SDL2_net PRIVATE ${SDL_INCLUDE_DIR}/SDL2)
|
2019-03-27 00:57:16 +08:00
|
|
|
|
|
|
|
if (WIN32)
|
2019-05-02 04:36:57 +08:00
|
|
|
target_link_libraries(SDL2_net SDL2::SDL2 ws2_32 iphlpapi)
|
2019-03-27 00:57:16 +08:00
|
|
|
endif()
|
2017-04-07 00:00:39 +08:00
|
|
|
|
|
|
|
install(TARGETS SDL2_net
|
2019-03-27 00:57:16 +08:00
|
|
|
EXPORT SDL2_net
|
2017-04-07 00:00:39 +08:00
|
|
|
RUNTIME DESTINATION bin
|
|
|
|
ARCHIVE DESTINATION lib
|
|
|
|
LIBRARY DESTINATION lib)
|
|
|
|
|
2019-03-27 00:57:16 +08:00
|
|
|
install(EXPORT SDL2_net
|
|
|
|
DESTINATION "share/sdl2-net"
|
|
|
|
FILE sdl2-net-config.cmake
|
|
|
|
NAMESPACE SDL2::
|
|
|
|
)
|
|
|
|
|
2017-04-07 00:00:39 +08:00
|
|
|
if(NOT DEFINED SDL_NET_SKIP_HEADERS)
|
|
|
|
install(FILES SDL_net.h DESTINATION include/SDL2)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
message(STATUS "Link-time dependencies:")
|
2019-05-02 04:36:57 +08:00
|
|
|
message(STATUS " " SDL2::SDL2)
|