Skip to content

Commit

Permalink
Fix building SDL2-image
Browse files Browse the repository at this point in the history
  • Loading branch information
tigertv committed Feb 4, 2023
1 parent 6f457ce commit d7b670b
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,23 @@ set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -s")

include_directories(${snake_SOURCE_DIR}/include)
file(COPY ../images DESTINATION .)

#set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
set(SHARE_SRC_FILES FoodBuilder.cpp Game.cpp AbstractGraphics.cpp BorderFrame.cpp Snake.cpp)
add_library(shareobjects OBJECT ${SHARE_SRC_FILES})

find_package(SDL2)
if(SDL2_FOUND)
#find_package(SDL2_image)
find_package(SDL2IMAGE)
#if (SDL2_IMAGE_FOUND)
find_package(SDL2_image)
if (SDL2_IMAGE_FOUND)
file(COPY ../images DESTINATION .)
set(SDL2_SRC_FILES graphics/SdlGraphics.cpp snake-sdl.cpp)
include_directories(${SDL2_INCLUDE_DIRS} ${SDL2_IMAGE_INCLUDE_DIRS})
add_executable(snake-sdl $<TARGET_OBJECTS:shareobjects> ${SDL2_SRC_FILES} )
#target_link_libraries(snake-sdl ${SDL2_LIBRARIES} ${SDL2_IMAGE_LIBRARIES})
target_link_libraries(snake-sdl ${SDL2_LIBRARIES} -lSDL2_image)
#else()
# message(WARNING "SDL2_image is not found.")
#endif()
target_link_libraries(snake-sdl ${SDL2_LIBRARIES} ${SDL2_IMAGE_LIBRARIES})
else()
message(WARNING "SDL2_image is not found.")
endif()
else()
message(WARNING "SDL2 is not found.")
endif()
Expand Down

0 comments on commit d7b670b

Please sign in to comment.