Skip to content

Commit be69a69

Browse files
committed
w
1 parent 00aa831 commit be69a69

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+514
-659
lines changed

CMakeLists.txt

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -162,24 +162,11 @@ endif()
162162
#===============================================================================
163163
# Build type settings
164164
#===============================================================================
165-
if(NOT CMAKE_BUILD_TYPE)
166-
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: Debug | Release | RelWithDebInfo | MinSizeRel" FORCE)
167-
endif()
168-
string(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_UPPERCASE)
169-
170-
set(DART_BUILD_MODE_DEBUG FALSE)
171-
set(DART_BUILD_MODE_RELEASE FALSE)
172-
173-
if("${CMAKE_BUILD_TYPE_UPPERCASE}" STREQUAL "DEBUG")
174-
set(DART_BUILD_MODE_DEBUG TRUE)
175-
elseif("${CMAKE_BUILD_TYPE_UPPERCASE}" STREQUAL "RELEASE")
176-
set(DART_BUILD_MODE_RELEASE TRUE)
177-
elseif("${CMAKE_BUILD_TYPE_UPPERCASE}" STREQUAL "RELWITHDEBINFO")
178-
set(DART_BUILD_MODE_RELEASE TRUE)
179-
elseif("${CMAKE_BUILD_TYPE_UPPERCASE}" STREQUAL "MINSIZEREL")
180-
set(DART_BUILD_MODE_RELEASE TRUE)
181-
else()
182-
message(WARNING "CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} unknown. Valid options are: Debug | Release | RelWithDebInfo | MinSizeRel")
165+
if(NOT CMAKE_CONFIGURATION_TYPES)
166+
if(NOT CMAKE_BUILD_TYPE)
167+
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
168+
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
169+
endif()
183170
endif()
184171

185172
# Active log level:
@@ -191,14 +178,33 @@ endif()
191178
# - ERROR: To enable log with DART_ERROR() and below
192179
# - FATAL: To enable log with DART_FATAL()
193180
# - OFF: To turn off all the logs
194-
if(DART_BUILD_MODE_DEBUG)
195-
set(DART_ACTIVE_LOG_LEVEL "DEBUG" CACHE STRING "Compile time active log level to enable")
181+
if(NOT DART_ACTIVE_LOG_LEVEL)
182+
if(NOT CMAKE_CONFIGURATION_TYPES AND CMAKE_BUILD_TYPE STREQUAL "Debug")
183+
set(DART_ACTIVE_LOG_LEVEL "DEBUG" CACHE STRING "Compile time active log level to enable")
184+
else()
185+
set(DART_ACTIVE_LOG_LEVEL "INFO" CACHE STRING "Compile time active log level to enable")
186+
endif()
187+
set_property(CACHE DART_ACTIVE_LOG_LEVEL PROPERTY STRINGS TRACE DEBUG INFO WARN ERROR FATAL OFF)
188+
endif()
189+
if(DART_ACTIVE_LOG_LEVEL STREQUAL "TRACE")
190+
set(DART_ACTIVE_LOG_LEVEL_VALUE 0)
191+
elseif(DART_ACTIVE_LOG_LEVEL STREQUAL "DEBUG")
192+
set(DART_ACTIVE_LOG_LEVEL_VALUE 1)
193+
elseif(DART_ACTIVE_LOG_LEVEL STREQUAL "INFO")
194+
set(DART_ACTIVE_LOG_LEVEL_VALUE 2)
195+
elseif(DART_ACTIVE_LOG_LEVEL STREQUAL "WARN")
196+
set(DART_ACTIVE_LOG_LEVEL_VALUE 3)
197+
elseif(DART_ACTIVE_LOG_LEVEL STREQUAL "ERROR")
198+
set(DART_ACTIVE_LOG_LEVEL_VALUE 4)
199+
elseif(DART_ACTIVE_LOG_LEVEL STREQUAL "FATAL")
200+
set(DART_ACTIVE_LOG_LEVEL_VALUE 5)
201+
elseif(DART_ACTIVE_LOG_LEVEL STREQUAL "OFF")
202+
set(DART_ACTIVE_LOG_LEVEL_VALUE 6)
196203
else()
197-
set(DART_ACTIVE_LOG_LEVEL "INFO" CACHE STRING "Compile time active log level to enable")
204+
message(FATAL_ERROR "Unknown DART_ACTIVE_LOG_LEVEL: ${DART_ACTIVE_LOG_LEVEL}")
198205
endif()
199-
set_property(CACHE DART_ACTIVE_LOG_LEVEL PROPERTY STRINGS TRACE DEBUG INFO WARN ERROR FATAL OFF)
200206

201-
if(DART_BUILD_MODE_DEBUG)
207+
if(NOT CMAKE_CONFIGURATION_TYPES AND CMAKE_BUILD_TYPE STREQUAL "Debug")
202208
option(DART_TREAT_WARNINGS_AS_ERRORS "Treat warnings as errors" OFF)
203209
else()
204210
option(DART_TREAT_WARNINGS_AS_ERRORS "Treat warnings as errors" ON)
@@ -355,14 +361,12 @@ if(DART_VERBOSE)
355361
message(STATUS "Build gui::osg : ${DART_BUILD_GUI_OSG}")
356362
message(STATUS "Install path : ${CMAKE_INSTALL_PREFIX}")
357363
message(STATUS "CXX_FLAGS : ${CMAKE_CXX_FLAGS}")
358-
if(${CMAKE_BUILD_TYPE_UPPERCASE} STREQUAL "RELEASE")
359-
message(STATUS "CXX_FLAGS_RELEASE: ${CMAKE_CXX_FLAGS_RELEASE}")
360-
elseif(${CMAKE_BUILD_TYPE_UPPERCASE} STREQUAL "DEBUG")
361-
message(STATUS "CXX_FLAGS_DEBUG : ${CMAKE_CXX_FLAGS_DEBUG}")
362-
elseif(${CMAKE_BUILD_TYPE_UPPERCASE} STREQUAL "RELWITHDEBINFO")
364+
if(NOT CMAKE_CONFIGURATION_TYPES)
365+
message(STATUS "CXX_FLAGS_RELEASE : ${CMAKE_CXX_FLAGS_RELEASE}")
366+
message(STATUS "CXX_FLAGS_DEBUG : ${CMAKE_CXX_FLAGS_DEBUG}")
367+
message(STATUS "CXX_FLAGS_MINSIZEREL : ${CXX_FLAGS_MINSIZEREL}")
363368
message(STATUS "CXX_FLAGS_RELWITHDEBINFO: ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
364-
elseif(${CMAKE_BUILD_TYPE_UPPERCASE} STREQUAL "PROFILE")
365-
message(STATUS "CXX_FLAGS_PROFILE: ${CMAKE_CXX_FLAGS_PROFILE}")
369+
message(STATUS "CXX_FLAGS_PROFILE : ${CMAKE_CXX_FLAGS_PROFILE}")
366370
endif()
367371
message(STATUS "DART_SOURCE_DIR : ${DART_SOURCE_DIR}")
368372
message(STATUS "DART_BINARY_DIR : ${DART_BINARY_DIR}")

dart/common/FreeListAllocator.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,6 @@ void FreeListAllocator::MemoryBlockHeader::merge(MemoryBlockHeader* other)
372372
}
373373

374374
//==============================================================================
375-
#if DART_BUILD_MODE_DEBUG
376375
bool FreeListAllocator::MemoryBlockHeader::isValid() const
377376
{
378377
if (mPrev != nullptr && mPrev->mNext != this) {
@@ -385,6 +384,5 @@ bool FreeListAllocator::MemoryBlockHeader::isValid() const
385384

386385
return true;
387386
}
388-
#endif
389387

390388
} // namespace dart::common

dart/common/FreeListAllocator.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,8 @@ class FreeListAllocator : public MemoryAllocator
126126
/// Merges this memory block with the given memory block
127127
void merge(MemoryBlockHeader* other);
128128

129-
#if DART_BUILD_MODE_DEBUG
130129
/// [Debug only] Returns whether this memory block is valid
131130
bool isValid() const;
132-
#endif
133131
};
134132

135133
/// Allocates a new memory block for \c sizeToAllocate bytes

dart/common/Logging.hpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
#ifndef DART_COMMON_LOGGING_HPP_
3434
#define DART_COMMON_LOGGING_HPP_
3535

36+
#include <dart/config.hpp>
37+
3638
// clang-format off
3739
#define DART_LOG_LEVEL_TRACE 0
3840
#define DART_LOG_LEVEL_DEBUG 1
@@ -43,11 +45,6 @@
4345
#define DART_LOG_LEVEL_OFF 6
4446
// clang-format on
4547

46-
// Default active log level
47-
#if !defined(DART_ACTIVE_LOG_LEVEL)
48-
#define DART_ACTIVE_LOG_LEVEL DART_LOG_LEVEL_INFO
49-
#endif
50-
5148
#if DART_ACTIVE_LOG_LEVEL <= DART_LOG_LEVEL_TRACE
5249
#define DART_TRACE(...) ::dart::common::trace(__VA_ARGS__)
5350
#else

dart/common/MemoryManager.cpp

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
#include "dart/common/MemoryManager.hpp"
3434

35-
#if DART_BUILD_MODE_DEBUG
35+
#ifndef NDEBUG
3636
#include "dart/common/Logging.hpp"
3737
#endif
3838

@@ -49,11 +49,7 @@ MemoryManager& MemoryManager::GetDefault()
4949
MemoryManager::MemoryManager(MemoryAllocator& baseAllocator)
5050
: mBaseAllocator(baseAllocator),
5151
mFreeListAllocator(mBaseAllocator),
52-
#if DART_BUILD_MODE_RELEASE
5352
mPoolAllocator(mFreeListAllocator)
54-
#else
55-
mPoolAllocator(mFreeListAllocator.getInternalAllocator())
56-
#endif
5753
{
5854
// Do nothing
5955
}
@@ -73,21 +69,13 @@ MemoryAllocator& MemoryManager::getBaseAllocator()
7369
//==============================================================================
7470
FreeListAllocator& MemoryManager::getFreeListAllocator()
7571
{
76-
#if DART_BUILD_MODE_RELEASE
7772
return mFreeListAllocator;
78-
#else
79-
return mFreeListAllocator.getInternalAllocator();
80-
#endif
8173
}
8274

8375
//==============================================================================
8476
PoolAllocator& MemoryManager::getPoolAllocator()
8577
{
86-
#if DART_BUILD_MODE_RELEASE
8778
return mPoolAllocator;
88-
#else
89-
return mPoolAllocator.getInternalAllocator();
90-
#endif
9179
}
9280

9381
//==============================================================================
@@ -144,20 +132,6 @@ void MemoryManager::deallocateUsingPool(void* pointer, size_t bytes)
144132
deallocate(Type::Pool, pointer, bytes);
145133
}
146134

147-
#if DART_BUILD_MODE_DEBUG
148-
//==============================================================================
149-
bool MemoryManager::hasAllocated(void* pointer, size_t size) const noexcept
150-
{
151-
if (mFreeListAllocator.hasAllocated(pointer, size))
152-
return true;
153-
154-
if (mPoolAllocator.hasAllocated(pointer, size))
155-
return true;
156-
157-
return false;
158-
}
159-
#endif
160-
161135
//==============================================================================
162136
void MemoryManager::print(std::ostream& os, int indent) const
163137
{

dart/common/MemoryManager.hpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@
3333
#ifndef DART_COMMON_MEMORYMANAGER_HPP_
3434
#define DART_COMMON_MEMORYMANAGER_HPP_
3535

36-
#if DART_BUILD_MODE_DEBUG
37-
#include <mutex>
38-
#endif
3936
#include <dart/common/FreeListAllocator.hpp>
4037
#include <dart/common/PoolAllocator.hpp>
4138

@@ -151,11 +148,6 @@ class MemoryManager final
151148
template <typename T>
152149
void destroyUsingPool(T* pointer) noexcept;
153150

154-
#if DART_BUILD_MODE_DEBUG
155-
/// Returns true if a pointer is allocated by the internal allocator.
156-
[[nodiscard]] bool hasAllocated(void* pointer, size_t size) const noexcept;
157-
#endif
158-
159151
/// Prints state of the memory manager.
160152
void print(std::ostream& os = std::cout, int indent = 0) const;
161153

@@ -167,19 +159,11 @@ class MemoryManager final
167159
/// The base allocator to allocate memory chunk.
168160
MemoryAllocator& mBaseAllocator;
169161

170-
#if DART_BUILD_MODE_RELEASE
171162
/// The free list allocator.
172163
FreeListAllocator mFreeListAllocator;
173164

174165
/// The pool allocator.
175166
PoolAllocator mPoolAllocator;
176-
#else
177-
/// The free list allocator.
178-
FreeListAllocator::Debug mFreeListAllocator;
179-
180-
/// The pool allocator.
181-
PoolAllocator::Debug mPoolAllocator;
182-
#endif
183167
};
184168

185169
} // namespace dart::common

dart/config.hpp.in

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@
3434
|| (DART_MINOR_VERSION <= y && DART_PATCH_VERSION <= z))))
3535

3636
// Deprecated in 6.14
37-
#define DART_VERSION_AT_LEAST(x, y, z) \
38-
DART_VERSION_GE(x, y, z)
37+
#define DART_VERSION_AT_LEAST(x, y, z) DART_VERSION_GE(x, y, z)
3938

4039
// Deprecated in 6.14
4140
#define DART_MAJOR_MINOR_VERSION_AT_LEAST(x, y) \
@@ -44,8 +43,7 @@
4443
&& (DART_MINOR_VERSION > y || (DART_MINOR_VERSION >= y))))
4544

4645
// Deprecated in 6.14
47-
#define DART_VERSION_AT_MOST(x, y, z) \
48-
DART_VERSION_LE(x, y, z)
46+
#define DART_VERSION_AT_MOST(x, y, z) DART_VERSION_LE(x, y, z)
4947

5048
// Deprecated in 6.14
5149
#define DART_MAJOR_MINOR_VERSION_AT_MOST(x, y) \
@@ -62,10 +60,6 @@
6260
#define DART_COMPILER_MSVC
6361
#endif
6462

65-
// Indicates the build mode used for compiling
66-
#cmakedefine01 DART_BUILD_MODE_DEBUG
67-
#cmakedefine01 DART_BUILD_MODE_RELEASE
68-
6963
#cmakedefine01 HAVE_NLOPT
7064
#cmakedefine01 HAVE_IPOPT
7165
#cmakedefine01 HAVE_PAGMO
@@ -98,3 +92,5 @@
9892
#cmakedefine01 DART_USE_SYSTEM_IMGUI
9993

10094
#cmakedefine01 DART_BUILD_PROFILE
95+
96+
#define DART_ACTIVE_LOG_LEVEL @DART_ACTIVE_LOG_LEVEL_VALUE@

0 commit comments

Comments
 (0)