diff --git a/CMakeLists.txt b/CMakeLists.txt index 3ca556e..20ee4b6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,16 +21,30 @@ 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") + 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) +endif() + # Set a common output directory for all executables. 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/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; } /** 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);