From cbe6c92da724dbae3d46b4ef68144d23aa18028e Mon Sep 17 00:00:00 2001 From: scawful Date: Sun, 28 Sep 2025 19:18:36 -0400 Subject: [PATCH] Enhance CMake configuration for yaze_config.h integration - Updated `CMakeLists.txt` to improve the generation and inclusion of `yaze_config.h` by specifying source and binary directories. - Added include directories in various CMake files to ensure proper access to generated headers, enhancing build reliability and maintainability. - Set properties for the generated header to improve IDE integration and organization within the project structure. --- CMakeLists.txt | 8 +++++++- src/CMakeLists.txt | 1 + src/app/app.cmake | 13 +++++++++++++ src/app/emu/emu.cmake | 1 + src/cli/z3ed.cmake | 1 + 5 files changed, 23 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5c50052e..530f56ec 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,7 +35,11 @@ set(YAZE_VERSION_MAJOR 0) set(YAZE_VERSION_MINOR 3) set(YAZE_VERSION_PATCH 1) -configure_file(src/yaze_config.h.in yaze_config.h @ONLY) +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/src/yaze_config.h.in + ${CMAKE_CURRENT_BINARY_DIR}/yaze_config.h + @ONLY +) # Build Flags set(YAZE_BUILD_APP ON) @@ -96,6 +100,8 @@ elseif(CMAKE_SYSTEM_NAME MATCHES "Windows") set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake" CACHE STRING "Vcpkg toolchain file") endif() + # Setup yaze_config include directories + endif() # Create a common interface target for shared settings diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a3a08c3e..24d54f5b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -199,6 +199,7 @@ if (YAZE_BUILD_LIB) ${CMAKE_SOURCE_DIR}/src/lib/imgui_test_engine ${SDL2_INCLUDE_DIR} ${PROJECT_BINARY_DIR} + ${CMAKE_CURRENT_BINARY_DIR} ) target_link_libraries( diff --git a/src/app/app.cmake b/src/app/app.cmake index 879dac31..9bf81132 100644 --- a/src/app/app.cmake +++ b/src/app/app.cmake @@ -66,9 +66,22 @@ target_include_directories( ${CMAKE_SOURCE_DIR}/src/ ${CMAKE_SOURCE_DIR}/src/lib/imgui_test_engine ${SDL2_INCLUDE_DIR} + ${CMAKE_CURRENT_BINARY_DIR} ${PROJECT_BINARY_DIR} ) +target_sources(yaze PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/yaze_config.h) + +# 4) Tell the IDE it’s generated +set_source_files_properties( + ${CMAKE_CURRENT_BINARY_DIR}/yaze_config.h + PROPERTIES GENERATED TRUE +) + +# (Optional) put it under a neat filter in VS Solution Explorer +source_group(TREE ${CMAKE_CURRENT_BINARY_DIR} + FILES ${CMAKE_CURRENT_BINARY_DIR}/yaze_config.h) + # Conditionally add PNG include dirs if available if(PNG_FOUND) target_include_directories(yaze PUBLIC ${PNG_INCLUDE_DIRS}) diff --git a/src/app/emu/emu.cmake b/src/app/emu/emu.cmake index 5bc69174..504f61c9 100644 --- a/src/app/emu/emu.cmake +++ b/src/app/emu/emu.cmake @@ -46,6 +46,7 @@ if(NOT YAZE_MINIMAL_BUILD) ${CMAKE_SOURCE_DIR}/src/lib/imgui_test_engine ${PNG_INCLUDE_DIRS} ${SDL2_INCLUDE_DIR} + ${CMAKE_CURRENT_BINARY_DIR} ${PROJECT_BINARY_DIR} ) diff --git a/src/cli/z3ed.cmake b/src/cli/z3ed.cmake index 9d85921f..4e8d94ef 100644 --- a/src/cli/z3ed.cmake +++ b/src/cli/z3ed.cmake @@ -52,6 +52,7 @@ target_include_directories( ${CMAKE_SOURCE_DIR}/src/lib/imgui_test_engine ${PNG_INCLUDE_DIRS} ${SDL2_INCLUDE_DIR} + ${CMAKE_CURRENT_BINARY_DIR} ${PROJECT_BINARY_DIR} )