Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
spiroskou committed Aug 16, 2024
1 parent bb9aaf9 commit 917f21c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ include_directories(Board Pieces)
# Add source to this project's executable.
add_executable (OpenChess "main.cpp" "Pieces/Piece.h" "Pieces/King.h" "Pieces/King.cpp" "Pieces/Rook.h" "Pieces/Rook.cpp" "Pieces/Queen.h" "Pieces/Queen.cpp" "Pieces/Pawn.h" "Pieces/Pawn.cpp" "Pieces/Bishop.h" "Pieces/Bishop.cpp" "Pieces/Knight.h" "Pieces/Knight.cpp" "Board/Board.cpp" "Board/Board.h" "ChessSDL.cpp" "ChessSDL.h" "Pieces/Piece.cpp")

target_link_libraries(OpenChess ${SDL2_LIBRARIES} SDL2_image::SDL2_image)
target_link_libraries(OpenChess SDL2::SDL2 SDL2_image::SDL2_image)

if (CMAKE_VERSION VERSION_GREATER 3.12)
set_property(TARGET OpenChess PROPERTY CXX_STANDARD 20)
Expand Down
18 changes: 13 additions & 5 deletions cmake/modules/FindSDL2.cmake
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
# Locate SDL2 library and include directories
find_path(SDL2_INCLUDE_DIR NAME SDL.h HINTS ENV SDL2DIR PATH_SUFFIXES include/SDL2 include)
# FindSDL2.cmake
# Attempt to find the SDL2 library

find_library(SDL2_LIBRARY NAME SDL2 HINTS ENV SDL2DIR PATH_SUFFIXES lib lib/x64 lib/x86)
# Look for the header file.
find_path(SDL2_INCLUDE_DIR NAME SDL.h
HINTS $ENV{SDL2DIR}
PATH_SUFFIXES SDL2 include/SDL2 include)

# Look for the library.
find_library(SDL2_LIBRARY NAME SDL2
HINTS $ENV{SDL2DIR}
PATH_SUFFIXES lib64 lib32 lib
PATHS ${SDL2_PATH})

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(SDL2 DEFAULT_MSG SDL2_LIBRARY SDL2_INCLUDE_DIR)
find_package_handle_standard_args(SDL2 REQUIRED_VARS SDL2_LIBRARY SDL2_INCLUDE_DIR)

if(SDL2_FOUND AND NOT TARGET SDL2::SDL2)
add_library(SDL2::SDL2 UNKNOWN IMPORTED)
Expand All @@ -14,4 +23,3 @@ if(SDL2_FOUND AND NOT TARGET SDL2::SDL2)
endif()

mark_as_advanced(SDL2_INCLUDE_DIR SDL2_LIBRARY)

0 comments on commit 917f21c

Please sign in to comment.