Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
23 changes: 23 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
# manages its dependencies, and sets up installation rules.
# ===================================================================

message(STATUS "Configuring Prism Library (v${PROJECT_VERSION}).")

# --- Dependencies ---

include(FetchContent)
Expand All @@ -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)
Expand All @@ -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 ---

Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/include/Prism/core/style.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ 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;
}

/**
* @brief Logs a formatted completion message to std::clog.
* @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;
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/include/Prism/objects/ObjReader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ class ObjReader {
std::vector<std::array<unsigned int, 3>> triangles;

ObjReader(const std::string& filename) {
curMaterial = std::make_shared<Material>();

file.open(filename);
if (!file.is_open()) {
Style::logError("Erro ao abrir o arquivo: " + filename);
Expand Down