Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMake: fix static linkage of SDL2 and use static SDL2 by default #1929

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 21 additions & 7 deletions CMake/Dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,9 @@ if(OGRE_BUILD_DEPENDENCIES AND NOT EXISTS ${OGREDEPS_PATH})
execute_process(COMMAND ${CMAKE_COMMAND}
-E make_directory ${PROJECT_BINARY_DIR}/SDL2-build)
execute_process(COMMAND ${BUILD_COMMAND_COMMON}
-DSDL_STATIC=FALSE
-DSDL_STATIC=TRUE
-DSDL_STATIC_PIC=TRUE
-DSDL_SHARED=FALSE
${PROJECT_BINARY_DIR}/SDL2-2.0.14
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/SDL2-build)
execute_process(COMMAND ${CMAKE_COMMAND}
Expand Down Expand Up @@ -336,12 +338,24 @@ if(NOT ANDROID AND NOT EMSCRIPTEN)
# find script does not work in cross compilation environment
find_package(SDL2 QUIET)
macro_log_feature(SDL2_FOUND "SDL2" "Simple DirectMedia Library needed for input handling in samples" "https://www.libsdl.org/" FALSE "" "")
if(SDL2_FOUND AND NOT TARGET SDL2::SDL2)
add_library(SDL2::SDL2 INTERFACE IMPORTED)
set_target_properties(SDL2::SDL2 PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${SDL2_INCLUDE_DIRS}"
INTERFACE_LINK_LIBRARIES "${SDL2_LIBRARIES}"
)
if(SDL2_FOUND)
if(TARGET SDL2::SDL2-static)
set_target_properties(SDL2::SDL2-static PROPERTIES IMPORTED_GLOBAL TRUE)
add_library(SDL2::SDL2 ALIAS SDL2::SDL2-static)
if(UNIX)
# leaks -Wl,--no-undefined
set_target_properties(SDL2::SDL2-static PROPERTIES
IMPORTED_LINK_INTERFACE_LIBRARIES_RELWITHDEBINFO ""
IMPORTED_LINK_INTERFACE_LIBRARIES_DEBUG ""
IMPORTED_LINK_INTERFACE_LIBRARIES_RELEASE "")
endif()
elseif(NOT TARGET SDL2::SDL2)
add_library(SDL2::SDL2 INTERFACE IMPORTED)
set_target_properties(SDL2::SDL2 PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${SDL2_INCLUDE_DIRS}"
INTERFACE_LINK_LIBRARIES "${SDL2_LIBRARIES}"
)
endif()
endif()

find_package(Qt5 COMPONENTS Core Gui QUIET)
Expand Down
6 changes: 5 additions & 1 deletion PlugIns/Assimp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ target_include_directories(Codec_Assimp PUBLIC
target_link_libraries(Codec_Assimp PUBLIC OgreMain PRIVATE fix::assimp)
if(OGRE_BUILD_DEPENDENCIES)
# hack to get our CI build going, despite horribly broken assimp cmake
target_link_libraries(Codec_Assimp PRIVATE ZLIB::ZLIB ${OGREDEPS_PATH}/lib/IrrXML.lib)
if(UNIX)
target_link_libraries(Codec_Assimp PUBLIC ${OGREDEPS_PATH}/lib/libIrrXML.a)
else()
target_link_libraries(Codec_Assimp PRIVATE ZLIB::ZLIB ${OGREDEPS_PATH}/lib/IrrXML.lib)
endif()
endif()

ogre_config_framework(Codec_Assimp)
Expand Down