Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add formatting to CMake listfiles using gersemi #657

Merged
merged 5 commits into from
Feb 12, 2025
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
4 changes: 4 additions & 0 deletions .gersemirc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
definitions: [./CMakeLists.txt,./cmake,./python,./src,./test]
line_length: 80
indent: 2
warn_about_unknown_commands: false
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ febfbcbe9c98cdb4e0c7bbf4554a6925b391834b
58dee5ae90eded5125825a2da0fe76a5031f3334
# black . (Guilhem Saurel, 2023-10-24)
889ff8d1ca00b9e317e1da4136e233bb49a049df
# pre-commit run -all (ManifoldFR, 2025-02-12)
3c3494086db02747bf858142bc3be5cbc244385f
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ ci:
autoupdate_branch: devel
autofix_prs: false
autoupdate_schedule: quarterly
submodules: true
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.6
Expand All @@ -21,3 +22,7 @@ repos:
rev: v5.0.0
hooks:
- id: trailing-whitespace
- repo: https://github.com/BlankSpruce/gersemi
rev: 0.19.0
hooks:
- id: gersemi
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [Unreleased]

### Changed
- Formatted all CMake listfiles using gersemi, add gersemi to pre-commit configuration ([#657](https://github.com/coal-library/coal/pull/657/files))

## [3.0.1] - 2025-02-12

### Fixed
Expand Down
195 changes: 123 additions & 72 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,28 +37,41 @@ set(CXX_DISABLE_WERROR TRUE)

set(PROJECT_NAME coal)
set(PROJECT_ORG "coal-library")
set(PROJECT_DESCRIPTION
set(
PROJECT_DESCRIPTION
"Coal, The Collision Detection Library. Previously known as HPP-FCL, fork of FCL -- The Flexible Collision Library"
)
)
set(PROJECT_URL "https://github.com/coal-library/coal")
SET(PROJECT_USE_CMAKE_EXPORT TRUE)
SET(PROJECT_COMPATIBILITY_VERSION AnyNewerVersion)
set(PROJECT_USE_CMAKE_EXPORT TRUE)
set(PROJECT_COMPATIBILITY_VERSION AnyNewerVersion)
# To enable jrl-cmakemodules compatibility with workspace we must define the two
# following lines
set(PROJECT_AUTO_RUN_FINALIZE FALSE)
set(PROJECT_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR})

SET(PROJECT_USE_KEYWORD_LINK_LIBRARIES TRUE)
SET(DOXYGEN_USE_TEMPLATE_CSS TRUE)
set(PROJECT_USE_KEYWORD_LINK_LIBRARIES TRUE)
set(DOXYGEN_USE_TEMPLATE_CSS TRUE)

# ----------------------------------------------------
# --- OPTIONS ---------------------------------------
# Need to be set before including base.cmake
# ----------------------------------------------------
option(INSTALL_DOCUMENTATION "Generate and install the documentation" OFF)
option(COAL_TURN_ASSERT_INTO_EXCEPTION "Turn some critical Coal asserts to exception." FALSE)
option(COAL_ENABLE_LOGGING "Activate logging for warnings or error messages. Turned on by default in Debug." FALSE)
option(COAL_BACKWARD_COMPATIBILITY_WITH_HPP_FCL "Make Coal retro-compatible with HPP-FCL." FALSE)
option(
COAL_TURN_ASSERT_INTO_EXCEPTION
"Turn some critical Coal asserts to exception."
FALSE
)
option(
COAL_ENABLE_LOGGING
"Activate logging for warnings or error messages. Turned on by default in Debug."
FALSE
)
option(
COAL_BACKWARD_COMPATIBILITY_WITH_HPP_FCL
"Make Coal retro-compatible with HPP-FCL."
FALSE
)

# Check if the submodule cmake have been initialized
set(JRL_CMAKE_MODULES "${CMAKE_CURRENT_LIST_DIR}/cmake")
Expand All @@ -70,22 +83,24 @@ else()
get_property(
JRL_CMAKE_MODULES
TARGET jrl-cmakemodules::jrl-cmakemodules
PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
PROPERTY INTERFACE_INCLUDE_DIRECTORIES
)
message(STATUS "JRL cmakemodules found on system at ${JRL_CMAKE_MODULES}")
elseif(${CMAKE_VERSION} VERSION_LESS "3.14.0")
message(
FATAL_ERROR
"\nCan't find jrl-cmakemodules. Please either:\n"
" - use git submodule: 'git submodule update --init'\n"
" - or install https://github.com/jrl-umi3218/jrl-cmakemodules\n"
" - or upgrade your CMake version to >= 3.14 to allow automatic fetching\n"
"\nCan't find jrl-cmakemodules. Please either:\n"
" - use git submodule: 'git submodule update --init'\n"
" - or install https://github.com/jrl-umi3218/jrl-cmakemodules\n"
" - or upgrade your CMake version to >= 3.14 to allow automatic fetching\n"
)
else()
message(STATUS "JRL cmakemodules not found. Let's fetch it.")
include(FetchContent)
FetchContent_Declare(
"jrl-cmakemodules"
GIT_REPOSITORY "https://github.com/jrl-umi3218/jrl-cmakemodules.git")
GIT_REPOSITORY "https://github.com/jrl-umi3218/jrl-cmakemodules.git"
)
FetchContent_MakeAvailable("jrl-cmakemodules")
FetchContent_GetProperties("jrl-cmakemodules" SOURCE_DIR JRL_CMAKE_MODULES)
endif()
Expand All @@ -94,60 +109,76 @@ endif()
# Use BoostConfig module distributed by boost library instead of using FindBoost module distributed
# by CMake.
# There is one unresolved issue with FindBoost and clang-cl so we deactivate it in this case.
IF(NOT WIN32 OR NOT ${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
IF(POLICY CMP0167)
CMAKE_POLICY(SET CMP0167 NEW)
if(NOT WIN32 OR NOT ${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
if(POLICY CMP0167)
cmake_policy(SET CMP0167 NEW)
# Set a default value to this policy to avoid issue with find_dependency
# macro redefinition with different policy in some modules.
SET(CMAKE_POLICY_DEFAULT_CMP0167 NEW)
ENDIF()
ENDIF()
set(CMAKE_POLICY_DEFAULT_CMP0167 NEW)
endif()
endif()

include("${JRL_CMAKE_MODULES}/base.cmake")
COMPUTE_PROJECT_ARGS(PROJECT_ARGS LANGUAGES CXX)
PROJECT(${PROJECT_NAME} ${PROJECT_ARGS})
project(${PROJECT_NAME} ${PROJECT_ARGS})

include("${JRL_CMAKE_MODULES}/boost.cmake")
include("${JRL_CMAKE_MODULES}/python.cmake")
include("${JRL_CMAKE_MODULES}/apple.cmake")
include("${JRL_CMAKE_MODULES}/ide.cmake")
include(CMakeDependentOption)

SET(CMAKE_MODULE_PATH
set(
CMAKE_MODULE_PATH
${JRL_CMAKE_MODULES}/find-external/assimp/
${CMAKE_MODULE_PATH})
${CMAKE_MODULE_PATH}
)

FUNCTION(set_standard_output_directory target)
SET_TARGET_PROPERTIES(
function(set_standard_output_directory target)
set_target_properties(
${target}
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin
LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib
ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib
)
ENDFUNCTION()
endfunction()

set_default_cmake_build_type("RelWithDebInfo")
SET_DEFAULT_CMAKE_BUILD_TYPE("RelWithDebInfo")

# If needed, fix CMake policy for APPLE systems
APPLY_DEFAULT_APPLE_CONFIGURATION()

OPTION(BUILD_PYTHON_INTERFACE "Build the python bindings" ON)
CMAKE_DEPENDENT_OPTION(GENERATE_PYTHON_STUBS "Generate the Python stubs associated to the Python library" OFF BUILD_PYTHON_INTERFACE OFF)
option(BUILD_PYTHON_INTERFACE "Build the python bindings" ON)
cmake_dependent_option(
GENERATE_PYTHON_STUBS
"Generate the Python stubs associated to the Python library"
OFF
BUILD_PYTHON_INTERFACE
OFF
)

ADD_PROJECT_DEPENDENCY(Eigen3 REQUIRED PKG_CONFIG_REQUIRES "eigen3 >= 3.0.0")

if(BUILD_PYTHON_INTERFACE)
SET(PYTHON_COMPONENTS Interpreter Development NumPy)
set(PYTHON_COMPONENTS Interpreter Development NumPy)
FINDPYTHON(REQUIRED)
ADD_PROJECT_PRIVATE_DEPENDENCY(eigenpy 2.9.2 REQUIRED)
endif()

# Required dependencies
SET_BOOST_DEFAULT_OPTIONS()
EXPORT_BOOST_DEFAULT_OPTIONS()
ADD_PROJECT_DEPENDENCY(Boost REQUIRED chrono thread date_time serialization filesystem)
if (COAL_ENABLE_LOGGING)
ADD_PROJECT_DEPENDENCY(
Boost
REQUIRED
chrono
thread
date_time
serialization
filesystem
)
if(COAL_ENABLE_LOGGING)
ADD_PROJECT_DEPENDENCY(Boost REQUIRED log)
endif()
if(BUILD_PYTHON_INTERFACE)
Expand All @@ -165,14 +196,14 @@ endif()
# Optional dependencies
ADD_PROJECT_DEPENDENCY(octomap PKG_CONFIG_REQUIRES "octomap >= 1.6")
if(octomap_FOUND)
SET(COAL_HAS_OCTOMAP TRUE)
set(COAL_HAS_OCTOMAP TRUE)
string(REPLACE "." ";" VERSION_LIST ${octomap_VERSION})
list(GET VERSION_LIST 0 OCTOMAP_MAJOR_VERSION)
list(GET VERSION_LIST 1 OCTOMAP_MINOR_VERSION)
list(GET VERSION_LIST 2 OCTOMAP_PATCH_VERSION)
message(STATUS "COAL uses Octomap")
else()
SET(COAL_HAS_OCTOMAP FALSE)
set(COAL_HAS_OCTOMAP FALSE)
message(STATUS "COAL does not use Octomap")
endif()

Expand All @@ -183,30 +214,37 @@ if(COAL_HAS_QHULL)
set(COAL_USE_SYSTEM_QHULL TRUE)
message(STATUS "COAL uses system Qhull")
else()
message(STATUS "Qhullcpp not found: it will be build from sources, if Qhull_r is found")
message(
STATUS
"Qhullcpp not found: it will be build from sources, if Qhull_r is found"
)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/third-parties)
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink
${PROJECT_SOURCE_DIR}/third-parties/qhull/src/libqhullcpp
${PROJECT_BINARY_DIR}/third-parties/libqhullcpp
)
execute_process(
COMMAND
${CMAKE_COMMAND} -E create_symlink
${PROJECT_SOURCE_DIR}/third-parties/qhull/src/libqhullcpp
${PROJECT_BINARY_DIR}/third-parties/libqhullcpp
)
set(Qhullcpp_PREFIX ${PROJECT_BINARY_DIR}/third-parties)
find_path(Qhull_r_INCLUDE_DIR
find_path(
Qhull_r_INCLUDE_DIR
NAMES libqhull_r/libqhull_r.h
PATHS ${Qhull_PREFIX}
)
find_library(Qhull_r_LIBRARY
NAMES libqhull_r.so
PATHS ${Qhull_PREFIX}
)
)
find_library(Qhull_r_LIBRARY NAMES libqhull_r.so PATHS ${Qhull_PREFIX})
if(NOT Qhull_r_LIBRARY)
message(FATAL_ERROR "Qhull_r not found, please install it or turn COAL_HAS_QHULL OFF")
message(
FATAL_ERROR
"Qhull_r not found, please install it or turn COAL_HAS_QHULL OFF"
)
endif()
endif()
endif()

FIND_PACKAGE(assimp REQUIRED)
find_package(assimp REQUIRED)

SET(${PROJECT_NAME}_HEADERS
set(
${PROJECT_NAME}_HEADERS
include/coal/collision_data.h
include/coal/BV/kIOS.h
include/coal/BV/BV.h
Expand Down Expand Up @@ -325,10 +363,11 @@ SET(${PROJECT_NAME}_HEADERS
include/coal/serialization/quadrilateral.h
include/coal/serialization/triangle.h
include/coal/timings.h
)
)

if(COAL_BACKWARD_COMPATIBILITY_WITH_HPP_FCL)
SET(HPP_FCL_BACKWARD_COMPATIBILITY_HEADERS
set(
HPP_FCL_BACKWARD_COMPATIBILITY_HEADERS
include/hpp/fcl/broadphase/broadphase_bruteforce.h
include/hpp/fcl/broadphase/broadphase_callbacks.h
include/hpp/fcl/broadphase/broadphase_collision_manager.h
Expand Down Expand Up @@ -454,48 +493,60 @@ if(COAL_BACKWARD_COMPATIBILITY_WITH_HPP_FCL)
include/hpp/fcl/shape/geometric_shape_to_BVH_model.h
include/hpp/fcl/timings.h
include/hpp/fcl/warning.hh
)
LIST(APPEND ${PROJECT_NAME}_HEADERS ${HPP_FCL_BACKWARD_COMPATIBILITY_HEADERS})
HEADER_INSTALL(COMPONENT hpp-fcl-compatibility ${HPP_FCL_BACKWARD_COMPATIBILITY_HEADERS})
)
list(APPEND ${PROJECT_NAME}_HEADERS ${HPP_FCL_BACKWARD_COMPATIBILITY_HEADERS})
HEADER_INSTALL(
COMPONENT hpp-fcl-compatibility
${HPP_FCL_BACKWARD_COMPATIBILITY_HEADERS}
)
endif()

IF(COAL_HAS_OCTOMAP)
LIST(APPEND ${PROJECT_NAME}_HEADERS
if(COAL_HAS_OCTOMAP)
list(
APPEND
${PROJECT_NAME}_HEADERS
include/coal/octree.h
include/coal/serialization/octree.h
include/coal/internal/traversal_node_octree.h
)
ENDIF(COAL_HAS_OCTOMAP)
endif(COAL_HAS_OCTOMAP)

add_subdirectory(doc)
add_subdirectory(src)
if (BUILD_PYTHON_INTERFACE)
if(BUILD_PYTHON_INTERFACE)
add_subdirectory(python)
endif ()
endif()
if(BUILD_TESTING)
add_subdirectory(test)
endif(BUILD_TESTING)

pkg_config_append_libs("coal")
IF(COAL_HAS_OCTOMAP)
PKG_CONFIG_APPEND_LIBS("coal")
if(COAL_HAS_OCTOMAP)
# FCL_HAVE_OCTOMAP kept for backward compatibility reasons.
PKG_CONFIG_APPEND_CFLAGS(
"-DCOAL_HAS_OCTOMAP -DCOAL_HAVE_OCTOMAP -DFCL_HAVE_OCTOMAP -DOCTOMAP_MAJOR_VERSION=${OCTOMAP_MAJOR_VERSION} -DOCTOMAP_MINOR_VERSION=${OCTOMAP_MINOR_VERSION} -DOCTOMAP_PATCH_VERSION=${OCTOMAP_PATCH_VERSION}")
ENDIF(COAL_HAS_OCTOMAP)
"-DCOAL_HAS_OCTOMAP -DCOAL_HAVE_OCTOMAP -DFCL_HAVE_OCTOMAP -DOCTOMAP_MAJOR_VERSION=${OCTOMAP_MAJOR_VERSION} -DOCTOMAP_MINOR_VERSION=${OCTOMAP_MINOR_VERSION} -DOCTOMAP_PATCH_VERSION=${OCTOMAP_PATCH_VERSION}"
)
endif(COAL_HAS_OCTOMAP)

# Install catkin package.xml
INSTALL(FILES package.xml DESTINATION share/${PROJECT_NAME})
install(FILES package.xml DESTINATION share/${PROJECT_NAME})

if(COAL_BACKWARD_COMPATIBILITY_WITH_HPP_FCL)
include(CMakePackageConfigHelpers)
write_basic_package_version_file(hpp-fclConfigVersion.cmake
VERSION 3.0.0
COMPATIBILITY AnyNewerVersion)
install(FILES hpp-fclConfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/hpp-fclConfigVersion.cmake
DESTINATION lib/cmake/hpp-fcl
COMPONENT hpp-fcl-compatibility)
write_basic_package_version_file(
hpp-fclConfigVersion.cmake
VERSION 3.0.0
COMPATIBILITY AnyNewerVersion
)
install(
FILES
hpp-fclConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/hpp-fclConfigVersion.cmake
DESTINATION lib/cmake/hpp-fcl
COMPONENT hpp-fcl-compatibility
)
include("${JRL_CMAKE_MODULES}/install-helpers.cmake")
add_install_target(NAME hpp-fcl-compatibility COMPONENT hpp-fcl-compatibility)
ADD_INSTALL_TARGET(NAME hpp-fcl-compatibility COMPONENT hpp-fcl-compatibility)
endif()

setup_project_finalize()
SETUP_PROJECT_FINALIZE()
Loading
Loading