fix cmake sdl finding, find_package for each cmake scope

This commit is contained in:
Green Sky 2022-10-31 22:35:55 +01:00 committed by Erik Scholz
parent 4d0f731d8d
commit dffbad65d2
5 changed files with 29 additions and 25 deletions

View File

@ -26,6 +26,7 @@ add_subdirectory("physfs")
if(NOT MM_HEADLESS) if(NOT MM_HEADLESS)
if(NOT EMSCRIPTEN) if(NOT EMSCRIPTEN)
# TODO: move into imgui and soload, since they are the one requireing this
if(VCPKG_TARGET_TRIPLET) if(VCPKG_TARGET_TRIPLET)
find_package(SDL2 CONFIG REQUIRED) find_package(SDL2 CONFIG REQUIRED)
else() # HACK: fix sdl find module else() # HACK: fix sdl find module

View File

@ -64,9 +64,9 @@ elseif(VCPKG_TARGET_TRIPLET)
target_link_libraries(imgui target_link_libraries(imgui
PUBLIC PUBLIC
SDL2::SDL2 SDL2::SDL2
PRIVATE #PRIVATE
SDL2::SDL2main #SDL2::SDL2main
SDL2::SDL2-static #SDL2::SDL2-static
) )
else() else()
target_include_directories(imgui PUBLIC "${SDL2_INCLUDE_DIR}") target_include_directories(imgui PUBLIC "${SDL2_INCLUDE_DIR}")

View File

@ -161,28 +161,27 @@ target_compile_definitions(soloud PRIVATE WITH_SDL2_STATIC)
target_include_directories(soloud SYSTEM PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/soloud/include") target_include_directories(soloud SYSTEM PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/soloud/include")
#if not android or emscripten if(EMSCRIPTEN)
if(VCPKG_TARGET_TRIPLET) target_compile_options(soloud PUBLIC -sUSE_SDL=2)
target_link_libraries(soloud PUBLIC -sUSE_SDL=2)
elseif(VCPKG_TARGET_TRIPLET)
target_link_libraries(soloud target_link_libraries(soloud
PUBLIC PUBLIC
SDL2::SDL2 SDL2::SDL2
PRIVATE #PRIVATE
SDL2::SDL2main #SDL2::SDL2main
SDL2::SDL2-static #SDL2::SDL2-static
) )
else() else()
target_include_directories(soloud PUBLIC "${SDL2_INCLUDE_DIR}") target_include_directories(soloud PUBLIC "${SDL2_INCLUDE_DIR}")
target_link_libraries(soloud PUBLIC ${SDL2_LIBRARY}) target_link_libraries(soloud PUBLIC ${SDL2_LIBRARY})
endif() endif()
#if not android or emscripten
#if android #if android
#target_link_libraries(soloud SDL) #target_link_libraries(soloud SDL)
#endif #endif
if(EMSCRIPTEN)
target_compile_options(soloud PUBLIC -sUSE_SDL=2)
target_link_libraries(soloud PUBLIC -sUSE_SDL=2)
endif()
# TODO: remove # TODO: remove

View File

@ -33,15 +33,18 @@ if(NOT MM_HEADLESS)
target_compile_options(filesystem_service PUBLIC -sUSE_SDL=2) target_compile_options(filesystem_service PUBLIC -sUSE_SDL=2)
target_link_libraries(filesystem_service PUBLIC -sUSE_SDL=2) target_link_libraries(filesystem_service PUBLIC -sUSE_SDL=2)
elseif(VCPKG_TARGET_TRIPLET) elseif(VCPKG_TARGET_TRIPLET)
find_package(SDL2 CONFIG REQUIRED)
target_link_libraries(filesystem_service target_link_libraries(filesystem_service
PUBLIC PUBLIC
SDL2::SDL2 SDL2::SDL2
PRIVATE #PRIVATE
SDL2::SDL2main #SDL2::SDL2main
SDL2::SDL2-static #SDL2::SDL2-static
) )
else() else()
#if not android or emscripten #if not android or emscripten
find_package(SDL2 REQUIRED)
target_include_directories(filesystem_service PUBLIC "${SDL2_INCLUDE_DIR}") target_include_directories(filesystem_service PUBLIC "${SDL2_INCLUDE_DIR}")
target_link_libraries(filesystem_service PUBLIC ${SDL2_LIBRARY}) target_link_libraries(filesystem_service PUBLIC ${SDL2_LIBRARY})
#endif #endif

View File

@ -27,8 +27,19 @@ target_link_libraries(sdl_service PUBLIC
if(EMSCRIPTEN) if(EMSCRIPTEN)
target_compile_options(sdl_service PUBLIC -sUSE_SDL=2) target_compile_options(sdl_service PUBLIC -sUSE_SDL=2)
target_link_libraries(sdl_service PUBLIC -sUSE_SDL=2) target_link_libraries(sdl_service PUBLIC -sUSE_SDL=2)
elseif(VCPKG_TARGET_TRIPLET)
find_package(SDL2 CONFIG REQUIRED)
target_link_libraries(sdl_service
PUBLIC
SDL2::SDL2
#PRIVATE
#SDL2::SDL2main
#SDL2::SDL2-static
)
else() else()
#if not android or emscripten #if not android or emscripten
find_package(SDL2 REQUIRED)
target_include_directories(sdl_service PUBLIC "${SDL2_INCLUDE_DIR}") target_include_directories(sdl_service PUBLIC "${SDL2_INCLUDE_DIR}")
target_link_libraries(sdl_service PUBLIC ${SDL2_LIBRARY}) target_link_libraries(sdl_service PUBLIC ${SDL2_LIBRARY})
#endif #endif
@ -40,16 +51,6 @@ else()
target_link_libraries(sdl_service PRIVATE glad) target_link_libraries(sdl_service PRIVATE glad)
endif() endif()
if(VCPKG_TARGET_TRIPLET)
target_link_libraries(sdl_service
PUBLIC
SDL2::SDL2
PRIVATE
SDL2::SDL2main
SDL2::SDL2-static
)
endif()
if(BUILD_TESTING) if(BUILD_TESTING)
add_subdirectory(test) add_subdirectory(test)
endif() endif()