Refactor CMake configuration for core library and testing
- Updated CMakeLists.txt to create a separate core library (yaze_core) for testing, enhancing modularity. - Adjusted source file organization for yaze_c and yaze_core, ensuring proper inclusion of essential components. - Modified test CMakeLists.txt to link against yaze_core instead of yaze_c, streamlining dependencies for test targets. - Disabled installation of the library in minimal builds while maintaining the ability to build for testing purposes.
This commit is contained in:
@@ -32,12 +32,14 @@ option(YAZE_ENABLE_EXPERIMENTAL_TESTS "Enable experimental/unstable tests" ON)
|
|||||||
option(YAZE_ENABLE_UI_TESTS "Enable ImGui Test Engine UI testing" ON)
|
option(YAZE_ENABLE_UI_TESTS "Enable ImGui Test Engine UI testing" 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)
|
||||||
|
|
||||||
# Disable optional components in minimal builds
|
# Configure minimal builds for CI/CD
|
||||||
if(YAZE_MINIMAL_BUILD)
|
if(YAZE_MINIMAL_BUILD)
|
||||||
set(YAZE_ENABLE_UI_TESTS OFF CACHE BOOL "Disabled for minimal build" FORCE)
|
set(YAZE_ENABLE_UI_TESTS OFF CACHE BOOL "Disabled for minimal build" FORCE)
|
||||||
set(YAZE_BUILD_EMU OFF CACHE BOOL "Disabled for minimal build" FORCE)
|
|
||||||
set(YAZE_BUILD_Z3ED OFF CACHE BOOL "Disabled for minimal build" FORCE)
|
set(YAZE_BUILD_Z3ED OFF CACHE BOOL "Disabled for minimal build" FORCE)
|
||||||
set(YAZE_BUILD_LIB OFF CACHE BOOL "Disabled for minimal build" FORCE)
|
# Keep EMU and LIB enabled for comprehensive testing
|
||||||
|
set(YAZE_BUILD_EMU ON CACHE BOOL "Required for test suite" FORCE)
|
||||||
|
set(YAZE_BUILD_LIB ON CACHE BOOL "Required for test suite" FORCE)
|
||||||
|
set(YAZE_INSTALL_LIB OFF CACHE BOOL "Disabled for minimal build" FORCE)
|
||||||
endif()
|
endif()
|
||||||
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")
|
||||||
|
|
||||||
|
|||||||
@@ -119,36 +119,80 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Yaze C API
|
# Yaze Core Library (for testing and C API)
|
||||||
if (YAZE_BUILD_LIB)
|
if (YAZE_BUILD_LIB)
|
||||||
# Create source list for yaze_c
|
# Create core library for testing (includes editor and zelda3 components needed by tests)
|
||||||
set(YAZE_C_SOURCES
|
set(YAZE_CORE_SOURCES
|
||||||
./yaze.cc
|
|
||||||
app/rom.cc
|
app/rom.cc
|
||||||
${YAZE_APP_EMU_SRC}
|
|
||||||
${YAZE_APP_CORE_SRC}
|
${YAZE_APP_CORE_SRC}
|
||||||
|
${YAZE_APP_GFX_SRC}
|
||||||
${YAZE_APP_EDITOR_SRC}
|
${YAZE_APP_EDITOR_SRC}
|
||||||
${YAZE_APP_GFX_SRC}
|
|
||||||
${YAZE_APP_ZELDA3_SRC}
|
${YAZE_APP_ZELDA3_SRC}
|
||||||
|
${YAZE_APP_EMU_SRC}
|
||||||
${YAZE_GUI_SRC}
|
${YAZE_GUI_SRC}
|
||||||
${YAZE_UTIL_SRC}
|
${YAZE_UTIL_SRC}
|
||||||
|
)
|
||||||
|
|
||||||
|
# Create full library for C API
|
||||||
|
set(YAZE_C_SOURCES
|
||||||
|
./yaze.cc
|
||||||
|
${YAZE_CORE_SOURCES}
|
||||||
|
${YAZE_GUI_SRC}
|
||||||
${IMGUI_SRC}
|
${IMGUI_SRC}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Add emulator sources only in full builds
|
||||||
|
if(NOT YAZE_MINIMAL_BUILD)
|
||||||
|
list(APPEND YAZE_C_SOURCES ${YAZE_APP_EMU_SRC})
|
||||||
|
endif()
|
||||||
|
|
||||||
# Only add ImGui Test Engine sources if UI tests are enabled
|
# Only add ImGui Test Engine sources if UI tests are enabled
|
||||||
if(YAZE_ENABLE_UI_TESTS)
|
if(YAZE_ENABLE_UI_TESTS)
|
||||||
list(APPEND YAZE_C_SOURCES ${IMGUI_TEST_ENGINE_SOURCES})
|
list(APPEND YAZE_C_SOURCES ${IMGUI_TEST_ENGINE_SOURCES})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# Create the core library (static for testing)
|
||||||
|
add_library(yaze_core STATIC ${YAZE_CORE_SOURCES})
|
||||||
|
|
||||||
|
# Create the full C API library (shared)
|
||||||
add_library(yaze_c SHARED ${YAZE_C_SOURCES})
|
add_library(yaze_c SHARED ${YAZE_C_SOURCES})
|
||||||
|
|
||||||
|
# Configure core library (for testing)
|
||||||
target_include_directories(
|
target_include_directories(
|
||||||
yaze_c PUBLIC
|
yaze_core PUBLIC
|
||||||
lib/
|
${CMAKE_SOURCE_DIR}/src/lib/
|
||||||
app/
|
${CMAKE_SOURCE_DIR}/src/app/
|
||||||
|
${CMAKE_SOURCE_DIR}/src/lib/asar/src
|
||||||
|
${CMAKE_SOURCE_DIR}/src/lib/asar/src/asar
|
||||||
|
${CMAKE_SOURCE_DIR}/src/lib/asar/src/asar-dll-bindings/c
|
||||||
${CMAKE_SOURCE_DIR}/incl/
|
${CMAKE_SOURCE_DIR}/incl/
|
||||||
${CMAKE_SOURCE_DIR}/src/
|
${CMAKE_SOURCE_DIR}/src/
|
||||||
${ASAR_INCLUDE_DIRS}
|
${CMAKE_SOURCE_DIR}/src/lib/imgui
|
||||||
|
${CMAKE_SOURCE_DIR}/src/lib/imgui_test_engine
|
||||||
|
${SDL2_INCLUDE_DIR}
|
||||||
|
${PROJECT_BINARY_DIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(
|
||||||
|
yaze_core PUBLIC
|
||||||
|
asar-static
|
||||||
|
${ABSL_TARGETS}
|
||||||
|
${SDL_TARGETS}
|
||||||
|
${CMAKE_DL_LIBS}
|
||||||
|
ImGui
|
||||||
|
)
|
||||||
|
|
||||||
|
# Configure full C API library
|
||||||
|
target_include_directories(
|
||||||
|
yaze_c PUBLIC
|
||||||
|
${CMAKE_SOURCE_DIR}/src/lib/
|
||||||
|
${CMAKE_SOURCE_DIR}/src/app/
|
||||||
|
${CMAKE_SOURCE_DIR}/src/lib/asar/src
|
||||||
|
${CMAKE_SOURCE_DIR}/src/lib/asar/src/asar
|
||||||
|
${CMAKE_SOURCE_DIR}/src/lib/asar/src/asar-dll-bindings/c
|
||||||
|
${CMAKE_SOURCE_DIR}/incl/
|
||||||
|
${CMAKE_SOURCE_DIR}/src/
|
||||||
|
${CMAKE_SOURCE_DIR}/src/lib/imgui_test_engine
|
||||||
${SDL2_INCLUDE_DIR}
|
${SDL2_INCLUDE_DIR}
|
||||||
${PROJECT_BINARY_DIR}
|
${PROJECT_BINARY_DIR}
|
||||||
)
|
)
|
||||||
@@ -156,16 +200,13 @@ if (YAZE_BUILD_LIB)
|
|||||||
# Conditionally add PNG include dirs if available
|
# Conditionally add PNG include dirs if available
|
||||||
if(PNG_FOUND)
|
if(PNG_FOUND)
|
||||||
target_include_directories(yaze_c PUBLIC ${PNG_INCLUDE_DIRS})
|
target_include_directories(yaze_c PUBLIC ${PNG_INCLUDE_DIRS})
|
||||||
|
target_include_directories(yaze_core PUBLIC ${PNG_INCLUDE_DIRS})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
yaze_c PRIVATE
|
yaze_c PRIVATE
|
||||||
asar-static
|
yaze_core
|
||||||
${ABSL_TARGETS}
|
|
||||||
${SDL_TARGETS}
|
|
||||||
${CMAKE_DL_LIBS}
|
|
||||||
ImGui
|
ImGui
|
||||||
Threads::Threads
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Conditionally link ImGui Test Engine and set definitions
|
# Conditionally link ImGui Test Engine and set definitions
|
||||||
@@ -179,6 +220,7 @@ if (YAZE_BUILD_LIB)
|
|||||||
# Conditionally link PNG if available
|
# Conditionally link PNG if available
|
||||||
if(PNG_FOUND)
|
if(PNG_FOUND)
|
||||||
target_link_libraries(yaze_c PRIVATE ${PNG_LIBRARIES})
|
target_link_libraries(yaze_c PRIVATE ${PNG_LIBRARIES})
|
||||||
|
target_link_libraries(yaze_core PRIVATE ${PNG_LIBRARIES})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (YAZE_INSTALL_LIB)
|
if (YAZE_INSTALL_LIB)
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ target_link_libraries(
|
|||||||
gtest
|
gtest
|
||||||
)
|
)
|
||||||
|
|
||||||
# Conditionally link yaze_c only when library is built
|
# Link core library for essential functionality (BPS, ASAR, etc.)
|
||||||
if(YAZE_BUILD_LIB)
|
if(YAZE_BUILD_LIB)
|
||||||
target_link_libraries(yaze_test yaze_c)
|
target_link_libraries(yaze_test yaze_c)
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
Reference in New Issue
Block a user