Skip to content

Commit

Permalink
[v7] Create v7 target
Browse files Browse the repository at this point in the history
  • Loading branch information
jslee02 committed Mar 20, 2024
1 parent 7bc91d9 commit 09cad4a
Show file tree
Hide file tree
Showing 24 changed files with 871 additions and 604 deletions.
4 changes: 3 additions & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ IncludeCategories:
# DART headers
- Regex: '^<dart\/config.hpp>$'
Priority: 10
- Regex: '^<dart\/v7\/fwd.hpp>$'
Priority: 11
- Regex: '^<dart\/test\/.*\.h(pp)?>$'
Priority: 20
- Regex: '^<dart\/python\/.*\.h(pp)?>$'
Expand All @@ -84,7 +86,7 @@ IncludeCategories:
Priority: 31
- Regex: '^<dart\/common\/.*\.h(pp)?>$'
Priority: 32
- Regex: '^<dart\/common\/.*\.h(pp)?>$'
- Regex: '^<dart\/v7\/.*\.h(pp)?>$'
Priority: 33
- Regex: '^<dart\/.*\.h(pp)?>$'
Priority: 40
Expand Down
3 changes: 3 additions & 0 deletions cmake/DARTConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ endfunction()

list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR})

# TODO: Improve the include mechanism
include(dart_v7Targets)

# Default component: dart
list(APPEND @PROJECT_NAME_UPPERCASE@_FIND_COMPONENTS dart)

Expand Down
5 changes: 5 additions & 0 deletions cmake/DARTFindDependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ find_package(Python3 COMPONENTS Interpreter Development)
option(DART_SKIP_spdlog "If ON, do not use spdlog even if it is found." OFF)
mark_as_advanced(DART_SKIP_spdlog)
dart_find_package(spdlog)
if(spdlog_FOUND)
set(DART_HAVE_SPDLOG 1)
else()
set(DART_HAVE_SPDLOG 0)
endif()

#--------------------
# Misc. dependencies
Expand Down
38 changes: 16 additions & 22 deletions dart/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${DART_BINARY_DIR}/lib")
#===============================================================================
# Source directories
#===============================================================================
# v7
# common
# math
# integration
Expand Down Expand Up @@ -60,6 +61,8 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${DART_BINARY_DIR}/lib")
# gui - (utils), {dart-gui}
# gui-osg - (gui), {dart-gui-osg}

add_subdirectory(v7)

# Component. This should be called before adding subdirectories.
add_component(${PROJECT_NAME} dart)

Expand All @@ -84,14 +87,6 @@ add_subdirectory(simulation)
add_subdirectory(utils) # tinyxml2, bullet
add_subdirectory(gui) # opengl, glut, bullet

set(DART_CONFIG_HPP_IN ${DART_SOURCE_DIR}/dart/config.hpp.in)
set(DART_CONFIG_HPP_OUT ${DART_BINARY_DIR}/dart/config.hpp)
if(DART_VERBOSE)
message(STATUS ${DART_CONFIG_HPP_OUT})
endif()
configure_file(${DART_CONFIG_HPP_IN} ${DART_CONFIG_HPP_OUT} @ONLY)
install(FILES ${DART_CONFIG_HPP_OUT} DESTINATION include/dart)

# Print building component
get_property(components GLOBAL PROPERTY ${PROJECT_NAME}_COMPONENTS)
if(DART_VERBOSE)
Expand Down Expand Up @@ -124,6 +119,7 @@ target_link_libraries(dart
PUBLIC
${CMAKE_DL_LIBS}
${PROJECT_NAME}-external-odelcpsolver
v7
Eigen3::Eigen
fcl
assimp
Expand All @@ -137,20 +133,10 @@ else()
endif()

# spdlog settings
if(spdlog_FOUND)
# Prefer header only target
if(TARGET spdlog::spdlog_header_only)
target_link_libraries(dart PUBLIC spdlog::spdlog_header_only)
target_compile_definitions(dart PUBLIC -DDART_HAVE_spdlog=1)
elseif(TARGET spdlog::spdlog)
target_link_libraries(dart PUBLIC spdlog::spdlog)
target_compile_definitions(dart PUBLIC -DDART_HAVE_spdlog=1)
else()
message(WARNING "spdlog found, but no target is found. Expected spdlog::spdlog or target_link_library_public spdlog::spdlog_header_only")
target_compile_definitions(dart PUBLIC -DDART_HAVE_spdlog=0)
endif()
else()
target_compile_definitions(dart PUBLIC -DDART_HAVE_spdlog=0)
if(TARGET spdlog::spdlog_header_only)
target_link_libraries(dart PUBLIC spdlog::spdlog_header_only)
elseif(TARGET spdlog::spdlog)
target_link_libraries(dart PUBLIC spdlog::spdlog)
endif()

# octomap settings
Expand Down Expand Up @@ -240,3 +226,11 @@ endif()
install(FILES dart.hpp DESTINATION include/dart/ COMPONENT headers)

dart_format_add(${dart_core_headers} ${dart_core_sources})

set(DART_CONFIG_HPP_IN ${DART_SOURCE_DIR}/dart/config.hpp.in)
set(DART_CONFIG_HPP_OUT ${DART_BINARY_DIR}/dart/config.hpp)
if(DART_VERBOSE)
message(STATUS ${DART_CONFIG_HPP_OUT})
endif()
configure_file(${DART_CONFIG_HPP_IN} ${DART_CONFIG_HPP_OUT} @ONLY)
install(FILES ${DART_CONFIG_HPP_OUT} DESTINATION include/dart)
110 changes: 1 addition & 109 deletions dart/common/Logging.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,114 +33,6 @@
#ifndef DART_COMMON_LOGGING_HPP_
#define DART_COMMON_LOGGING_HPP_

// clang-format off
#define DART_LOG_LEVEL_TRACE 0
#define DART_LOG_LEVEL_DEBUG 1
#define DART_LOG_LEVEL_INFO 2
#define DART_LOG_LEVEL_WARN 3
#define DART_LOG_LEVEL_ERROR 4
#define DART_LOG_LEVEL_FATAL 5
#define DART_LOG_LEVEL_OFF 6
// clang-format on

// Default active log level
#if !defined(DART_ACTIVE_LOG_LEVEL)
#define DART_ACTIVE_LOG_LEVEL DART_LOG_LEVEL_INFO
#endif

#if DART_ACTIVE_LOG_LEVEL <= DART_LOG_LEVEL_TRACE
#define DART_TRACE(...) ::dart::common::trace(__VA_ARGS__)
#else
#define DART_TRACE(...) (void)0
#endif

#if DART_ACTIVE_LOG_LEVEL <= DART_LOG_LEVEL_DEBUG
#define DART_DEBUG(...) ::dart::common::debug(__VA_ARGS__)
#else
#define DART_DEBUG(...) (void)0
#endif

#if DART_ACTIVE_LOG_LEVEL <= DART_LOG_LEVEL_INFO
#define DART_INFO(...) ::dart::common::info(__VA_ARGS__)
#else
#define DART_INFO(...) (void)0
#endif

#if DART_ACTIVE_LOG_LEVEL <= DART_LOG_LEVEL_WARN
#define DART_WARN(...) ::dart::common::warn(__VA_ARGS__)
#else
#define DART_WARN(...) (void)0
#endif

#if DART_ACTIVE_LOG_LEVEL <= DART_LOG_LEVEL_ERROR
#define DART_ERROR(...) ::dart::common::error(__VA_ARGS__)
#else
#define DART_ERROR(...) (void)0
#endif

#if DART_ACTIVE_LOG_LEVEL <= DART_LOG_LEVEL_FATAL
#define DART_FATAL(...) ::dart::common::fatal(__VA_ARGS__)
#else
#define DART_FATAL(...) (void)0
#endif

namespace dart::common {

/// \brief Logs for a trace message
///
/// Logs for the most fine-grained information than any other log levels.
///
/// \sa info
template <typename S, typename... Args>
void trace(const S& format_str, Args&&... args);

/// \brief Logs for a debug message
///
/// Logs for fine-grained information that is useful for debugging.
///
/// \sa info
template <typename S, typename... Args>
void debug(const S& format_str, Args&&... args);

/// \brief Logs for a information message
///
/// Logs for useful information from normal operations.
///
/// You can use a Python like formatting API as
/// \code
/// dart::common::info("Hello {}!", "World"); // logged as "Hello World!"
/// \endcode
template <typename S, typename... Args>
void info(const S& format_str, Args&&... args);

/// \brief Logs for a warning message
///
/// Logs for warning information that is potentially harmful.
///
/// \sa info
template <typename S, typename... Args>
void warn(const S& format_str, Args&&... args);

/// \brief Logs for a error message
///
/// Logs for errors that might still allow the application to continue running,
/// but the application might lead to unexpected behavior.
///
/// \sa info
template <typename S, typename... Args>
void error(const S& format_str, Args&&... args);

/// \brief Logs for a fatal error message
///
/// Logs for highly sever errors that will presumably lead the application to
/// crash.
///
/// \sa info
template <typename S, typename... Args>
void fatal(const S& format_str, Args&&... args);

} // namespace dart::common

#include <dart/common/detail/Logging-impl.hpp>
#include <dart/v7/logging.hpp>

#endif // DART_COMMON_LOGGING_HPP_
42 changes: 1 addition & 41 deletions dart/common/Macros.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,46 +33,6 @@
#ifndef DART_COMMON_MACROS_HPP_
#define DART_COMMON_MACROS_HPP_

#include <dart/common/Logging.hpp>

#include <cassert>

// DART_NUM_ARGS(<arg1> [, <arg2> [, ...]])
#define DETAIL_DART_NUM_ARGS(z, a, b, c, d, e, f, cnt, ...) cnt
#define DART_NUM_ARGS(...) \
DETAIL_DART_NUM_ARGS(, ##__VA_ARGS__, 6, 5, 4, 3, 2, 1, 0)

// DART_CONCAT(a, b)
#define DETAIL_DART_CONCAT(a, b) a##b
#define DART_CONCAT(a, b) DETAIL_DART_CONCAT(a, b)

// Macro to suppress -Wunused-parameter and -Wunused-variable warnings in
// release mode when a variable is only used in assertions.
//
// Usage: DART_UNUSED(<variable1> [, <variable2> [, ...]])
#define DETAIL_DART_UNUSED_0()
#define DETAIL_DART_UNUSED_1(a) (void)(a)
#define DETAIL_DART_UNUSED_2(a, b) (void)(a), DETAIL_DART_UNUSED_1(b)
#define DETAIL_DART_UNUSED_3(a, b, c) (void)(a), DETAIL_DART_UNUSED_2(b, c)
#define DETAIL_DART_UNUSED_4(a, b, c, d) \
(void)(a), DETAIL_DART_UNUSED_3(b, c, d)
#define DETAIL_DART_UNUSED_5(a, b, c, d, e) \
(void)(a), DETAIL_DART_UNUSED_4(b, c, d, e)
#define DETAIL_DART_UNUSED_6(a, b, c, d, e, f) \
(void)(a), DETAIL_DART_UNUSED_5(b, c, d, e, f)
#define DART_UNUSED(...) \
DART_CONCAT(DETAIL_DART_UNUSED_, DART_NUM_ARGS(__VA_ARGS__))(__VA_ARGS__)

// DART_ASSERT(<expression> [, <message>])
#define DETAIL_DART_ASSERT_1(condition) assert(condition)
#define DETAIL_DART_ASSERT_2(condition, message) assert((condition) && #message)
#define DART_ASSERT(...) \
DART_CONCAT(DETAIL_DART_ASSERT_, DART_NUM_ARGS(__VA_ARGS__)) \
(__VA_ARGS__)

// Macro to mark the function is not implemented
#define DART_NOT_IMPLEMENTED \
DART_FATAL("Not implemented: {}:{}", __FILE__, __LINE__); \
void(0)
#include <dart/v7/assert.hpp>

#endif
Loading

0 comments on commit 09cad4a

Please sign in to comment.