Skip to content

Commit

Permalink
precomit and format
Browse files Browse the repository at this point in the history
  • Loading branch information
strasdat committed Jun 9, 2024
1 parent 61b4678 commit ac128dc
Show file tree
Hide file tree
Showing 18 changed files with 663 additions and 578 deletions.
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ assignees: ''
**To Reproduce**
[Steps to reproduce the behavior:]
1.
2.
3.
2.
3.

**Expected behavior**
[A clear and concise description of what you expected to happen.]
Expand Down
22 changes: 22 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: format

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
pre-commit-check:
runs-on: ubuntu-latest
steps:
- name: Checkout workspace
uses: actions/checkout@v3
- name: Install pre-commit and install
run: |
pip install pre-commit
pre-commit install
- name: Run pre-commit checks
run: pre-commit run --all-files
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
build
CMakeLists.txt.user
*.pyc
.vscode/settings.json
.vscode/settings.json
4 changes: 3 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ repos:
rev: v14.0.0
hooks:
- id: clang-format
exclude: (sympy/.*)
types_or: [file]
files: .*(\.h|\.cpp|\.h\.glsl|\.proto)$
- repo: https://github.com/pre-commit/mirrors-prettier
Expand All @@ -23,4 +24,5 @@ repos:
rev: v0.6.10
hooks:
- id: cmake-format
- id: cmake-lint
# lint does not pass
#- id: cmake-lint
173 changes: 81 additions & 92 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,44 +4,48 @@ project(Sophus VERSION 1.24.06)
include(CMakePackageConfigHelpers)
include(GNUInstallDirs)

# Determine if sophus is built as a subproject (using add_subdirectory)
# or if it is the master project.
if (NOT DEFINED SOPHUS_MASTER_PROJECT)
# Determine if sophus is built as a subproject (using add_subdirectory) or if it
# is the master project.
if(NOT DEFINED SOPHUS_MASTER_PROJECT)
set(SOPHUS_MASTER_PROJECT OFF)
if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
set(SOPHUS_MASTER_PROJECT ON)
message(STATUS "CMake version: ${CMAKE_VERSION}")
endif ()
endif ()
endif()
endif()

option(SOPHUS_INSTALL "Generate the install target." ${SOPHUS_MASTER_PROJECT})

if(SOPHUS_MASTER_PROJECT)
# Release by default
# Turn on Debug with "-DCMAKE_BUILD_TYPE=Debug"
# Release by default Turn on Debug with "-DCMAKE_BUILD_TYPE=Debug"
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE RelWithDebInfo)
endif()

set(CMAKE_CXX_STANDARD 17)

# Set compiler specific settings (FixMe: Should not cmake do this for us automatically?)
IF("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
SET(CMAKE_CXX_FLAGS_RELEASE "-O3")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror -Wextra -Wno-deprecated-register -Qunused-arguments -fcolor-diagnostics")
ELSEIF("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
SET(CMAKE_CXX_FLAGS_RELEASE "-O3")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror -Wextra -std=c++14 -Wno-deprecated-declarations -ftemplate-backtrace-limit=0 -Wno-array-bounds")
ENDIF()
# Set compiler specific settings (FixMe: Should not cmake do this for us
# automatically?)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -Wall -Werror -Wextra -Wno-deprecated-register -Qunused-arguments -fcolor-diagnostics"
)
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -Wall -Werror -Wextra -std=c++14 -Wno-deprecated-declarations -ftemplate-backtrace-limit=0 -Wno-array-bounds"
)
endif()

# Add local path for finding packages, set the local version first
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules")
endif()

# Find public dependencies if targets are not yet defined. (Targets might be for example
# defined by a parent project including Sophus via `add_subdirectory`.)
# Find public dependencies if targets are not yet defined. (Targets might be for
# example defined by a parent project including Sophus via `add_subdirectory`.)

if(NOT TARGET Eigen3::Eigen)
find_package(Eigen3 3.3.0 REQUIRED)
Expand All @@ -51,97 +55,86 @@ if(NOT TARGET fmt::fmt)
find_package(fmt)
endif()


# Define interface library target
add_library(sophus INTERFACE)
add_library (Sophus::Sophus ALIAS sophus)
add_library(Sophus::Sophus ALIAS sophus)

set(SOPHUS_HEADER_FILES
sophus/average.hpp
sophus/cartesian.hpp
sophus/ceres_manifold.hpp
sophus/ceres_typetraits.hpp
sophus/common.hpp
sophus/geometry.hpp
sophus/interpolate.hpp
sophus/interpolate_details.hpp
sophus/num_diff.hpp
sophus/rotation_matrix.hpp
sophus/rxso2.hpp
sophus/rxso3.hpp
sophus/se2.hpp
sophus/se3.hpp
sophus/sim2.hpp
sophus/sim3.hpp
sophus/sim_details.hpp
sophus/so2.hpp
sophus/so3.hpp
sophus/spline.hpp
sophus/types.hpp
)

set(SOPHUS_OTHER_FILES
sophus/test_macros.hpp
sophus/example_ensure_handler.cpp
)
sophus/average.hpp
sophus/cartesian.hpp
sophus/ceres_manifold.hpp
sophus/ceres_typetraits.hpp
sophus/common.hpp
sophus/geometry.hpp
sophus/interpolate.hpp
sophus/interpolate_details.hpp
sophus/num_diff.hpp
sophus/rotation_matrix.hpp
sophus/rxso2.hpp
sophus/rxso3.hpp
sophus/se2.hpp
sophus/se3.hpp
sophus/sim2.hpp
sophus/sim3.hpp
sophus/sim_details.hpp
sophus/so2.hpp
sophus/so3.hpp
sophus/spline.hpp
sophus/types.hpp)

set(SOPHUS_OTHER_FILES sophus/test_macros.hpp sophus/example_ensure_handler.cpp)

if(MSVC)
# Define common math constants if we compile with MSVC
target_compile_definitions (sophus INTERFACE _USE_MATH_DEFINES)
endif (MSVC)
target_compile_definitions(sophus INTERFACE _USE_MATH_DEFINES)
endif(MSVC)

# Add Eigen interface dependency, depending on available cmake info
if(TARGET Eigen3::Eigen)
target_link_libraries(sophus INTERFACE Eigen3::Eigen)
set(Eigen3_DEPENDENCY "find_dependency (Eigen3 ${Eigen3_VERSION})")
else()
target_include_directories (sophus SYSTEM INTERFACE ${EIGEN3_INCLUDE_DIR})
target_include_directories(sophus SYSTEM INTERFACE ${EIGEN3_INCLUDE_DIR})
endif()


target_link_libraries(sophus INTERFACE fmt::fmt)
set(fmt_DEPENDENCY "find_dependency (fmt ${fmt_VERSION})")
message(STATUS "Turning basic logging OFF")

# Associate target with include directory
target_include_directories(sophus INTERFACE
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
)
target_include_directories(
sophus INTERFACE "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")

# Declare all used C++14 features
target_compile_features (sophus INTERFACE
cxx_auto_type
cxx_decltype
cxx_nullptr
cxx_right_angle_brackets
cxx_variadic_macros
cxx_variadic_templates
)
target_compile_features(
sophus
INTERFACE cxx_auto_type cxx_decltype cxx_nullptr cxx_right_angle_brackets
cxx_variadic_macros cxx_variadic_templates)

# Add sources as custom target so that they are shown in IDE's
add_custom_target(other SOURCES ${SOPHUS_OTHER_FILES} ${SOPHUS_HEADER_FILES})

# Create 'test' make target using ctest
option(BUILD_SOPHUS_TESTS "Build tests." ON)
if(BUILD_SOPHUS_TESTS)
enable_testing()
add_subdirectory(test)
enable_testing()
add_subdirectory(test)
endif()

# Build python sophus bindings
option(BUILD_PYTHON_BINDINGS "Build python sophus bindings." OFF)
if(BUILD_PYTHON_BINDINGS)
include(FetchContent)
FetchContent_Declare(
pybind11
GIT_REPOSITORY https://github.com/pybind/pybind11.git
GIT_TAG master
)
pybind11
GIT_REPOSITORY https://github.com/pybind/pybind11.git
GIT_TAG master)
FetchContent_MakeAvailable(pybind11)

add_subdirectory(${pybind11_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/pybind)
pybind11_add_module(sophus_pybind ${CMAKE_CURRENT_SOURCE_DIR}/sophus_pybind/bindings.cpp)
pybind11_add_module(sophus_pybind
${CMAKE_CURRENT_SOURCE_DIR}/sophus_pybind/bindings.cpp)
target_link_libraries(sophus_pybind PUBLIC sophus)
endif(BUILD_PYTHON_BINDINGS)

Expand All @@ -152,45 +145,41 @@ if(SOPHUS_INSTALL)
set_target_properties(sophus PROPERTIES EXPORT_NAME Sophus)

install(TARGETS sophus EXPORT SophusTargets)
install(EXPORT SophusTargets
install(
EXPORT SophusTargets
NAMESPACE Sophus::
DESTINATION ${SOPHUS_CMAKE_EXPORT_DIR}
)
DESTINATION ${SOPHUS_CMAKE_EXPORT_DIR})

export(TARGETS sophus NAMESPACE Sophus:: FILE SophusTargets.cmake)
export(
TARGETS sophus
NAMESPACE Sophus::
FILE SophusTargets.cmake)
export(PACKAGE Sophus)

configure_package_config_file(
SophusConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/SophusConfig.cmake
SophusConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/SophusConfig.cmake
INSTALL_DESTINATION ${SOPHUS_CMAKE_EXPORT_DIR}
NO_CHECK_REQUIRED_COMPONENTS_MACRO
)
NO_CHECK_REQUIRED_COMPONENTS_MACRO)

# Remove architecture dependence. Sophus is a header-only library.
set(TEMP_SIZEOF_VOID_P ${CMAKE_SIZEOF_VOID_P})
unset(CMAKE_SIZEOF_VOID_P)

# Write version to file
write_basic_package_version_file (
write_basic_package_version_file(
SophusConfigVersion.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion
)
COMPATIBILITY SameMajorVersion)

# Recover architecture dependence
set(CMAKE_SIZEOF_VOID_P ${TEMP_SIZEOF_VOID_P})

# Install cmake targets
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/SophusConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/SophusConfigVersion.cmake
DESTINATION ${SOPHUS_CMAKE_EXPORT_DIR}
)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/SophusConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/SophusConfigVersion.cmake
DESTINATION ${SOPHUS_CMAKE_EXPORT_DIR})

# Install header files
install(
FILES ${SOPHUS_HEADER_FILES}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/sophus
)
install(FILES ${SOPHUS_HEADER_FILES}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/sophus)
endif()
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright 2011-2017 Hauke Strasdat
Copyright 2011-2017 Hauke Strasdat
2012-2017 Steven Lovegrove

Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ This is a c++ implementation of Lie groups commonly used for 2d and 3d
geometric problems (i.e. for Computer Vision or Robotics applications).
Among others, this package includes the special orthogonal groups SO(2) and
SO(3) to present rotations in 2d and 3d as well as the special Euclidean group
SE(2) and SE(3) to represent isometries also known as rigid body transformations
SE(2) and SE(3) to represent isometries also known as rigid body transformations
(i.e. rotations and translations) in 2d and 3d.

## Status
Expand All @@ -40,21 +40,21 @@ However, next incarnations of Sophus are under development:


- sophus2 is the next c++ iteration of Sophus and is a complete rewrite.
In addition to the Lie groups, it includes a more geometric concepts
In addition to the Lie groups, it includes a more geometric concepts
such unit vector, splines, image classes, camera models and more.

It is currently hosted as part of the [farm-ng-core repository](https://github.com/farm-ng/farm-ng-core/tree/cygnet-dev)
and has likely only a few community users. While the code itself is in a good shape, there are
It is currently hosted as part of the [farm-ng-core repository](https://github.com/farm-ng/farm-ng-core/tree/cygnet-dev)
and has likely only a few community users. While the code itself is in a good shape, there are
no good build instructions yet. Hopefully, this will change in the near future.


- sophus-rs is a Rust version of Sophus. Similar to sophus2, it includes a more geometric concepts
- sophus-rs is a Rust version of Sophus. Similar to sophus2, it includes a more geometric concepts
such unit vector, splines, image classes, camera models and more. Also it includes an early and
experimental version of non-linear least squares optimization library (similar to Ceres, g2o,
experimental version of non-linear least squares optimization library (similar to Ceres, g2o,
etc.).
sophus-rs has likely only a few community users so far, but should be easy to build and
experiment with - of course being written in Rust.

sophus-rs has likely only a few community users so far, but should be easy to build and
experiment with - of course being written in Rust.

https://github.com/sophus-vision/sophus-rs

Expand All @@ -67,9 +67,9 @@ How to build

Sophus requires a C++17 compiler (though older versions build with C++14).

Sophus is tested on Linux and macOS. It also worked on Windows in the past, however there is
Sophus is tested on Linux and macOS. It also worked on Windows in the past, however there is
currently no CI for Windows, so it might require some smaller patches to build on Windows.

There are no comprehensive build instructions but inspecting the install [scripts](scripts/)
as well as the [main.yml](.github/workflows/main.yml) file should give you a good idea how to
build the required dependencies.
as well as the [main.yml](.github/workflows/main.yml) file should give you a good idea how to
build the required dependencies.
2 changes: 1 addition & 1 deletion Sophus.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,4 @@
"typeinfo": "cpp"
}
}
}
}
Loading

0 comments on commit ac128dc

Please sign in to comment.