mirror of
https://github.com/dhewm/dhewm3-libs.git
synced 2024-11-14 16:41:27 +00:00
fc9f4ce542
if you don't fix everything yourself...
49 lines
2.4 KiB
CMake
49 lines
2.4 KiB
CMake
# sdl2 cmake project-config input for ./configure scripts
|
|
|
|
# DG: I modified this so it might actually work...
|
|
|
|
|
|
#set(prefix "/opt/local/x86_64-w64-mingw32")
|
|
set(prefix "${CMAKE_CURRENT_LIST_DIR}/../../..") # DG: one modification..
|
|
set(exec_prefix "${prefix}")
|
|
set(libdir "${exec_prefix}/lib")
|
|
set(SDL2_PREFIX "/opt/local/x86_64-w64-mingw32")
|
|
set(SDL2_EXEC_PREFIX "/opt/local/x86_64-w64-mingw32")
|
|
set(SDL2_LIBDIR "${exec_prefix}/lib")
|
|
set(SDL2_INCLUDE_DIRS "${prefix}/include/SDL2")
|
|
#set(SDL2_LIBRARIES "-L${SDL2_LIBDIR} -lmingw32 -lSDL2main -lSDL2 -mwindows")
|
|
if(MSVC) # DG: added handling MSVC specially
|
|
#set(SDL2_LIBRARIES "${SDL2_LIBDIR}/SDL2.lib")
|
|
set(SDL2_LIBRARIES "SDL2")
|
|
else() # MinGW
|
|
set(SDL2_LIBRARIES "-lmingw32 -lSDL2 -mwindows") # DG: no SDL2main, no -L (using ${SDL2_LIBDIR} in CMakeLists.txt)
|
|
endif() # DG end
|
|
string(STRIP "${SDL2_LIBRARIES}" SDL2_LIBRARIES)
|
|
|
|
if(NOT TARGET SDL2::SDL2)
|
|
# Remove -lSDL2 as that is handled by CMake, note the space at the end so it does not replace e.g. -lSDL2main
|
|
# This may require "libdir" beeing set (from above)
|
|
string(REPLACE "-lSDL2 " "" SDL2_EXTRA_LINK_FLAGS " -lmingw32 -lSDL2main -lSDL2 -mwindows ")
|
|
string(STRIP "${SDL2_EXTRA_LINK_FLAGS}" SDL2_EXTRA_LINK_FLAGS)
|
|
string(REPLACE "-lSDL2 " "" SDL2_EXTRA_LINK_FLAGS_STATIC " -lmingw32 -lSDL2main -lSDL2 -mwindows -Wl,--no-undefined -Wl,--dynamicbase -Wl,--nxcompat -Wl,--high-entropy-va -lm -ldinput8 -ldxguid -ldxerr8 -luser32 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lshell32 -lsetupapi -lversion -luuid -static-libgcc ")
|
|
string(STRIP "${SDL2_EXTRA_LINK_FLAGS_STATIC}" SDL2_EXTRA_LINK_FLAGS_STATIC)
|
|
|
|
add_library(SDL2::SDL2 SHARED IMPORTED)
|
|
set_target_properties(SDL2::SDL2 PROPERTIES
|
|
INTERFACE_INCLUDE_DIRECTORIES "${prefix}/include/SDL2"
|
|
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
|
|
IMPORTED_LOCATION "${exec_prefix}/lib/libSDL2.so"
|
|
INTERFACE_LINK_LIBRARIES "${SDL2_EXTRA_LINK_FLAGS}")
|
|
|
|
add_library(SDL2::SDL2-static STATIC IMPORTED)
|
|
set_target_properties(SDL2::SDL2-static PROPERTIES
|
|
INTERFACE_INCLUDE_DIRECTORIES "${prefix}/include/SDL2"
|
|
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
|
|
IMPORTED_LOCATION "${exec_prefix}/lib/libSDL2.a"
|
|
INTERFACE_LINK_LIBRARIES "${SDL2_EXTRA_LINK_FLAGS_STATIC}")
|
|
|
|
add_library(SDL2::SDL2main STATIC IMPORTED)
|
|
set_target_properties(SDL2::SDL2main PROPERTIES
|
|
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
|
|
IMPORTED_LOCATION "${exec_prefix}/lib/libSDL2main.a")
|
|
endif()
|