Enhance CMake configuration for PNG support and introduce vcpkg.json
- Updated CMakeLists.txt to conditionally enable PNG support based on the presence of the PNG library, improving compatibility for minimal builds. - Added vcpkg.json to manage project dependencies, including zlib, libpng, sdl2, and abseil, streamlining package management. - Modified CI workflow in ci.yml to simplify CMake configuration commands for better readability. - Enhanced CMake scripts to ensure proper handling of dependencies in both minimal and regular builds, improving build reliability.
This commit is contained in:
11
.github/workflows/ci.yml
vendored
11
.github/workflows/ci.yml
vendored
@@ -166,16 +166,9 @@ jobs:
|
|||||||
|
|
||||||
- name: Configure CMake (Windows)
|
- name: Configure CMake (Windows)
|
||||||
if: runner.os == 'Windows'
|
if: runner.os == 'Windows'
|
||||||
|
shell: cmd
|
||||||
run: |
|
run: |
|
||||||
cmake -B ${{ github.workspace }}/build ^
|
cmake -B ${{ github.workspace }}/build -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} -DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=${{ matrix.vcpkg_triplet }} -DYAZE_MINIMAL_BUILD=ON -DYAZE_ENABLE_ROM_TESTS=OFF -DYAZE_ENABLE_EXPERIMENTAL_TESTS=OFF -G "${{ matrix.cmake_generator }}" -A ${{ matrix.cmake_generator_platform }}
|
||||||
-DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} ^
|
|
||||||
-DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake ^
|
|
||||||
-DVCPKG_TARGET_TRIPLET=${{ matrix.vcpkg_triplet }} ^
|
|
||||||
-DYAZE_MINIMAL_BUILD=ON ^
|
|
||||||
-DYAZE_ENABLE_ROM_TESTS=OFF ^
|
|
||||||
-DYAZE_ENABLE_EXPERIMENTAL_TESTS=OFF ^
|
|
||||||
-G "${{ matrix.cmake_generator }}" ^
|
|
||||||
-A ${{ matrix.cmake_generator_platform }}
|
|
||||||
|
|
||||||
# Build
|
# Build
|
||||||
- name: Build
|
- name: Build
|
||||||
|
|||||||
@@ -26,8 +26,13 @@ option(YAZE_ENABLE_EXPERIMENTAL_TESTS "Enable experimental/unstable tests" ON)
|
|||||||
option(YAZE_MINIMAL_BUILD "Minimal build for CI (disable optional features)" OFF)
|
option(YAZE_MINIMAL_BUILD "Minimal build for CI (disable optional features)" OFF)
|
||||||
set(YAZE_TEST_ROM_PATH "${CMAKE_BINARY_DIR}/bin/zelda3.sfc" CACHE STRING "Path to test ROM file")
|
set(YAZE_TEST_ROM_PATH "${CMAKE_BINARY_DIR}/bin/zelda3.sfc" CACHE STRING "Path to test ROM file")
|
||||||
|
|
||||||
# libpng features in bitmap.cc
|
# libpng features in bitmap.cc - conditional for minimal builds
|
||||||
add_definitions("-DYAZE_LIB_PNG=1")
|
if(PNG_FOUND)
|
||||||
|
add_definitions("-DYAZE_LIB_PNG=1")
|
||||||
|
else()
|
||||||
|
add_definitions("-DYAZE_LIB_PNG=0")
|
||||||
|
message(STATUS "Building without PNG support for minimal build")
|
||||||
|
endif()
|
||||||
|
|
||||||
# Modern CMake standards
|
# Modern CMake standards
|
||||||
set(CMAKE_CXX_STANDARD 23)
|
set(CMAKE_CXX_STANDARD 23)
|
||||||
|
|||||||
@@ -1,7 +1,15 @@
|
|||||||
if (MINGW)
|
if (MINGW OR WIN32)
|
||||||
|
add_subdirectory(src/lib/abseil-cpp)
|
||||||
|
elseif(YAZE_MINIMAL_BUILD)
|
||||||
|
# For CI builds, always use submodule to avoid dependency issues
|
||||||
add_subdirectory(src/lib/abseil-cpp)
|
add_subdirectory(src/lib/abseil-cpp)
|
||||||
else()
|
else()
|
||||||
find_package(absl)
|
# Try system package first, fallback to submodule
|
||||||
|
find_package(absl QUIET)
|
||||||
|
if(NOT absl_FOUND)
|
||||||
|
message(STATUS "System Abseil not found, using submodule")
|
||||||
|
add_subdirectory(src/lib/abseil-cpp)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
set(ABSL_PROPAGATE_CXX_STD ON)
|
set(ABSL_PROPAGATE_CXX_STD ON)
|
||||||
set(ABSL_CXX_STANDARD 17)
|
set(ABSL_CXX_STANDARD 17)
|
||||||
|
|||||||
@@ -12,5 +12,23 @@ if(WIN32 OR MINGW)
|
|||||||
add_definitions("-DSDL_MAIN_HANDLED")
|
add_definitions("-DSDL_MAIN_HANDLED")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# libpng
|
# libpng and ZLIB dependencies
|
||||||
find_package(PNG REQUIRED)
|
if(WIN32 AND NOT YAZE_MINIMAL_BUILD)
|
||||||
|
# Use vcpkg on Windows
|
||||||
|
find_package(ZLIB REQUIRED)
|
||||||
|
find_package(PNG REQUIRED)
|
||||||
|
elseif(YAZE_MINIMAL_BUILD)
|
||||||
|
# For CI builds, try to find but don't require
|
||||||
|
find_package(ZLIB QUIET)
|
||||||
|
find_package(PNG QUIET)
|
||||||
|
if(NOT ZLIB_FOUND OR NOT PNG_FOUND)
|
||||||
|
message(STATUS "PNG/ZLIB not found in minimal build, some features may be disabled")
|
||||||
|
set(PNG_FOUND FALSE)
|
||||||
|
set(PNG_LIBRARIES "")
|
||||||
|
set(PNG_INCLUDE_DIRS "")
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
# Regular builds require these dependencies
|
||||||
|
find_package(ZLIB REQUIRED)
|
||||||
|
find_package(PNG REQUIRED)
|
||||||
|
endif()
|
||||||
@@ -119,22 +119,30 @@ if (YAZE_BUILD_LIB)
|
|||||||
${CMAKE_SOURCE_DIR}/incl/
|
${CMAKE_SOURCE_DIR}/incl/
|
||||||
${CMAKE_SOURCE_DIR}/src/
|
${CMAKE_SOURCE_DIR}/src/
|
||||||
${ASAR_INCLUDE_DIRS}
|
${ASAR_INCLUDE_DIRS}
|
||||||
${PNG_INCLUDE_DIRS}
|
|
||||||
${SDL2_INCLUDE_DIR}
|
${SDL2_INCLUDE_DIR}
|
||||||
${PROJECT_BINARY_DIR}
|
${PROJECT_BINARY_DIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Conditionally add PNG include dirs if available
|
||||||
|
if(PNG_FOUND)
|
||||||
|
target_include_directories(yaze_c PUBLIC ${PNG_INCLUDE_DIRS})
|
||||||
|
endif()
|
||||||
|
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
yaze_c PRIVATE
|
yaze_c PRIVATE
|
||||||
asar-static
|
asar-static
|
||||||
${ABSL_TARGETS}
|
${ABSL_TARGETS}
|
||||||
${SDL_TARGETS}
|
${SDL_TARGETS}
|
||||||
${PNG_LIBRARIES}
|
|
||||||
${CMAKE_DL_LIBS}
|
${CMAKE_DL_LIBS}
|
||||||
ImGuiTestEngine
|
ImGuiTestEngine
|
||||||
ImGui
|
ImGui
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Conditionally link PNG if available
|
||||||
|
if(PNG_FOUND)
|
||||||
|
target_link_libraries(yaze_c PRIVATE ${PNG_LIBRARIES})
|
||||||
|
endif()
|
||||||
|
|
||||||
if (YAZE_INSTALL_LIB)
|
if (YAZE_INSTALL_LIB)
|
||||||
install(TARGETS yaze_c
|
install(TARGETS yaze_c
|
||||||
RUNTIME DESTINATION bin
|
RUNTIME DESTINATION bin
|
||||||
|
|||||||
@@ -45,11 +45,15 @@ target_include_directories(
|
|||||||
${CMAKE_SOURCE_DIR}/incl/
|
${CMAKE_SOURCE_DIR}/incl/
|
||||||
${CMAKE_SOURCE_DIR}/src/
|
${CMAKE_SOURCE_DIR}/src/
|
||||||
${CMAKE_SOURCE_DIR}/src/lib/imgui_test_engine
|
${CMAKE_SOURCE_DIR}/src/lib/imgui_test_engine
|
||||||
${PNG_INCLUDE_DIRS}
|
|
||||||
${SDL2_INCLUDE_DIR}
|
${SDL2_INCLUDE_DIR}
|
||||||
${PROJECT_BINARY_DIR}
|
${PROJECT_BINARY_DIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Conditionally add PNG include dirs if available
|
||||||
|
if(PNG_FOUND)
|
||||||
|
target_include_directories(yaze PUBLIC ${PNG_INCLUDE_DIRS})
|
||||||
|
endif()
|
||||||
|
|
||||||
# Conditionally link nfd if available
|
# Conditionally link nfd if available
|
||||||
if(YAZE_HAS_NFD)
|
if(YAZE_HAS_NFD)
|
||||||
target_link_libraries(yaze PRIVATE nfd)
|
target_link_libraries(yaze PRIVATE nfd)
|
||||||
@@ -63,12 +67,16 @@ target_link_libraries(
|
|||||||
asar-static
|
asar-static
|
||||||
${ABSL_TARGETS}
|
${ABSL_TARGETS}
|
||||||
${SDL_TARGETS}
|
${SDL_TARGETS}
|
||||||
${PNG_LIBRARIES}
|
|
||||||
${CMAKE_DL_LIBS}
|
${CMAKE_DL_LIBS}
|
||||||
ImGui
|
ImGui
|
||||||
ImGuiTestEngine
|
ImGuiTestEngine
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Conditionally link PNG if available
|
||||||
|
if(PNG_FOUND)
|
||||||
|
target_link_libraries(yaze PUBLIC ${PNG_LIBRARIES})
|
||||||
|
endif()
|
||||||
|
|
||||||
if (APPLE)
|
if (APPLE)
|
||||||
target_link_libraries(yaze PUBLIC ${COCOA_LIBRARY})
|
target_link_libraries(yaze PUBLIC ${COCOA_LIBRARY})
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "project.h"
|
#include "project.h"
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "app/gui/icons.h"
|
#include "app/gui/icons.h"
|
||||||
|
|||||||
12
vcpkg.json
Normal file
12
vcpkg.json
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"name": "yaze",
|
||||||
|
"version": "0.3.0",
|
||||||
|
"description": "Yet Another Zelda3 Editor",
|
||||||
|
"dependencies": [
|
||||||
|
"zlib",
|
||||||
|
"libpng",
|
||||||
|
"sdl2",
|
||||||
|
"abseil"
|
||||||
|
],
|
||||||
|
"builtin-baseline": "c8696863d371ab7f46e213d8f5ca923c4aef2a00"
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user