Skip to content

Commit

Permalink
cmake: only require SDL3::SDL3-shared when building a shared SDL3_sha…
Browse files Browse the repository at this point in the history
…dercross library
  • Loading branch information
madebr committed Jan 24, 2025
1 parent ac425b2 commit 59d98c5
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ include("${CMAKE_CURRENT_LIST_DIR}/cmake/PrivateSdlFunctions.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/cmake/sdlcpu.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/cmake/sdlplatform.cmake")

if(NOT TARGET SDL3::Headers OR NOT TARGET SDL3::SDL3-shared)
find_package(SDL3 ${SDL_REQUIRED_VERSION} REQUIRED COMPONENTS Headers SDL3-shared)
if(NOT TARGET SDL3::SDL3-static)
find_package(SDL3 ${SDL_REQUIRED_VERSION})
endif()

if(BUILD_SHARED_LIBS)
Expand Down Expand Up @@ -165,6 +165,10 @@ set(SOURCE_FILES
set(SDL3_shadercross_targets)
if(SDLSHADERCROSS_SHARED)
list(APPEND SDL3_shadercross_targets SDL3_shadercross-shared)
if(NOT TARGET SDL3::Headers OR NOT TARGET SDL3::SDL3-shared)
find_package(SDL3 ${SDL_REQUIRED_VERSION} REQUIRED COMPONENTS Headers SDL3-shared)
endif()

add_library(SDL3_shadercross-shared SHARED ${SOURCE_FILES})
add_library(SDL3_shadercross::SDL3_shadercross ALIAS SDL3_shadercross-shared)

Expand Down Expand Up @@ -198,7 +202,7 @@ endif()

if(SDLSHADERCROSS_STATIC)
list(APPEND SDL3_shadercross_targets SDL3_shadercross-static)
if(NOT TARGET SDL3::Headers OR NOT TARGET SDL3::SDL3)
if(NOT TARGET SDL3::Headers)
find_package(SDL3 ${SDL_REQUIRED_VERSION} REQUIRED COMPONENTS Headers)
endif()

Expand Down Expand Up @@ -265,6 +269,9 @@ if(SDLSHADERCROSS_CLI)
target_link_libraries(shadercross PRIVATE SDL3_shadercross::SDL3_shadercross-static)
target_link_libraries(shadercross PRIVATE SDL3::SDL3-static)
else()
if(NOT TARGET SDL3::SDL3)
find_package(SDL3 ${SDL_REQUIRED_VERSION} REQUIRED CONFIG COMPONENTS SDL3)
endif()
target_link_libraries(shadercross PRIVATE SDL3_shadercross::SDL3_shadercross)
target_link_libraries(shadercross PRIVATE SDL3::SDL3)
endif()
Expand Down

0 comments on commit 59d98c5

Please sign in to comment.