Update YAZE project configuration to use static SDL2 libraries and improve CMake integration
- Modified the `YAZE.vcxproj` file to replace dynamic SDL2 library dependencies with static versions, enhancing build performance and reducing runtime dependencies. - Updated `cmake/sdl2.cmake` to prioritize vcpkg for SDL2 on Windows, falling back to bundled SDL when necessary, and improved handling for non-Windows platforms. - Adjusted `cmake/vcpkg.cmake` to set the library linkage to static, ensuring consistent behavior across builds. - These changes streamline the build process and align with the project's library management strategy.
This commit is contained in:
@@ -1,29 +1,44 @@
|
||||
# SDL2
|
||||
if (UNIX OR MINGW OR WIN32)
|
||||
# On Windows, try to use vcpkg first, then fall back to bundled SDL
|
||||
if(WIN32)
|
||||
# Try to find SDL2 via vcpkg first
|
||||
find_package(SDL2 QUIET)
|
||||
if(SDL2_FOUND)
|
||||
# Use vcpkg SDL2
|
||||
set(SDL_TARGETS SDL2::SDL2)
|
||||
list(PREPEND SDL_TARGETS SDL2::SDL2main ws2_32)
|
||||
add_definitions("-DSDL_MAIN_HANDLED")
|
||||
message(STATUS "Using vcpkg SDL2")
|
||||
else()
|
||||
# Fall back to 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})
|
||||
list(PREPEND SDL_TARGETS SDL2main ws2_32)
|
||||
add_definitions("-DSDL_MAIN_HANDLED")
|
||||
message(STATUS "Using bundled SDL2")
|
||||
endif()
|
||||
elseif(UNIX OR MINGW)
|
||||
# Non-Windows: use bundled SDL
|
||||
add_subdirectory(src/lib/SDL)
|
||||
# When using bundled SDL, use the static target and set include directories
|
||||
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}
|
||||
)
|
||||
# Also set for consistency with bundled SDL
|
||||
set(SDL2_INCLUDE_DIRS ${SDL2_INCLUDE_DIR})
|
||||
|
||||
# Add SDL2main for Windows builds when using bundled SDL
|
||||
if(WIN32)
|
||||
list(PREPEND SDL_TARGETS SDL2main ws2_32)
|
||||
add_definitions("-DSDL_MAIN_HANDLED")
|
||||
endif()
|
||||
message(STATUS "Using bundled SDL2")
|
||||
else()
|
||||
# Fallback: try to find system SDL
|
||||
find_package(SDL2)
|
||||
# When using system SDL, use the imported targets
|
||||
set(SDL_TARGETS SDL2::SDL2)
|
||||
if(WIN32)
|
||||
list(PREPEND SDL_TARGETS SDL2::SDL2main ws2_32)
|
||||
add_definitions("-DSDL_MAIN_HANDLED")
|
||||
endif()
|
||||
message(STATUS "Using system SDL2")
|
||||
endif()
|
||||
|
||||
# PNG and ZLIB dependencies removed
|
||||
Reference in New Issue
Block a user