Skip to content

Commit bee549c

Browse files
authored
fix(build & log) (#21)
1 parent cde0a77 commit bee549c

File tree

4 files changed

+42
-3
lines changed

4 files changed

+42
-3
lines changed

CMakeLists.txt

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,30 @@ set(CMAKE_CXX_EXTENSIONS OFF)
2121
set(BUILD_SHARED_LIBS ON CACHE BOOL "Build shared libraries" FORCE)
2222
option(PRISM_BUILD_DEMO "Build the Prism demo application" ON)
2323

24+
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
25+
message(STATUS "Building in Debug mode.")
26+
set(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "Suffix for debug binaries" FORCE)
27+
else()
28+
set(CMAKE_DEBUG_POSTFIX "" CACHE STRING "Suffix for non-debug binaries" FORCE)
29+
endif()
30+
2431
# Set a common output directory for all executables.
2532
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
2633

2734
# --- Sub-projects ---
2835
add_subdirectory(src) # The Prism library
29-
add_subdirectory(demo) # The demo application
36+
37+
if (PRISM_BUILD_DEMO)
38+
message(STATUS "Building the Prism demo application.")
39+
add_subdirectory(demo) # The demo application
40+
else()
41+
message(STATUS "Skipping the Prism demo application build.")
42+
endif()
3043

3144
# --- Testing ---
3245
enable_testing()
3346
if(BUILD_TESTING)
47+
message(STATUS "Building tests for the Prism library.")
3448
# Fetch GoogleTest only when tests are enabled.
3549
include(FetchContent)
3650
FetchContent_Declare(

src/CMakeLists.txt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
# manages its dependencies, and sets up installation rules.
66
# ===================================================================
77

8+
message(STATUS "Configuring Prism Library (v${PROJECT_VERSION}).")
9+
810
# --- Dependencies ---
911

1012
include(FetchContent)
@@ -16,6 +18,8 @@ FetchContent_Declare(
1618
)
1719
FetchContent_MakeAvailable(yaml-cpp)
1820

21+
message(STATUS "Configuring yaml-cpp dependency: building SHARED library, tests/tools DISABLED.")
22+
1923
set(YAML_CPP_BUILD_CONTRIB OFF CACHE BOOL "Disable building yaml-cpp contrib tools" FORCE)
2024
set(YAML_CPP_BUILD_TOOLS OFF CACHE BOOL "Disable building yaml-cpp parse tools" FORCE)
2125
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)
3135
option(PRISM_BUILD_OBJECTS "Build the Objects module (Sphere, Plane, Mesh, etc.)" ON)
3236
option(PRISM_BUILD_SCENE "Build the Scene module (Scene, Camera)" ON)
3337

38+
# --- Dependecy Management ---
39+
3440
# The CORE module is essential for all other parts of the library.
3541
if(NOT PRISM_BUILD_CORE)
3642
message(FATAL_ERROR "PRISM_BUILD_CORE is a required module and cannot be disabled.")
3743
endif()
3844

45+
# The OBJECTS module depends on the CORE module.
46+
if(PRISM_BUILD_OBJECTS AND NOT PRISM_BUILD_CORE)
47+
message(FATAL_ERROR "PRISM_BUILD_OBJECTS requires PRISM_BUILD_CORE to be enabled. Please enable PRISM_BUILD_CORE.")
48+
endif()
49+
50+
# The SCENE module depends on the OBJECTS module.
51+
if(PRISM_BUILD_SCENE AND NOT PRISM_BUILD_OBJECTS)
52+
message(FATAL_ERROR "PRISM_BUILD_SCENE requires PRISM_BUILD_OBJECTS to be enabled. Please enable PRISM_BUILD_OBJECTS.")
53+
endif()
54+
3955

4056
# --- Build Source File Collection ---
4157

@@ -44,19 +60,26 @@ set(PRISM_SOURCES "")
4460

4561
# Always add the core source files.
4662
if(PRISM_BUILD_CORE)
63+
message(STATUS "Prism Library: Core module ENABLED.")
4764
file(GLOB CORE_SOURCES CONFIGURE_DEPENDS "src/core/*.cpp")
4865
list(APPEND PRISM_SOURCES ${CORE_SOURCES})
4966
endif()
5067

5168
# Conditionally add sources for the other modules.
5269
if(PRISM_BUILD_OBJECTS)
70+
message(STATUS "Prism Library: Objects module ENABLED.")
5371
file(GLOB GEOMETRY_SOURCES CONFIGURE_DEPENDS "src/objects/*.cpp")
5472
list(APPEND PRISM_SOURCES ${GEOMETRY_SOURCES})
73+
else()
74+
message(STATUS "Prism Library: Objects module DISABLED.")
5575
endif()
5676

5777
if(PRISM_BUILD_SCENE)
78+
message(STATUS "Prism Library: Scene module ENABLED.")
5879
file(GLOB SCENE_SOURCES CONFIGURE_DEPENDS "src/scene/*.cpp")
5980
list(APPEND PRISM_SOURCES ${SCENE_SOURCES})
81+
else()
82+
message(STATUS "Prism Library: Scene module DISABLED.")
6083
endif()
6184

6285
# Add any remaining top-level source files (e.g., init.cpp)

src/include/Prism/core/style.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@ const std::string BOLD_YELLOW = "\033[1;33m";
3636
* @param message The message to display.
3737
*/
3838
inline void logInfo(const std::string& message) {
39-
std::clog << YELLOW << "[INFO] " << RESET << message << std::endl;
39+
std::clog << YELLOW << "[INFO] " << RESET << message << RESET << std::endl;
4040
}
4141

4242
/**
4343
* @brief Logs a formatted completion message to std::clog.
4444
* @param message The message to display.
4545
*/
4646
inline void logDone(const std::string& message) {
47-
std::clog << GREEN << "[DONE] " << RESET << message << std::endl;
47+
std::clog << GREEN << "[DONE] " << RESET << message << RESET << std::endl;
4848
}
4949

5050
/**

src/include/Prism/objects/ObjReader.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ class ObjReader {
2222
std::vector<std::array<unsigned int, 3>> triangles;
2323

2424
ObjReader(const std::string& filename) {
25+
curMaterial = std::make_shared<Material>();
26+
2527
file.open(filename);
2628
if (!file.is_open()) {
2729
Style::logError("Erro ao abrir o arquivo: " + filename);

0 commit comments

Comments
 (0)