From 3364630a389504cbbcdfa0c36eb91112d180056c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Guimar=C3=A3es?= Date: Fri, 11 Jul 2025 08:06:23 -0300 Subject: [PATCH 1/4] Add debug postfix and update demo CMake policies Set CMAKE_DEBUG_POSTFIX based on build type for distinguishing debug binaries. Updated demo/CMakeLists.txt to set CMP0177 policy for proper path handling. --- CMakeLists.txt | 6 ++++++ demo/CMakeLists.txt | 3 +++ 2 files changed, 9 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3ca556e..28c218e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,6 +21,12 @@ set(CMAKE_CXX_EXTENSIONS OFF) set(BUILD_SHARED_LIBS ON CACHE BOOL "Build shared libraries" FORCE) option(PRISM_BUILD_DEMO "Build the Prism demo application" ON) +if (CMAKE_BUILD_TYPE STREQUAL "Debug") + set(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "Suffix for debug binaries" FORCE) +else() + set(CMAKE_DEBUG_POSTFIX "" CACHE STRING "Suffix for non-debug binaries" FORCE) +endif() + # Set a common output directory for all executables. set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) diff --git a/demo/CMakeLists.txt b/demo/CMakeLists.txt index 1459dfa..bed34e0 100644 --- a/demo/CMakeLists.txt +++ b/demo/CMakeLists.txt @@ -8,6 +8,9 @@ add_executable(prism_demo src/main.cpp) +# Policy to ensure proper handling of paths. +cmake_policy(SET CMP0177 NEW) + target_link_libraries(prism_demo PRIVATE Prism) set_target_properties(prism_demo PROPERTIES From b843d4234f4bb28c152d090a89208348abc79e6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Guimar=C3=A3es?= Date: Fri, 11 Jul 2025 08:06:34 -0300 Subject: [PATCH 2/4] Fix color reset in logInfo and logDone functions Adds an extra RESET escape sequence after the message in logInfo and logDone to ensure terminal color formatting is properly reset. --- src/include/Prism/core/style.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/include/Prism/core/style.hpp b/src/include/Prism/core/style.hpp index 4b53364..e2457b1 100644 --- a/src/include/Prism/core/style.hpp +++ b/src/include/Prism/core/style.hpp @@ -36,7 +36,7 @@ const std::string BOLD_YELLOW = "\033[1;33m"; * @param message The message to display. */ inline void logInfo(const std::string& message) { - std::clog << YELLOW << "[INFO] " << RESET << message << std::endl; + std::clog << YELLOW << "[INFO] " << RESET << message << RESET << std::endl; } /** @@ -44,7 +44,7 @@ inline void logInfo(const std::string& message) { * @param message The message to display. */ inline void logDone(const std::string& message) { - std::clog << GREEN << "[DONE] " << RESET << message << std::endl; + std::clog << GREEN << "[DONE] " << RESET << message << RESET << std::endl; } /** From 065a15103b690b113bfebc3b7fbcf19e4684b152 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Guimar=C3=A3es?= Date: Fri, 11 Jul 2025 08:16:41 -0300 Subject: [PATCH 3/4] Remove unused CMake policy CMP0177 Deleted the setting of CMake policy CMP0177 from demo/CMakeLists.txt as it is no longer needed for path handling. --- demo/CMakeLists.txt | 3 --- 1 file changed, 3 deletions(-) diff --git a/demo/CMakeLists.txt b/demo/CMakeLists.txt index bed34e0..1459dfa 100644 --- a/demo/CMakeLists.txt +++ b/demo/CMakeLists.txt @@ -8,9 +8,6 @@ add_executable(prism_demo src/main.cpp) -# Policy to ensure proper handling of paths. -cmake_policy(SET CMP0177 NEW) - target_link_libraries(prism_demo PRIVATE Prism) set_target_properties(prism_demo PROPERTIES From d07b960c9c63ba9abea2adc5e10cdb287d75fd26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Guimar=C3=A3es?= Date: Tue, 15 Jul 2025 14:18:39 -0300 Subject: [PATCH 4/4] Improve CMake configuration and ObjReader initialization Added informative status messages to CMake scripts for better build feedback and clarified module dependencies. In ObjReader, ensured curMaterial is initialized in the constructor to prevent potential issues with uninitialized materials. --- CMakeLists.txt | 10 +++++++++- src/CMakeLists.txt | 23 +++++++++++++++++++++++ src/include/Prism/objects/ObjReader.hpp | 2 ++ 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 28c218e..20ee4b6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,6 +22,7 @@ set(BUILD_SHARED_LIBS ON CACHE BOOL "Build shared libraries" FORCE) option(PRISM_BUILD_DEMO "Build the Prism demo application" ON) if (CMAKE_BUILD_TYPE STREQUAL "Debug") + message(STATUS "Building in Debug mode.") set(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "Suffix for debug binaries" FORCE) else() set(CMAKE_DEBUG_POSTFIX "" CACHE STRING "Suffix for non-debug binaries" FORCE) @@ -32,11 +33,18 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) # --- Sub-projects --- add_subdirectory(src) # The Prism library -add_subdirectory(demo) # The demo application + +if (PRISM_BUILD_DEMO) + message(STATUS "Building the Prism demo application.") + add_subdirectory(demo) # The demo application +else() + message(STATUS "Skipping the Prism demo application build.") +endif() # --- Testing --- enable_testing() if(BUILD_TESTING) + message(STATUS "Building tests for the Prism library.") # Fetch GoogleTest only when tests are enabled. include(FetchContent) FetchContent_Declare( diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index fba2e22..ea93b20 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -5,6 +5,8 @@ # manages its dependencies, and sets up installation rules. # =================================================================== +message(STATUS "Configuring Prism Library (v${PROJECT_VERSION}).") + # --- Dependencies --- include(FetchContent) @@ -16,6 +18,8 @@ FetchContent_Declare( ) FetchContent_MakeAvailable(yaml-cpp) +message(STATUS "Configuring yaml-cpp dependency: building SHARED library, tests/tools DISABLED.") + set(YAML_CPP_BUILD_CONTRIB OFF CACHE BOOL "Disable building yaml-cpp contrib tools" FORCE) set(YAML_CPP_BUILD_TOOLS OFF CACHE BOOL "Disable building yaml-cpp parse tools" FORCE) set(YAML_CPP_BUILD_TESTS OFF CACHE BOOL "Disable building yaml-cpp tests" FORCE) @@ -31,11 +35,23 @@ option(PRISM_BUILD_CORE "Build the Core module (math, etc.)" ON) option(PRISM_BUILD_OBJECTS "Build the Objects module (Sphere, Plane, Mesh, etc.)" ON) option(PRISM_BUILD_SCENE "Build the Scene module (Scene, Camera)" ON) +# --- Dependecy Management --- + # The CORE module is essential for all other parts of the library. if(NOT PRISM_BUILD_CORE) message(FATAL_ERROR "PRISM_BUILD_CORE is a required module and cannot be disabled.") endif() +# The OBJECTS module depends on the CORE module. +if(PRISM_BUILD_OBJECTS AND NOT PRISM_BUILD_CORE) + message(FATAL_ERROR "PRISM_BUILD_OBJECTS requires PRISM_BUILD_CORE to be enabled. Please enable PRISM_BUILD_CORE.") +endif() + +# The SCENE module depends on the OBJECTS module. +if(PRISM_BUILD_SCENE AND NOT PRISM_BUILD_OBJECTS) + message(FATAL_ERROR "PRISM_BUILD_SCENE requires PRISM_BUILD_OBJECTS to be enabled. Please enable PRISM_BUILD_OBJECTS.") +endif() + # --- Build Source File Collection --- @@ -44,19 +60,26 @@ set(PRISM_SOURCES "") # Always add the core source files. if(PRISM_BUILD_CORE) + message(STATUS "Prism Library: Core module ENABLED.") file(GLOB CORE_SOURCES CONFIGURE_DEPENDS "src/core/*.cpp") list(APPEND PRISM_SOURCES ${CORE_SOURCES}) endif() # Conditionally add sources for the other modules. if(PRISM_BUILD_OBJECTS) + message(STATUS "Prism Library: Objects module ENABLED.") file(GLOB GEOMETRY_SOURCES CONFIGURE_DEPENDS "src/objects/*.cpp") list(APPEND PRISM_SOURCES ${GEOMETRY_SOURCES}) +else() + message(STATUS "Prism Library: Objects module DISABLED.") endif() if(PRISM_BUILD_SCENE) + message(STATUS "Prism Library: Scene module ENABLED.") file(GLOB SCENE_SOURCES CONFIGURE_DEPENDS "src/scene/*.cpp") list(APPEND PRISM_SOURCES ${SCENE_SOURCES}) +else() + message(STATUS "Prism Library: Scene module DISABLED.") endif() # Add any remaining top-level source files (e.g., init.cpp) diff --git a/src/include/Prism/objects/ObjReader.hpp b/src/include/Prism/objects/ObjReader.hpp index 929f725..5ef134b 100644 --- a/src/include/Prism/objects/ObjReader.hpp +++ b/src/include/Prism/objects/ObjReader.hpp @@ -22,6 +22,8 @@ class ObjReader { std::vector> triangles; ObjReader(const std::string& filename) { + curMaterial = std::make_shared(); + file.open(filename); if (!file.is_open()) { Style::logError("Erro ao abrir o arquivo: " + filename);