Skip to content

Commit

Permalink
fix SDL2 includes
Browse files Browse the repository at this point in the history
  • Loading branch information
jakoch committed Jul 26, 2024
1 parent 7d44bdb commit 9e4d3ed
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
3 changes: 1 addition & 2 deletions CMake/packaging/fifechan.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@ includedir=@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@
Name: @CMAKE_PROJECT_NAME@
Description: Fifechan is a C++ GUI library designed for games.
Version: @PROJECT_VERSION@
Libs: -L${libdir} -lfifechan@ASSIMP_LIBRARY_SUFFIX@
Libs.private: @LIBSTDC++_LIBRARIES@
Libs: -L${libdir} -lfifechan
Cflags: -I${includedir}
5 changes: 2 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -308,15 +308,14 @@ if(SDL2_FOUND AND SDL2_image_FOUND)
add_library(${PROJECT_NAME}::${PROJECT_NAME}_sdl ALIAS ${PROJECT_NAME}_sdl)

target_include_directories(${PROJECT_NAME}_sdl PUBLIC
# Only set the SDL2 include dir, SDL2_image and SDL2_ttf are included in the SDL2 include directory.
$<BUILD_INTERFACE:${SDL2_INCLUDE_DIRS}>
$<BUILD_INTERFACE:${SDL2_IMAGE_INCLUDE_DIR}>
$<BUILD_INTERFACE:${SDL2_TTF_INCLUDE_DIRS}>
$<INSTALL_INTERFACE:include>
)

target_link_libraries(${PROJECT_NAME}_sdl PRIVATE
# SDL2::SDL2
$<TARGET_NAME_IF_EXISTS:SDL2::SDL2main>
#$<TARGET_NAME_IF_EXISTS:SDL2::SDL2main>
$<IF:$<TARGET_EXISTS:SDL2::SDL2>,SDL2::SDL2,SDL2::SDL2-static>
# SDL2::SDL2_image
$<IF:$<TARGET_EXISTS:SDL2_image::SDL2_image>,SDL2_image::SDL2_image,SDL2_image::SDL2_image-static>
Expand Down
17 changes: 11 additions & 6 deletions tests/integration/sdl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,28 @@
#message(STATUS "[ 🛠️ ] Building integration tests for SDL2")
#message(STATUS "---------------------------------------------------------------")

set(FIFECHAN_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/include")

#------------------------------------------------------------------------------
# sdlhelloworld
#------------------------------------------------------------------------------

add_executable(sdlhelloworld sdlhelloworld.cpp)

target_include_directories(sdlhelloworld PRIVATE
${SDL_INCLUDE_DIR}
${SDL_IMAGE_INCLUDE_DIR}
${SDL2_INCLUDE_DIRS}
${FIFECHAN_INCLUDE_DIR}
)

target_link_libraries(sdlhelloworld PRIVATE
# SDL2
$<TARGET_NAME_IF_EXISTS:SDL2::SDL2main>
$<IF:$<TARGET_EXISTS:SDL2::SDL2>,SDL2::SDL2,SDL2::SDL2-static>
${SDL_IMAGE_LIBRARIES}
# SDL2_image
$<IF:$<TARGET_EXISTS:SDL2_image::SDL2_image>,SDL2_image::SDL2_image,SDL2_image::SDL2_image-static>
# Fifechan
fifechan::fifechan
# Fifechan SDL extension
fifechan::fifechan_sdl
)

Expand All @@ -43,8 +47,7 @@ install(FILES "${IMAGE_SOURCE}" DESTINATION "${CMAKE_INSTALL_BINDIR}")
add_executable(sdlwidgets sdlwidgets.cpp)

target_include_directories(sdlwidgets PRIVATE
${SDL_INCLUDE_DIR}
${SDL_IMAGE_INCLUDE_DIR}
${SDL2_INCLUDE_DIR}
${FIFECHAN_INCLUDE_DIR}
)

Expand All @@ -53,8 +56,10 @@ target_link_libraries(sdlwidgets PRIVATE
$<TARGET_NAME_IF_EXISTS:SDL2::SDL2main>
$<IF:$<TARGET_EXISTS:SDL2::SDL2>,SDL2::SDL2,SDL2::SDL2-static>
# SDL2_image
${SDL_IMAGE_LIBRARIES}
$<IF:$<TARGET_EXISTS:SDL2_image::SDL2_image>,SDL2_image::SDL2_image,SDL2_image::SDL2_image-static>
# Fifechan
fifechan::fifechan
# Fifechan SDL extension
fifechan::fifechan_sdl
)

Expand Down

0 comments on commit 9e4d3ed

Please sign in to comment.