- Updated CMakeLists.txt to provide clearer logging and error messages for vcpkg integration, including detailed status reports for toolchain and triplet settings. - Modified CI workflows to utilize manifest mode for vcpkg installations, improving dependency management and build reliability. - Enhanced SDL2 and gRPC configurations to prioritize vcpkg packages, ensuring faster builds and clearer fallback mechanisms. - Improved overall CMake structure for better readability and maintainability, including updated messages for build configurations and warnings.
63 lines
2.2 KiB
CMake
63 lines
2.2 KiB
CMake
# SDL2
|
|
# On Windows with vcpkg, prefer vcpkg packages for faster builds
|
|
if(WIN32)
|
|
# Try to find SDL2 via vcpkg first if toolchain is available
|
|
if(DEFINED CMAKE_TOOLCHAIN_FILE AND EXISTS "${CMAKE_TOOLCHAIN_FILE}")
|
|
find_package(SDL2 CONFIG QUIET)
|
|
if(SDL2_FOUND OR TARGET SDL2::SDL2)
|
|
# Use vcpkg SDL2
|
|
if(TARGET SDL2::SDL2)
|
|
set(SDL_TARGETS SDL2::SDL2)
|
|
if(TARGET SDL2::SDL2main)
|
|
list(PREPEND SDL_TARGETS SDL2::SDL2main)
|
|
endif()
|
|
list(APPEND SDL_TARGETS ws2_32)
|
|
add_definitions("-DSDL_MAIN_HANDLED")
|
|
message(STATUS "✓ Using vcpkg SDL2")
|
|
|
|
# Get SDL2 include directories for reference
|
|
get_target_property(SDL2_INCLUDE_DIR SDL2::SDL2 INTERFACE_INCLUDE_DIRECTORIES)
|
|
set(SDL2_INCLUDE_DIRS ${SDL2_INCLUDE_DIR})
|
|
return()
|
|
endif()
|
|
endif()
|
|
endif()
|
|
|
|
# Fall back to bundled SDL if vcpkg not available or SDL2 not found
|
|
if(EXISTS "${CMAKE_SOURCE_DIR}/src/lib/SDL/CMakeLists.txt")
|
|
message(STATUS "○ vcpkg SDL2 not found, using bundled SDL2")
|
|
add_subdirectory(src/lib/SDL)
|
|
set(SDL_TARGETS SDL2-static)
|
|
set(SDL2_INCLUDE_DIR
|
|
${CMAKE_SOURCE_DIR}/src/lib/SDL/include
|
|
${CMAKE_BINARY_DIR}/src/lib/SDL/include
|
|
${CMAKE_BINARY_DIR}/src/lib/SDL/include-config-${CMAKE_BUILD_TYPE}
|
|
)
|
|
set(SDL2_INCLUDE_DIRS ${SDL2_INCLUDE_DIR})
|
|
if(TARGET SDL2main)
|
|
list(PREPEND SDL_TARGETS SDL2main)
|
|
endif()
|
|
list(APPEND SDL_TARGETS ws2_32)
|
|
add_definitions("-DSDL_MAIN_HANDLED")
|
|
else()
|
|
message(FATAL_ERROR "SDL2 not found via vcpkg and bundled SDL2 not available. Please install via vcpkg or ensure submodules are initialized.")
|
|
endif()
|
|
elseif(UNIX OR MINGW)
|
|
# Non-Windows: use bundled SDL
|
|
add_subdirectory(src/lib/SDL)
|
|
set(SDL_TARGETS SDL2-static)
|
|
set(SDL2_INCLUDE_DIR
|
|
${CMAKE_SOURCE_DIR}/src/lib/SDL/include
|
|
${CMAKE_BINARY_DIR}/src/lib/SDL/include
|
|
${CMAKE_BINARY_DIR}/src/lib/SDL/include-config-${CMAKE_BUILD_TYPE}
|
|
)
|
|
set(SDL2_INCLUDE_DIRS ${SDL2_INCLUDE_DIR})
|
|
message(STATUS "Using bundled SDL2")
|
|
else()
|
|
# Fallback: try to find system SDL
|
|
find_package(SDL2 REQUIRED)
|
|
set(SDL_TARGETS SDL2::SDL2)
|
|
message(STATUS "Using system SDL2")
|
|
endif()
|
|
|
|
# PNG and ZLIB dependencies removed |