From 1c9de50ad28b958a1d2009562f166eb748212577 Mon Sep 17 00:00:00 2001 From: Ronald Kinard Date: Wed, 28 Jan 2015 15:33:29 -0600 Subject: [PATCH] cmake: Search SDL2_main separately for MSVC --- cmake/Modules/FindSDL2_main.cmake | 34 +++++++++++++++++++++++++++++++ src/sdl/CMakeLists.txt | 1 + 2 files changed, 35 insertions(+) create mode 100644 cmake/Modules/FindSDL2_main.cmake diff --git a/cmake/Modules/FindSDL2_main.cmake b/cmake/Modules/FindSDL2_main.cmake new file mode 100644 index 000000000..da9e7770f --- /dev/null +++ b/cmake/Modules/FindSDL2_main.cmake @@ -0,0 +1,34 @@ +# Find SDL2 +# Once done, this will define +# +# SDL2_MAIN_FOUND - system has SDL2 +# SDL2_MAIN_INCLUDE_DIRS - SDL2 include directories +# SDL2_MAIN_LIBRARIES - link libraries + +include(LibFindMacros) + +libfind_pkg_check_modules(SDL2_MAIN_PKGCONF SDL2) + +# includes +find_path(SDL2_MAIN_INCLUDE_DIR + NAMES SDL_main.h + PATHS + ${SDL2_MAIN_PKGCONF_INCLUDE_DIRS} + "/usr/include/SDL2" + "/usr/local/include/SDL2" +) + +# library +find_library(SDL2_MAIN_LIBRARY + NAMES SDL2_main + PATHS + ${SDL2_MAIN_PKGCONF_LIBRARY_DIRS} + "/usr/lib" + "/usr/local/lib" +) + + +# set include dir variables +set(SDL2_MAIN_PROCESS_INCLUDES SDL2_MAIN_INCLUDE_DIR) +set(SDL2_MAIN_PROCESS_LIBS SDL2_MAIN_LIBRARY) +libfind_process(SDL2_MAIN) diff --git a/src/sdl/CMakeLists.txt b/src/sdl/CMakeLists.txt index 1b8ad5f5d..b6b120568 100644 --- a/src/sdl/CMakeLists.txt +++ b/src/sdl/CMakeLists.txt @@ -131,6 +131,7 @@ if(${SDL2_FOUND}) endif() if(MSVC) + find_package(SDL2_MAIN REQUIRED) target_link_libraries(${SRB2_SDL2_EXE_NAME} PRIVATE ${SDL2_MAIN_LIBRARIES} )