Skip to content

Commit

Permalink
Merge pull request #380 from ManifoldFR/topic/gersemi
Browse files Browse the repository at this point in the history
Change CMake listfile formatting to gersemi
  • Loading branch information
ManifoldFR authored Feb 18, 2025
2 parents dc5ae75 + 885ec59 commit 5760e50
Show file tree
Hide file tree
Showing 19 changed files with 519 additions and 329 deletions.
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-module,./cmake-external,./bindings,./include]
line_length: 80
indent: 2
warn_about_unknown_commands: false
3 changes: 3 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@

# pre-commit -a
f9b7356675024220eefda2344dd186acd612b027

# pre-commit -a
377ea892ac50927d59239e6c57cf0f9477d340e4
7 changes: 4 additions & 3 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/pre-commit/mirrors-clang-format
rev: v19.1.7
Expand All @@ -16,7 +17,7 @@ repos:
rev: 24.10.0
hooks:
- id: black
- repo: https://github.com/cheshirekow/cmake-format-precommit
rev: v0.6.13
- repo: https://github.com/BlankSpruce/gersemi
rev: 0.19.0
hooks:
- id: cmake-format
- id: gersemi
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

### Changed
* Upgrade nanobind submodule to v2.5.0 ([#378](https://github.com/Simple-Robotics/proxsuite/pull/378))
* Switch to gersemi for formatting ([#380](https://github.com/Simple-Robotics/proxsuite/pull/380))

## [0.7.1] - 2025-01-28

Expand Down
161 changes: 101 additions & 60 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,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 Down Expand Up @@ -76,51 +78,79 @@ if(POLICY CMP0177)
set(CMAKE_POLICY_DEFAULT_CMP0177 NEW)
endif()
include(${JRL_CMAKE_MODULES}/base.cmake)
compute_project_args(PROJECT_ARGS LANGUAGES CXX)
COMPUTE_PROJECT_ARGS(PROJECT_ARGS LANGUAGES CXX)
project(${PROJECT_NAME} ${PROJECT_ARGS})

include(${JRL_CMAKE_MODULES}/ide.cmake)
include(${JRL_CMAKE_MODULES}/apple.cmake)

if(NOT ${CMAKE_VERSION} VERSION_GREATER "3.26.0" OR WIN32)
set(CMAKE_MODULE_PATH ${JRL_CMAKE_MODULES}/find-external/OpenMP
${CMAKE_MODULE_PATH})
set(
CMAKE_MODULE_PATH
${JRL_CMAKE_MODULES}/find-external/OpenMP
${CMAKE_MODULE_PATH}
)
endif()
include(${JRL_CMAKE_MODULES}/julia.cmake)
include(CMakeDependentOption)

# If needed, set CMake policy for APPLE systems
apply_default_apple_configuration()
set_default_cmake_build_type(Release)
APPLY_DEFAULT_APPLE_CONFIGURATION()
SET_DEFAULT_CMAKE_BUILD_TYPE(Release)

option(BUILD_PYTHON_INTERFACE "Build the Python bindings" OFF)
option(INITIALIZE_EIGEN_WITH_NAN "Initialize Eigen objects with NAN values" OFF)
option(CHECK_RUNTIME_MALLOC
"Check if some memory allocations are performed at runtime" OFF)
option(
CHECK_RUNTIME_MALLOC
"Check if some memory allocations are performed at runtime"
OFF
)
option(SUFFIX_SO_VERSION "Suffix library name with its version" ON)

option(BUILD_WITH_VECTORIZATION_SUPPORT
"Build the library with the support of modern SIMD instructions." ON)
option(BUILD_BINDINGS_WITH_AVX2_SUPPORT "Build the bindings with AVX2 support."
ON)
option(BUILD_BINDINGS_WITH_AVX512_SUPPORT
"Build the bindings with AVX512 support." ON)
option(
BUILD_WITH_VECTORIZATION_SUPPORT
"Build the library with the support of modern SIMD instructions."
ON
)
option(
BUILD_BINDINGS_WITH_AVX2_SUPPORT
"Build the bindings with AVX2 support."
ON
)
option(
BUILD_BINDINGS_WITH_AVX512_SUPPORT
"Build the bindings with AVX512 support."
ON
)
option(TEST_JULIA_INTERFACE "Run the julia examples as unittest" OFF)
option(BUILD_WITH_OPENMP_SUPPORT "Build the library with the OpenMP support"
OFF)
option(
BUILD_WITH_OPENMP_SUPPORT
"Build the library with the OpenMP support"
OFF
)
cmake_dependent_option(
LINK_PYTHON_INTERFACE_TO_OPENMP "Link OpenMP to the Python interface" ON
BUILD_WITH_OPENMP_SUPPORT OFF)
LINK_PYTHON_INTERFACE_TO_OPENMP
"Link OpenMP to the Python interface"
ON
BUILD_WITH_OPENMP_SUPPORT
OFF
)

if(BUILD_WITH_OPENMP_SUPPORT)
find_package(OpenMP REQUIRED)
separate_arguments(OpenMP_CXX_FLAGS UNIX_COMMAND "${OpenMP_CXX_FLAGS}")
endif(BUILD_WITH_OPENMP_SUPPORT)

set(CMAKE_MODULE_PATH "${JRL_CMAKE_MODULES}/find-external/Julia"
${CMAKE_MODULE_PATH})
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake-external"
${CMAKE_MODULE_PATH})
set(
CMAKE_MODULE_PATH
"${JRL_CMAKE_MODULES}/find-external/Julia"
${CMAKE_MODULE_PATH}
)
set(
CMAKE_MODULE_PATH
"${CMAKE_CURRENT_LIST_DIR}/cmake-external"
${CMAKE_MODULE_PATH}
)

message(STATUS "CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}")
if(INITIALIZE_EIGEN_WITH_NAN)
Expand All @@ -134,7 +164,7 @@ endif(CHECK_RUNTIME_MALLOC)

# set CXX standard
if(DEFINED CMAKE_CXX_STANDARD)
check_minimal_cxx_standard(14 ENFORCE)
CHECK_MINIMAL_CXX_STANDARD(14 ENFORCE)
else()
set(CMAKE_CXX_STANDARD 17)
endif()
Expand All @@ -147,14 +177,19 @@ if(MSVC)
endif()

# Look for dependencies
add_project_dependency(Eigen3 REQUIRED PKG_CONFIG_REQUIRES "eigen3 >= 3.0.5")
ADD_PROJECT_DEPENDENCY(Eigen3 REQUIRED PKG_CONFIG_REQUIRES "eigen3 >= 3.0.5")

set(SIMDE_HINT_FAILURE
"Set BUILD_WITH_VECTORIZATION_SUPPORT=OFF or install Simde on your system.\n If Simde is already installed, ensure that the CMake variable CMAKE_MODULE_PATH correctly points toward the location of FindSimde.cmake file."
set(
SIMDE_HINT_FAILURE
"Set BUILD_WITH_VECTORIZATION_SUPPORT=OFF or install Simde on your system.\n If Simde is already installed, ensure that the CMake variable CMAKE_MODULE_PATH correctly points toward the location of FindSimde.cmake file."
)
if(BUILD_WITH_VECTORIZATION_SUPPORT)
add_project_dependency(Simde REQUIRED FIND_EXTERNAL "Simde"
PKG_CONFIG_REQUIRES "simde")
ADD_PROJECT_DEPENDENCY(
Simde
REQUIRED
FIND_EXTERNAL "Simde"
PKG_CONFIG_REQUIRES "simde"
)
endif()

# Build the main library
Expand All @@ -165,29 +200,25 @@ if(MSVC)
target_compile_options(proxsuite INTERFACE /permissive-)
target_compile_options(proxsuite INTERFACE $<$<COMPILE_LANGUAGE:CXX>:/bigobj>)
endif(MSVC)
target_link_libraries(
proxsuite
PUBLIC
INTERFACE Eigen3::Eigen)
target_link_libraries(proxsuite PUBLIC INTERFACE Eigen3::Eigen)
target_include_directories(
proxsuite INTERFACE "$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")
proxsuite
INTERFACE
"$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
)
target_include_directories(
proxsuite INTERFACE "$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include>")
proxsuite
INTERFACE "$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include>"
)
set(EXPORTED_TARGETS_LIST proxsuite)

add_header_group(${PROJECT_NAME}_HEADERS)
ADD_HEADER_GROUP(${PROJECT_NAME}_HEADERS)

if(BUILD_WITH_VECTORIZATION_SUPPORT)
add_library(proxsuite-vectorized INTERFACE)
target_link_libraries(
proxsuite-vectorized
PUBLIC
INTERFACE proxsuite)
target_link_libraries(
proxsuite-vectorized
PUBLIC
INTERFACE simde)
target_link_libraries(proxsuite-vectorized PUBLIC INTERFACE proxsuite)
target_link_libraries(proxsuite-vectorized PUBLIC INTERFACE simde)
target_compile_definitions(proxsuite-vectorized INTERFACE PROXSUITE_VECTORIZE)
list(APPEND EXPORTED_TARGETS_LIST proxsuite-vectorized)
endif()
Expand All @@ -202,7 +233,9 @@ if(BUILD_TESTING OR BUILD_PYTHON_INTERFACE)
if(NOT EXISTS ${cereal})
execute_process(
COMMAND ${GIT_EXECUTABLE} submodule update --init ${cereal_dir}
WORKING_DIRECTORY ${cereal_dir} COMMAND_ERROR_IS_FATAL ANY)
WORKING_DIRECTORY ${cereal_dir}
COMMAND_ERROR_IS_FATAL ANY
)
endif()
endif()
endif()
Expand All @@ -213,7 +246,8 @@ if(NOT PROXSUITE_AS_SUBPROJECT)
EXPORT ${TARGETS_EXPORT_NAME}
LIBRARY DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_FULL_BINDIR})
RUNTIME DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}
)
endif(NOT PROXSUITE_AS_SUBPROJECT)

add_subdirectory(bindings)
Expand All @@ -230,26 +264,33 @@ install(FILES package.xml DESTINATION share/${PROJECT_NAME})
file(
WRITE
${CMAKE_CURRENT_BINARY_DIR}/share/ament_index/resource_index/packages/${PROJECT_NAME}
"")
""
)
install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/share/ament_index/resource_index/packages/${PROJECT_NAME}
DESTINATION share/ament_index/resource_index/packages)
DESTINATION share/ament_index/resource_index/packages
)
file(
WRITE
${CMAKE_CURRENT_BINARY_DIR}/share/${PROJECT_NAME}/hook/ament_prefix_path.dsv
"prepend-non-duplicate;AMENT_PREFIX_PATH;")
"prepend-non-duplicate;AMENT_PREFIX_PATH;"
)
install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/share/${PROJECT_NAME}/hook/ament_prefix_path.dsv
DESTINATION share/${PROJECT_NAME}/hook)
DESTINATION share/${PROJECT_NAME}/hook
)
if(BUILD_PYTHON_INTERFACE)
file(WRITE
${CMAKE_CURRENT_BINARY_DIR}/share/${PROJECT_NAME}/hook/python_path.dsv
"prepend-non-duplicate;PYTHONPATH;${PYTHON_SITELIB}")
file(
WRITE
${CMAKE_CURRENT_BINARY_DIR}/share/${PROJECT_NAME}/hook/python_path.dsv
"prepend-non-duplicate;PYTHONPATH;${PYTHON_SITELIB}"
)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/share/${PROJECT_NAME}/hook/python_path.dsv
DESTINATION share/${PROJECT_NAME}/hook)
DESTINATION share/${PROJECT_NAME}/hook
)
endif(BUILD_PYTHON_INTERFACE)

setup_project_finalize()
SETUP_PROJECT_FINALIZE()
Loading

0 comments on commit 5760e50

Please sign in to comment.