Skip to content

Commit 6b3c0cb

Browse files
committed
[v7] Initial setup
(cherry picked from commit f8c5108) (cherry picked from commit 64757b8)
1 parent defcc61 commit 6b3c0cb

38 files changed

+1068
-53
lines changed

.clang-format

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,12 @@ IncludeCategories:
8484
Priority: 31
8585
- Regex: '^<dart\/common\/.*\.h(pp)?>$'
8686
Priority: 32
87-
- Regex: '^<dart\/.*\.h(pp)?>$'
87+
- Regex: '^<dart\/common\/.*\.h(pp)?>$'
8888
Priority: 33
89+
- Regex: '^<dart\/.*\.h(pp)?>$'
90+
Priority: 40
8991
- Regex: '^<dart\/external\/.*\.h(pp)?>$'
90-
Priority: 34
92+
Priority: 50
9193

9294
# 3rd-party headers
9395
- Regex: '^<.*\.h(pp)?>$'

.github/workflows/ci_macos.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ jobs:
3232
COMPILER: clang
3333
BUILD_TYPE: ${{ matrix.build_type }}
3434
BUILD_DARTPY: ON
35+
DART_USE_SYSTEM_ENTT: ON
3536
steps:
3637
- name: Checkout
3738
uses: actions/checkout@v4
@@ -64,4 +65,3 @@ jobs:
6465
- name: Test DART and dartpy
6566
run: |
6667
pixi run build
67-

.github/workflows/ci_windows.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636

3737
- uses: johnwason/vcpkg-action@v6
3838
with:
39-
pkgs: assimp ccd eigen3 fcl fmt spdlog bullet3 coin-or-ipopt freeglut glfw3 nlopt ode opengl osg pagmo2 tinyxml2 urdfdom
39+
pkgs: assimp ccd eigen3 entt fcl fmt spdlog bullet3 coin-or-ipopt freeglut glfw3 nlopt ode opengl osg pagmo2 tinyxml2 urdfdom
4040
triplet: x64-windows
4141
revision: "2024.02.14"
4242
github-binarycache: true
@@ -61,6 +61,7 @@ jobs:
6161
-DDART_MSVC_DEFAULT_OPTIONS=ON ^
6262
-DDART_VERBOSE=ON ^
6363
-DBUILD_SHARED_LIBS=${{ matrix.build_shared_libs }} ^
64+
-DDART_USE_SYSTEM_ENTT=ON ^
6465
|| exit /b
6566
cmake ^
6667
--build build ^
@@ -93,4 +94,3 @@ jobs:
9394
- name: Test DART and dartpy
9495
run: |
9596
pixi run build
96-

.github/workflows/publish_dartpy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ jobs:
9898
if: ${{ matrix.os == 'windows-latest' && (matrix.release_only == false || github.ref == 'refs/heads/main') }}
9999
uses: johnwason/vcpkg-action@v6
100100
with:
101-
pkgs: assimp ccd eigen3 fcl fmt spdlog bullet3 coin-or-ipopt freeglut glfw3 nlopt ode opengl osg pagmo2 tinyxml2 urdfdom
101+
pkgs: assimp ccd eigen3 entt fcl fmt spdlog bullet3 coin-or-ipopt freeglut glfw3 nlopt ode opengl osg pagmo2 tinyxml2 urdfdom
102102
triplet: x64-windows
103103
revision: "2024.02.14"
104104
github-binarycache: true

Brewfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ brew 'octomap'
1414
brew 'ode'
1515
#brew 'open-scene-graph' # disabled until 3.7.0 is released
1616
brew 'pagmo'
17+
brew 'skypjack/entt/entt'
1718
brew 'spdlog'
1819
brew 'tinyxml2'
1920
brew 'urdfdom'

CMakeLists.txt

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ set(CMAKE_DEBUG_POSTFIX "d")
4343
set(CMAKE_MODULE_PATH "${DART_SOURCE_DIR}/cmake")
4444

4545
include(DARTMacros)
46+
include(dart_defs)
4647

4748
# CMake component helper. It uses the following variables:
4849
# - LIBRARY_INSTALL_DIR
@@ -73,13 +74,13 @@ set(DART_PKG_EXTERNAL_DEPS "eigen, ccd, fcl, assimp")
7374
#===============================================================================
7475
# Build options
7576
#===============================================================================
76-
option(DART_VERBOSE "Whether print detailed information in CMake process" OFF)
77+
dart_option(DART_VERBOSE "Whether print detailed information in CMake process" OFF)
7778
if(MSVC)
7879
set(DART_RUNTIME_LIBRARY "/MD" CACHE STRING "BaseName chosen by the user at CMake configure time")
7980
set_property(CACHE DART_RUNTIME_LIBRARY PROPERTY STRINGS /MD /MT)
80-
option(DART_MSVC_DEFAULT_OPTIONS "Build DART with default Visual Studio options" OFF)
81+
dart_option(DART_MSVC_DEFAULT_OPTIONS "Build DART with default Visual Studio options" OFF)
8182
else()
82-
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
83+
dart_option(BUILD_SHARED_LIBS "Build shared libraries" ON)
8384
endif()
8485
# Warning: DART_ENABLE_SIMD should be ON only when you build DART and the DART
8586
# dependent projects on the same machine. If this option is on, then compile
@@ -88,19 +89,20 @@ endif()
8889
# local machines are different then the projects will be built with different
8990
# compile options, which may cause runtime errors especially memory alignment
9091
# errors.
91-
option(DART_ENABLE_SIMD
92+
dart_option(DART_ENABLE_SIMD
9293
"Build DART with all SIMD instructions on the current local machine" OFF)
93-
option(DART_BUILD_GUI_OSG "Build osgDart library" ON)
94-
option(DART_BUILD_DARTPY "Build dartpy" ON)
95-
option(DART_CODECOV "Turn on codecov support" OFF)
96-
option(DART_FAST_DEBUG "Add -O1 option for DEBUG mode build" OFF)
94+
dart_option(DART_BUILD_GUI_OSG "Build osgDart library" ON)
95+
dart_option(DART_BUILD_DARTPY "Build dartpy" ON)
96+
dart_option(DART_CODECOV "Turn on codecov support" OFF)
97+
dart_option(DART_FAST_DEBUG "Add -O1 option for DEBUG mode build" OFF)
9798
# GCC and Clang add ANSI-formatted colors when they detect the output medium is a
9899
# terminal. However, this doesn't work in some cases such as when the makefile is
99100
# invoked by Ninja. DART_FORCE_COLORED_OUTPUT can be used in this case to enforce
100101
# to always generate ANSI-formatted colors regardless of the output medium types.
101102
# See: https://medium.com/@alasher/colored-c-compiler-output-with-ninja-clang-gcc-10bfe7f2b949
102-
option(DART_FORCE_COLORED_OUTPUT
103+
dart_option(DART_FORCE_COLORED_OUTPUT
103104
"Always produce ANSI-colored output (GNU/Clang only)." OFF)
105+
dart_option(DART_USE_SYSTEM_ENTT "Use system EnTT" OFF)
104106

105107
#===============================================================================
106108
# Print intro
@@ -111,6 +113,8 @@ message(STATUS " DART ${DART_VERSION}")
111113
message(STATUS "============================================")
112114
message(STATUS "")
113115

116+
dart_print_options()
117+
114118
# Print build tool information
115119
message(STATUS "[ Build Tools ]")
116120
message(STATUS "- CMake : ${CMAKE_VERSION}")

cmake/DARTConfig.cmake.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,9 @@ endfunction()
143143

144144
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR})
145145

146+
# TODO: Improve the include mechanism
147+
include(dart_v7Targets)
148+
146149
# Default component: dart
147150
list(APPEND @PROJECT_NAME_UPPERCASE@_FIND_COMPONENTS dart)
148151

cmake/DARTFindDependencies.cmake

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ dart_check_required_package(fmt "libfmt")
1717
dart_find_package(Eigen3)
1818
dart_check_required_package(EIGEN3 "eigen3")
1919

20+
# Entt
21+
if(DART_USE_SYSTEM_ENTT)
22+
dart_find_package(EnTT)
23+
dart_check_required_package(EnTT "EnTT")
24+
endif()
25+
2026
# CCD
2127
dart_find_package(ccd)
2228
dart_check_required_package(ccd "libccd")

cmake/DARTFindEnTT.cmake

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Copyright (c) 2011-2024, The DART development contributors
2+
# All rights reserved.
3+
#
4+
# The list of contributors can be found at:
5+
# https://github.com/dartsim/dart/blob/main/LICENSE
6+
#
7+
# This file is provided under the "BSD-style" License
8+
9+
find_package(EnTT QUIET CONFIG)

cmake/dart_defs.cmake

Lines changed: 224 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,224 @@
1+
# Copyright (c) The DART development contributors
2+
# All rights reserved.
3+
#
4+
# The list of contributors can be found at:
5+
# https://github.com/dartsim/dart/blob/master/LICENSE
6+
#
7+
# This file is provided under the following "BSD-style" License:
8+
# Redistribution and use in source and binary forms, with or
9+
# without modification, are permitted provided that the following
10+
# conditions are met:
11+
# * Redistributions of source code must retain the above copyright
12+
# notice, this list of conditions and the following disclaimer.
13+
# * Redistributions in binary form must reproduce the above
14+
# copyright notice, this list of conditions and the following
15+
# disclaimer in the documentation and/or other materials provided
16+
# with the distribution.
17+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
18+
# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
19+
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
20+
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
22+
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23+
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24+
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
25+
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
26+
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27+
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
28+
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29+
# POSSIBILITY OF SUCH DAMAGE.
30+
31+
# dart_get_max(var [value1 value2...])
32+
function(dart_get_max var)
33+
set(first YES)
34+
set(choice NO)
35+
foreach(item ${ARGN})
36+
if(first)
37+
set(choice ${item})
38+
set(first NO)
39+
elseif(choice LESS ${item})
40+
set(choice ${item})
41+
endif()
42+
endforeach(item)
43+
set(${var} ${choice} PARENT_SCOPE)
44+
endfunction()
45+
46+
# dart_get_max_string_length(var [value1 value2...])
47+
function(dart_get_max_string_length var)
48+
foreach(item ${ARGN})
49+
string(LENGTH ${item} length)
50+
list(APPEND list ${length})
51+
endforeach()
52+
dart_get_max(choice ${list})
53+
set(${var} ${choice} PARENT_SCOPE)
54+
endfunction()
55+
56+
# cmake-format: off
57+
# dart_option(<variable> "<help_text>" <value>)
58+
# cmake-format: on
59+
function(dart_option variable help_text default_value)
60+
set_property(
61+
GLOBAL PROPERTY DART_DETAIL_PROPERTY_OPTION_VARIABLE "${variable}" APPEND
62+
)
63+
set_property(
64+
GLOBAL PROPERTY DART_DETAIL_property_option_help_text "${help_text}" APPEND
65+
)
66+
set_property(
67+
GLOBAL PROPERTY DART_DETAIL_property_option_default_value "${default_value}"
68+
APPEND
69+
)
70+
71+
# Add option
72+
option(${variable} ${help_text} ${default_value})
73+
74+
# Normalize boolean value variants (e.g. 1/0, On/Off, TRUE/FALSE) to ON/OFF
75+
if(${variable})
76+
set(${variable} ON PARENT_SCOPE)
77+
else()
78+
set(${variable} OFF PARENT_SCOPE)
79+
endif()
80+
81+
endfunction()
82+
83+
# cmake-format: off
84+
# dart_print_options()
85+
# cmake-format: on
86+
function(dart_print_options)
87+
# Print the header
88+
message(STATUS "[ Options ]")
89+
90+
get_property(
91+
option_variables GLOBAL PROPERTY DART_DETAIL_PROPERTY_OPTION_VARIABLE
92+
)
93+
get_property(
94+
option_help_texts GLOBAL PROPERTY DART_DETAIL_property_option_help_text
95+
)
96+
get_property(
97+
option_default_values GLOBAL
98+
PROPERTY DART_DETAIL_property_option_default_value
99+
)
100+
101+
dart_get_max_string_length(option_variable_max_len ${option_variables})
102+
list(LENGTH option_variables option_count)
103+
math(EXPR option_count "${option_count} - 1")
104+
foreach(val RANGE ${option_count})
105+
list(GET option_variables ${val} option_variable)
106+
list(GET option_default_values ${val} option_default_value)
107+
108+
set(option_str "- ${option_variable}")
109+
set(spaces "")
110+
string(LENGTH ${option_variable} option_variable_len)
111+
math(EXPR space_count "${option_variable_max_len} - ${option_variable_len}")
112+
foreach(loop_var RANGE ${space_count})
113+
set(option_str "${option_str} ")
114+
endforeach()
115+
116+
set(option_str "${option_str}: ${${option_variable}}")
117+
118+
if(${option_variable} STREQUAL option_default_value)
119+
set(option_str "${option_str} [default]")
120+
endif()
121+
122+
message(STATUS "${option_str}")
123+
endforeach()
124+
125+
message(STATUS "")
126+
endfunction()
127+
128+
function(dart_library)
129+
set(prefix _ARG)
130+
set(options
131+
GLOB_HEADERS
132+
GLOB_SOURCES
133+
)
134+
set(oneValueArgs
135+
NAME
136+
)
137+
set(multiValueArgs
138+
HEADERS
139+
SOURCES
140+
PUBLIC_LINK_LIBRARIES
141+
PRIVATE_LINK_LIBRARIES
142+
PUBLIC_COMPILE_DEFINITIONS
143+
PRIVATE_COMPILE_DEFINITIONS
144+
)
145+
cmake_parse_arguments(
146+
"${prefix}" "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}
147+
)
148+
149+
# Get the current directory relative to the root of the project
150+
# assuming that dart/* is the root of the source tree
151+
string(REPLACE "${CMAKE_SOURCE_DIR}/" "" relative_path ${CMAKE_CURRENT_SOURCE_DIR})
152+
153+
if(${_ARG_GLOB_HEADERS})
154+
file(GLOB_RECURSE headers "*.hpp")
155+
list(APPEND _ARG_HEADERS ${headers})
156+
endif()
157+
158+
if(${_ARG_GLOB_SOURCES})
159+
file(GLOB_RECURSE sources "*.cpp")
160+
list(APPEND _ARG_SOURCES ${sources})
161+
endif()
162+
163+
add_library(${_ARG_NAME}
164+
${_ARG_HEADERS}
165+
${_ARG_SOURCES}
166+
)
167+
168+
target_include_directories(${_ARG_NAME} PUBLIC
169+
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}>
170+
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}>
171+
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
172+
)
173+
174+
target_compile_features(${_ARG_NAME} PUBLIC cxx_std_17)
175+
176+
target_link_libraries(${_ARG_NAME}
177+
PUBLIC
178+
${_ARG_PUBLIC_LINK_LIBRARIES}
179+
PRIVATE
180+
${_ARG_PRIVATE_LINK_LIBRARIES}
181+
)
182+
183+
target_compile_definitions(${_ARG_NAME}
184+
PUBLIC
185+
${_ARG_PUBLIC_COMPILE_DEFINITIONS}
186+
PRIVATE
187+
${_ARG_PRIVATE_COMPILE_DEFINITIONS}
188+
)
189+
190+
set_target_properties(${_ARG_NAME} PROPERTIES
191+
OUTPUT_NAME dart-${_ARG_NAME}
192+
)
193+
194+
include(GNUInstallDirs)
195+
196+
foreach(header ${_ARG_HEADERS})
197+
# Compute the relative path of each header from the root_dir
198+
file(RELATIVE_PATH rel_path "${CMAKE_SOURCE_DIR}" "${header}")
199+
get_filename_component(rel_dir "${rel_path}" DIRECTORY)
200+
201+
# Install the file to the destination, preserving the directory structure
202+
install(
203+
FILES "${header}"
204+
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${rel_dir}"
205+
)
206+
endforeach()
207+
208+
install(
209+
TARGETS ${_ARG_NAME}
210+
EXPORT dart_${_ARG_NAME}Targets
211+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
212+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
213+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
214+
)
215+
216+
install(
217+
EXPORT dart_${_ARG_NAME}Targets
218+
NAMESPACE DART::
219+
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/cmake
220+
)
221+
222+
dart_format_add(${_ARG_HEADERS} ${_ARG_SOURCES})
223+
224+
endfunction()

0 commit comments

Comments
 (0)