Skip to content
Snippets Groups Projects
Commit 4af05ec6 authored by Guilhem Saurel's avatar Guilhem Saurel
Browse files

pre-commit run -a

parent 1e93d59f
No related branches found
No related tags found
No related merge requests found
#
# Copyright (c) 2014-2019 CNRS
# Copyright (c) 2018-2022 INRIA
# Copyright (c) 2014-2019 CNRS Copyright (c) 2018-2022 INRIA
#
CMAKE_MINIMUM_REQUIRED(VERSION 3.1)
cmake_minimum_required(VERSION 3.1)
SET(PROJECT_NAME eigenpy)
SET(PROJECT_DESCRIPTION "Bindings between Numpy and Eigen using Boost.Python")
SET(PROJECT_URL "http://github.com/stack-of-tasks/eigenpy")
SET(PROJECT_USE_CMAKE_EXPORT TRUE)
SET(PROJECT_USE_KEYWORD_LINK_LIBRARIES TRUE)
SET(PROJECT_CUSTOM_HEADER_EXTENSION "hpp")
SET(PROJECT_COMPATIBILITY_VERSION AnyNewerVersion)
set(PROJECT_NAME eigenpy)
set(PROJECT_DESCRIPTION "Bindings between Numpy and Eigen using Boost.Python")
set(PROJECT_URL "http://github.com/stack-of-tasks/eigenpy")
set(PROJECT_USE_CMAKE_EXPORT TRUE)
set(PROJECT_USE_KEYWORD_LINK_LIBRARIES TRUE)
set(PROJECT_CUSTOM_HEADER_EXTENSION "hpp")
set(PROJECT_COMPATIBILITY_VERSION AnyNewerVersion)
# Check if the submodule cmake have been initialized
set(JRL_CMAKE_MODULES "${CMAKE_CURRENT_LIST_DIR}/cmake")
IF(NOT EXISTS "${CMAKE_SOURCE_DIR}/cmake/base.cmake")
IF(${CMAKE_VERSION} VERSION_LESS "3.14.0")
MESSAGE(FATAL_ERROR "\nPlease run the following command first:\ngit submodule update --init\n")
ELSE()
if(NOT EXISTS "${CMAKE_SOURCE_DIR}/cmake/base.cmake")
if(${CMAKE_VERSION} VERSION_LESS "3.14.0")
message(
FATAL_ERROR
"\nPlease run the following command first:\ngit submodule update --init\n"
)
else()
message(STATUS "JRL cmakemodules not found. Let's fetch it.")
include(FetchContent)
FetchContent_Declare("jrl-cmakemodules"
FetchContent_Declare(
"jrl-cmakemodules"
GIT_REPOSITORY "https://github.com/jrl-umi3218/jrl-cmakemodules.git")
FetchContent_MakeAvailable("jrl-cmakemodules")
FetchContent_GetProperties("jrl-cmakemodules" SOURCE_DIR JRL_CMAKE_MODULES)
ENDIF()
ENDIF()
endif()
endif()
# Disable -Werror on Unix for now.
SET(CXX_DISABLE_WERROR True)
SET(CMAKE_VERBOSE_MAKEFILE True)
set(CXX_DISABLE_WERROR True)
set(CMAKE_VERBOSE_MAKEFILE True)
# ----------------------------------------------------
# --- OPTIONS ---------------------------------------
# Need to be set before including base.cmake
# ----------------------------------------------------
OPTION(INSTALL_DOCUMENTATION "Generate and install the documentation" OFF)
OPTION(SUFFIX_SO_VERSION "Suffix library name with its version" OFF)
option(INSTALL_DOCUMENTATION "Generate and install the documentation" OFF)
option(SUFFIX_SO_VERSION "Suffix library name with its version" OFF)
IF(DEFINED BUILD_UNIT_TESTS)
MESSAGE(AUTHOR_WARNING "BUILD_UNIT_TESTS is deprecated. Use BUILD_TESTING instead.\
if(DEFINED BUILD_UNIT_TESTS)
message(
AUTHOR_WARNING
"BUILD_UNIT_TESTS is deprecated. Use BUILD_TESTING instead.\
If you are manually building EigenPy from source in an existing build folder,\
we suggest that you delete your build folder and make a new one.")
SET(BUILD_TESTING ${BUILD_UNIT_TESTS})
ENDIF(DEFINED BUILD_UNIT_TESTS)
set(BUILD_TESTING ${BUILD_UNIT_TESTS})
endif(DEFINED BUILD_UNIT_TESTS)
INCLUDE("${JRL_CMAKE_MODULES}/base.cmake")
COMPUTE_PROJECT_ARGS(PROJECT_ARGS LANGUAGES CXX)
PROJECT(${PROJECT_NAME} ${PROJECT_ARGS})
include("${JRL_CMAKE_MODULES}/base.cmake")
compute_project_args(PROJECT_ARGS LANGUAGES CXX)
project(${PROJECT_NAME} ${PROJECT_ARGS})
INCLUDE("${JRL_CMAKE_MODULES}/boost.cmake")
INCLUDE("${JRL_CMAKE_MODULES}/python.cmake")
INCLUDE("${JRL_CMAKE_MODULES}/ide.cmake")
INCLUDE("${JRL_CMAKE_MODULES}/apple.cmake")
include("${JRL_CMAKE_MODULES}/boost.cmake")
include("${JRL_CMAKE_MODULES}/python.cmake")
include("${JRL_CMAKE_MODULES}/ide.cmake")
include("${JRL_CMAKE_MODULES}/apple.cmake")
OPTION(GENERATE_PYTHON_STUBS "Generate the Python stubs associated to the Python library" OFF)
option(GENERATE_PYTHON_STUBS
"Generate the Python stubs associated to the Python library" OFF)
STRING(REPLACE "-pedantic" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
string(REPLACE "-pedantic" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
# If needed, fix CMake policy for APPLE systems
APPLY_DEFAULT_APPLE_CONFIGURATION()
apply_default_apple_configuration()
IF(WIN32)
SET(LINK copy_if_different)
ELSE(WIN32)
SET(LINK create_symlink)
ENDIF(WIN32)
if(WIN32)
set(LINK copy_if_different)
else(WIN32)
set(LINK create_symlink)
endif(WIN32)
if(CMAKE_CROSSCOMPILING)
set(PYTHON_COMPONENTS Interpreter NumPy)
......@@ -74,95 +80,87 @@ else()
set(PYTHON_COMPONENTS Interpreter Development.Module NumPy)
endif()
set(PYTHON_EXPORT_DEPENDENCY ON)
FINDPYTHON()
IF(WIN32)
LINK_DIRECTORIES(${PYTHON_LIBRARY_DIRS})
# # Set default Windows build paths
# SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY
# ${PROJECT_BINARY_DIR}/Bin
# CACHE PATH "Single directory for all libraries")
# SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY
# ${PROJECT_BINARY_DIR}/Bin
# CACHE PATH "Single directory for all executables")
# SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY
# ${PROJECT_BINARY_DIR}/Bin
# CACHE PATH "Sing$le directory for all archives")
ENDIF(WIN32)
findpython()
if(WIN32)
link_directories(${PYTHON_LIBRARY_DIRS})
# # Set default Windows build paths SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY
# ${PROJECT_BINARY_DIR}/Bin CACHE PATH "Single directory for all libraries")
# SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/Bin CACHE PATH
# "Single directory for all executables") SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY
# ${PROJECT_BINARY_DIR}/Bin CACHE PATH "Sing$le directory for all archives")
endif(WIN32)
# ----------------------------------------------------
# --- 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_BOOST_DEFAULT_OPTIONS()
EXPORT_BOOST_DEFAULT_OPTIONS()
FIND_PACKAGE(Boost REQUIRED)
SEARCH_FOR_BOOST_PYTHON()
set_boost_default_options()
export_boost_default_options()
find_package(Boost REQUIRED)
search_for_boost_python()
# ----------------------------------------------------
# --- INCLUDE ----------------------------------------
# ----------------------------------------------------
SET(${PROJECT_NAME}_UTILS_HEADERS
include/eigenpy/utils/scalar-name.hpp
include/eigenpy/utils/is-approx.hpp
include/eigenpy/utils/is-aligned.hpp
)
SET(${PROJECT_NAME}_SOLVERS_HEADERS
include/eigenpy/solvers/solvers.hpp
include/eigenpy/solvers/preconditioners.hpp
include/eigenpy/solvers/IterativeSolverBase.hpp
include/eigenpy/solvers/LeastSquaresConjugateGradient.hpp
include/eigenpy/solvers/ConjugateGradient.hpp
include/eigenpy/solvers/SparseSolverBase.hpp
include/eigenpy/solvers/BasicPreconditioners.hpp
include/eigenpy/solvers/BFGSPreconditioners.hpp
)
SET(${PROJECT_NAME}_DECOMPOSITIONS_HEADERS
include/eigenpy/decompositions/decompositions.hpp
include/eigenpy/decompositions/EigenSolver.hpp
include/eigenpy/decompositions/LDLT.hpp
include/eigenpy/decompositions/LLT.hpp
include/eigenpy/decompositions/SelfAdjointEigenSolver.hpp
include/eigenpy/decompositions/minres.hpp
)
SET(${PROJECT_NAME}_HEADERS
${${PROJECT_NAME}_UTILS_HEADERS}
${${PROJECT_NAME}_SOLVERS_HEADERS}
${${PROJECT_NAME}_DECOMPOSITIONS_HEADERS}
include/eigenpy/computation-info.hpp
include/eigenpy/eigenpy.hpp
include/eigenpy/exception.hpp
include/eigenpy/scalar-conversion.hpp
include/eigenpy/expose.hpp
include/eigenpy/details.hpp
include/eigenpy/fwd.hpp
include/eigenpy/eigen-allocator.hpp
include/eigenpy/eigen-to-python.hpp
include/eigenpy/eigen-from-python.hpp
include/eigenpy/eigen-typedef.hpp
include/eigenpy/numpy-map.hpp
include/eigenpy/geometry.hpp
include/eigenpy/geometry-conversion.hpp
include/eigenpy/memory.hpp
include/eigenpy/numpy.hpp
include/eigenpy/numpy-allocator.hpp
include/eigenpy/numpy-type.hpp
include/eigenpy/registration.hpp
include/eigenpy/angle-axis.hpp
include/eigenpy/quaternion.hpp
include/eigenpy/user-type.hpp
include/eigenpy/ufunc.hpp
include/eigenpy/register.hpp
include/eigenpy/stride.hpp
include/eigenpy/swig.hpp
include/eigenpy/version.hpp
)
LIST(APPEND ${PROJECT_NAME}_HEADERS
set(${PROJECT_NAME}_UTILS_HEADERS
include/eigenpy/utils/scalar-name.hpp include/eigenpy/utils/is-approx.hpp
include/eigenpy/utils/is-aligned.hpp)
set(${PROJECT_NAME}_SOLVERS_HEADERS
include/eigenpy/solvers/solvers.hpp
include/eigenpy/solvers/preconditioners.hpp
include/eigenpy/solvers/IterativeSolverBase.hpp
include/eigenpy/solvers/LeastSquaresConjugateGradient.hpp
include/eigenpy/solvers/ConjugateGradient.hpp
include/eigenpy/solvers/SparseSolverBase.hpp
include/eigenpy/solvers/BasicPreconditioners.hpp
include/eigenpy/solvers/BFGSPreconditioners.hpp)
set(${PROJECT_NAME}_DECOMPOSITIONS_HEADERS
include/eigenpy/decompositions/decompositions.hpp
include/eigenpy/decompositions/EigenSolver.hpp
include/eigenpy/decompositions/LDLT.hpp
include/eigenpy/decompositions/LLT.hpp
include/eigenpy/decompositions/SelfAdjointEigenSolver.hpp
include/eigenpy/decompositions/minres.hpp)
set(${PROJECT_NAME}_HEADERS
${${PROJECT_NAME}_UTILS_HEADERS}
${${PROJECT_NAME}_SOLVERS_HEADERS}
${${PROJECT_NAME}_DECOMPOSITIONS_HEADERS}
include/eigenpy/computation-info.hpp
include/eigenpy/eigenpy.hpp
include/eigenpy/exception.hpp
include/eigenpy/scalar-conversion.hpp
include/eigenpy/expose.hpp
include/eigenpy/details.hpp
include/eigenpy/fwd.hpp
include/eigenpy/eigen-allocator.hpp
include/eigenpy/eigen-to-python.hpp
include/eigenpy/eigen-from-python.hpp
include/eigenpy/eigen-typedef.hpp
include/eigenpy/numpy-map.hpp
include/eigenpy/geometry.hpp
include/eigenpy/geometry-conversion.hpp
include/eigenpy/memory.hpp
include/eigenpy/numpy.hpp
include/eigenpy/numpy-allocator.hpp
include/eigenpy/numpy-type.hpp
include/eigenpy/registration.hpp
include/eigenpy/angle-axis.hpp
include/eigenpy/quaternion.hpp
include/eigenpy/user-type.hpp
include/eigenpy/ufunc.hpp
include/eigenpy/register.hpp
include/eigenpy/stride.hpp
include/eigenpy/swig.hpp
include/eigenpy/version.hpp)
list(
APPEND
${PROJECT_NAME}_HEADERS
${${PROJECT_NAME}_BINARY_DIR}/include/${PROJECT_NAME}/config.hpp
${${PROJECT_NAME}_BINARY_DIR}/include/${PROJECT_NAME}/deprecated.hpp
${${PROJECT_NAME}_BINARY_DIR}/include/${PROJECT_NAME}/warning.hpp)
......@@ -170,96 +168,125 @@ LIST(APPEND ${PROJECT_NAME}_HEADERS
# ----------------------------------------------------
# --- TARGETS ----------------------------------------
# ----------------------------------------------------
SET(${PROJECT_NAME}_SOLVERS_SOURCES
src/solvers/preconditioners.cpp
src/solvers/solvers.cpp
)
SET(${PROJECT_NAME}_DECOMPOSITIONS_SOURCES
src/decompositions/decompositions.cpp
)
SET(${PROJECT_NAME}_SOURCES
${${PROJECT_NAME}_SOLVERS_SOURCES}
${${PROJECT_NAME}_DECOMPOSITIONS_SOURCES}
src/exception.cpp
src/eigenpy.cpp
src/numpy.cpp
src/numpy-type.cpp
src/matrix-float.cpp
src/matrix-complex-float.cpp
src/matrix-complex-double.cpp
src/register.cpp
src/matrix-double.cpp
src/matrix-long-double.cpp
src/matrix-complex-long-double.cpp
src/matrix-bool.cpp
src/matrix-int.cpp
src/matrix-long.cpp
src/angle-axis.cpp
src/quaternion.cpp
src/geometry-conversion.cpp
src/version.cpp
)
ADD_LIBRARY(${PROJECT_NAME} SHARED ${${PROJECT_NAME}_SOURCES} ${${PROJECT_NAME}_HEADERS})
TARGET_INCLUDE_DIRECTORIES(${PROJECT_NAME}
SYSTEM PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
$<INSTALL_INTERFACE:include>)
MODERNIZE_TARGET_LINK_LIBRARIES(${PROJECT_NAME} SCOPE PUBLIC
TARGETS Eigen3::Eigen
INCLUDE_DIRS ${EIGEN3_INCLUDE_DIR})
MODERNIZE_TARGET_LINK_LIBRARIES(${PROJECT_NAME} SCOPE PUBLIC
TARGETS Python3::NumPy
INCLUDE_DIRS ${NUMPY_INCLUDE_DIR})
TARGET_INCLUDE_DIRECTORIES(${PROJECT_NAME} SYSTEM PRIVATE ${PYTHON_INCLUDE_DIRS})
IF(SUFFIX_SO_VERSION)
SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES SOVERSION ${PROJECT_VERSION})
ENDIF(SUFFIX_SO_VERSION)
IF(NOT WIN32)
TARGET_COMPILE_OPTIONS(${PROJECT_NAME} PRIVATE $<$<CXX_COMPILER_ID:MSVC>:-bigobj> "-Wno-conversion")
ELSE()
TARGET_COMPILE_OPTIONS(${PROJECT_NAME} PRIVATE $<$<CXX_COMPILER_ID:MSVC>:-bigobj>)
ENDIF()
TARGET_LINK_BOOST_PYTHON(${PROJECT_NAME} PUBLIC)
INSTALL(TARGETS ${PROJECT_NAME}
set(${PROJECT_NAME}_SOLVERS_SOURCES src/solvers/preconditioners.cpp
src/solvers/solvers.cpp)
set(${PROJECT_NAME}_DECOMPOSITIONS_SOURCES
src/decompositions/decompositions.cpp)
set(${PROJECT_NAME}_SOURCES
${${PROJECT_NAME}_SOLVERS_SOURCES}
${${PROJECT_NAME}_DECOMPOSITIONS_SOURCES}
src/exception.cpp
src/eigenpy.cpp
src/numpy.cpp
src/numpy-type.cpp
src/matrix-float.cpp
src/matrix-complex-float.cpp
src/matrix-complex-double.cpp
src/register.cpp
src/matrix-double.cpp
src/matrix-long-double.cpp
src/matrix-complex-long-double.cpp
src/matrix-bool.cpp
src/matrix-int.cpp
src/matrix-long.cpp
src/angle-axis.cpp
src/quaternion.cpp
src/geometry-conversion.cpp
src/version.cpp)
add_library(${PROJECT_NAME} SHARED ${${PROJECT_NAME}_SOURCES}
${${PROJECT_NAME}_HEADERS})
target_include_directories(
${PROJECT_NAME} SYSTEM
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
$<INSTALL_INTERFACE:include>)
modernize_target_link_libraries(
${PROJECT_NAME}
SCOPE
PUBLIC
TARGETS
Eigen3::Eigen
INCLUDE_DIRS
${EIGEN3_INCLUDE_DIR})
modernize_target_link_libraries(
${PROJECT_NAME}
SCOPE
PUBLIC
TARGETS
Python3::NumPy
INCLUDE_DIRS
${NUMPY_INCLUDE_DIR})
target_include_directories(${PROJECT_NAME} SYSTEM
PRIVATE ${PYTHON_INCLUDE_DIRS})
if(SUFFIX_SO_VERSION)
set_target_properties(${PROJECT_NAME} PROPERTIES SOVERSION ${PROJECT_VERSION})
endif(SUFFIX_SO_VERSION)
if(NOT WIN32)
target_compile_options(
${PROJECT_NAME} PRIVATE $<$<CXX_COMPILER_ID:MSVC>:-bigobj>
"-Wno-conversion")
else()
target_compile_options(${PROJECT_NAME}
PRIVATE $<$<CXX_COMPILER_ID:MSVC>:-bigobj>)
endif()
target_link_boost_python(${PROJECT_NAME} PUBLIC)
install(
TARGETS ${PROJECT_NAME}
EXPORT ${TARGETS_EXPORT_NAME}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_FULL_INCLUDEDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_FULL_INCLUDEDIR}
INCLUDES
DESTINATION ${CMAKE_INSTALL_FULL_INCLUDEDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_FULL_BINDIR})
ADD_HEADER_GROUP(${PROJECT_NAME}_HEADERS)
ADD_SOURCE_GROUP(${PROJECT_NAME}_SOURCES)
add_header_group(${PROJECT_NAME}_HEADERS)
add_source_group(${PROJECT_NAME}_SOURCES)
# Install package for ROS
install(FILES package.xml DESTINATION share/eigenpy)
# Allows Colcon to find non-Ament packages when using workspace underlays
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)
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/share/${PROJECT_NAME}/hook/ament_prefix_path.dsv "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)
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)
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)
file(
WRITE
${CMAKE_CURRENT_BINARY_DIR}/share/${PROJECT_NAME}/hook/ament_prefix_path.dsv
"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)
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)
# ----------------------------------------------------
# --- PYTHON LIBRARY ---------------------------------
# ----------------------------------------------------
ADD_SUBDIRECTORY(python)
add_subdirectory(python)
# ----------------------------------------------------
# --- UNIT TEST --------------------------------------
# ----------------------------------------------------
ADD_SUBDIRECTORY(unittest)
add_subdirectory(unittest)
PKG_CONFIG_APPEND_LIBS(${PROJECT_NAME})
PKG_CONFIG_APPEND_CFLAGS("-I${PYTHON_INCLUDE_DIRS}")
PKG_CONFIG_APPEND_CFLAGS("-I${NUMPY_INCLUDE_DIRS}")
PKG_CONFIG_APPEND_BOOST_LIBS(${BOOST_COMPONENTS})
pkg_config_append_libs(${PROJECT_NAME})
pkg_config_append_cflags("-I${PYTHON_INCLUDE_DIRS}")
pkg_config_append_cflags("-I${NUMPY_INCLUDE_DIRS}")
pkg_config_append_boost_libs(${BOOST_COMPONENTS})
......@@ -3,58 +3,59 @@
#
# --- LIBRARY --- #
SET(PYWRAP ${PROJECT_NAME}_pywrap)
SET(PYWRAP ${PYWRAP} PARENT_SCOPE)
set(PYWRAP ${PROJECT_NAME}_pywrap)
set(PYWRAP
${PYWRAP}
PARENT_SCOPE)
MAKE_DIRECTORY("${${PROJECT_NAME}_BINARY_DIR}/python/${PROJECT_NAME}")
make_directory("${${PROJECT_NAME}_BINARY_DIR}/python/${PROJECT_NAME}")
include("${JRL_CMAKE_MODULES}/stubs.cmake")
ADD_CUSTOM_TARGET(python)
SET_TARGET_PROPERTIES(python PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD True)
ADD_LIBRARY(${PYWRAP} SHARED main.cpp)
ADD_DEPENDENCIES(python ${PYWRAP})
TARGET_LINK_LIBRARIES(${PYWRAP} PUBLIC ${PROJECT_NAME})
# BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS spews conversion warnings from int to long unsigned int.
# Unfortunately, using literals does not work in a macro. As such, this turns them off for the entire wrapper:
IF(NOT WIN32)
TARGET_COMPILE_OPTIONS(${PYWRAP} PRIVATE "-Wno-conversion")
ENDIF()
IF(IS_ABSOLUTE ${PYTHON_SITELIB})
SET(ABSOLUTE_PYTHON_SITELIB ${PYTHON_SITELIB})
ELSE()
SET(ABSOLUTE_PYTHON_SITELIB ${CMAKE_INSTALL_PREFIX}/${PYTHON_SITELIB})
ENDIF()
SET(${PYWRAP}_INSTALL_DIR ${ABSOLUTE_PYTHON_SITELIB}/${PROJECT_NAME})
SET_TARGET_PROPERTIES(${PYWRAP}
PROPERTIES
PREFIX ""
SUFFIX ${PYTHON_EXT_SUFFIX}
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/python/${PROJECT_NAME}"
)
IF(UNIX AND NOT APPLE)
SET_TARGET_PROPERTIES(${PYWRAP} PROPERTIES INSTALL_RPATH "\$ORIGIN/../../..")
ENDIF()
INSTALL(TARGETS ${PYWRAP} DESTINATION ${${PYWRAP}_INSTALL_DIR})
add_custom_target(python)
set_target_properties(python PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD True)
add_library(${PYWRAP} SHARED main.cpp)
add_dependencies(python ${PYWRAP})
target_link_libraries(${PYWRAP} PUBLIC ${PROJECT_NAME})
# BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS spews conversion warnings from int to
# long unsigned int. Unfortunately, using literals does not work in a macro. As
# such, this turns them off for the entire wrapper:
if(NOT WIN32)
target_compile_options(${PYWRAP} PRIVATE "-Wno-conversion")
endif()
if(IS_ABSOLUTE ${PYTHON_SITELIB})
set(ABSOLUTE_PYTHON_SITELIB ${PYTHON_SITELIB})
else()
set(ABSOLUTE_PYTHON_SITELIB ${CMAKE_INSTALL_PREFIX}/${PYTHON_SITELIB})
endif()
set(${PYWRAP}_INSTALL_DIR ${ABSOLUTE_PYTHON_SITELIB}/${PROJECT_NAME})
set_target_properties(
${PYWRAP}
PROPERTIES PREFIX ""
SUFFIX ${PYTHON_EXT_SUFFIX}
LIBRARY_OUTPUT_DIRECTORY
"${CMAKE_BINARY_DIR}/python/${PROJECT_NAME}")
if(UNIX AND NOT APPLE)
set_target_properties(${PYWRAP} PROPERTIES INSTALL_RPATH "\$ORIGIN/../../..")
endif()
install(TARGETS ${PYWRAP} DESTINATION ${${PYWRAP}_INSTALL_DIR})
# --- GENERATE STUBS
IF(GENERATE_PYTHON_STUBS)
LOAD_STUBGEN()
if(GENERATE_PYTHON_STUBS)
load_stubgen()
GENERATE_STUBS(${CMAKE_CURRENT_BINARY_DIR} ${PROJECT_NAME} ${ABSOLUTE_PYTHON_SITELIB})
ENDIF(GENERATE_PYTHON_STUBS)
generate_stubs(${CMAKE_CURRENT_BINARY_DIR} ${PROJECT_NAME}
${ABSOLUTE_PYTHON_SITELIB})
endif(GENERATE_PYTHON_STUBS)
# --- INSTALL SCRIPTS
SET(PYTHON_FILES
__init__.py
)
FOREACH(python ${PYTHON_FILES})
PYTHON_BUILD(${PROJECT_NAME} ${python})
INSTALL(FILES
"${CMAKE_CURRENT_SOURCE_DIR}/eigenpy/${python}"
DESTINATION ${${PYWRAP}_INSTALL_DIR})
ENDFOREACH(python)
set(PYTHON_FILES __init__.py)
foreach(python ${PYTHON_FILES})
python_build(${PROJECT_NAME} ${python})
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/eigenpy/${python}"
DESTINATION ${${PYWRAP}_INSTALL_DIR})
endforeach(python)
#
# Copyright (c) 2014-2019 CNRS
# Copyright (c) 2018-2021 INRIA
# Copyright (c) 2014-2019 CNRS Copyright (c) 2018-2021 INRIA
#
MACRO(ADD_LIB_UNIT_TEST test)
CREATE_CTEST_BUILD_TESTS_TARGET()
IF(BUILD_TESTING)
ADD_LIBRARY(${test} SHARED "${test}.cpp")
ELSE(BUILD_TESTING)
ADD_LIBRARY(${test} SHARED EXCLUDE_FROM_ALL "${test}.cpp")
ENDIF(BUILD_TESTING)
TARGET_LINK_LIBRARIES(${test} PUBLIC ${PROJECT_NAME})
SET_TARGET_PROPERTIES(${test} PROPERTIES PREFIX "")
SET_TARGET_PROPERTIES(${test} PROPERTIES SUFFIX ${PYTHON_EXT_SUFFIX})
ADD_TEST(NAME ${test} COMMAND ${PYTHON_EXECUTABLE} -c "import ${test}")
ADD_DEPENDENCIES(build_tests ${test})
IF(NOT BUILD_TESTING)
SET_TESTS_PROPERTIES(${test} PROPERTIES DEPENDS ctest_build_tests)
ENDIF(NOT BUILD_TESTING)
ENDMACRO(ADD_LIB_UNIT_TEST)
ADD_LIB_UNIT_TEST(matrix)
ADD_LIB_UNIT_TEST(geometry)
ADD_LIB_UNIT_TEST(complex)
ADD_LIB_UNIT_TEST(return_by_ref)
ADD_LIB_UNIT_TEST(include)
IF(NOT ${EIGEN3_VERSION} VERSION_LESS "3.2.0")
ADD_LIB_UNIT_TEST(eigen_ref)
ENDIF()
ADD_LIB_UNIT_TEST(user_type)
ADD_PYTHON_UNIT_TEST("py-matrix" "unittest/python/test_matrix.py" "unittest")
ADD_PYTHON_UNIT_TEST("py-geometry" "unittest/python/test_geometry.py" "unittest")
ADD_PYTHON_UNIT_TEST("py-complex" "unittest/python/test_complex.py" "unittest")
ADD_PYTHON_UNIT_TEST("py-return-by-ref" "unittest/python/test_return_by_ref.py" "unittest")
ADD_PYTHON_UNIT_TEST("py-eigen-ref" "unittest/python/test_eigen_ref.py" "unittest")
ADD_PYTHON_UNIT_TEST("py-user-type" "unittest/python/test_user_type.py" "unittest")
ADD_PYTHON_UNIT_TEST("py-switch" "unittest/python/test_switch.py" "python;unittest")
SET_TESTS_PROPERTIES("py-switch" PROPERTIES DEPENDS ${PYWRAP})
ADD_PYTHON_UNIT_TEST("py-dimensions" "unittest/python/test_dimensions.py" "python;unittest")
SET_TESTS_PROPERTIES("py-dimensions" PROPERTIES DEPENDS ${PYWRAP})
ADD_PYTHON_UNIT_TEST("py-version" "unittest/python/test_version.py" "python;unittest")
SET_TESTS_PROPERTIES("py-version" PROPERTIES DEPENDS ${PYWRAP})
ADD_PYTHON_UNIT_TEST("py-eigen-solver" "unittest/python/test_eigen_solver.py" "python;unittest")
SET_TESTS_PROPERTIES("py-eigen-solver" PROPERTIES DEPENDS ${PYWRAP})
ADD_PYTHON_UNIT_TEST("py-self-adjoint-eigen-solver" "unittest/python/test_self_adjoint_eigen_solver.py" "python;unittest")
SET_TESTS_PROPERTIES("py-self-adjoint-eigen-solver" PROPERTIES DEPENDS ${PYWRAP})
ADD_PYTHON_UNIT_TEST("py-LLT" "unittest/python/test_LLT.py" "python;unittest")
SET_TESTS_PROPERTIES("py-LLT" PROPERTIES DEPENDS ${PYWRAP})
ADD_PYTHON_UNIT_TEST("py-LDLT" "unittest/python/test_LDLT.py" "python;unittest")
SET_TESTS_PROPERTIES("py-LDLT" PROPERTIES DEPENDS ${PYWRAP})
IF(NOT WIN32)
ADD_PYTHON_UNIT_TEST("py-MINRES" "unittest/python/test_MINRES.py" "python;unittest")
SET_TESTS_PROPERTIES("py-MINRES" PROPERTIES DEPENDS ${PYWRAP})
ENDIF(NOT WIN32)
macro(ADD_LIB_UNIT_TEST test)
create_ctest_build_tests_target()
if(BUILD_TESTING)
add_library(${test} SHARED "${test}.cpp")
else(BUILD_TESTING)
add_library(${test} SHARED EXCLUDE_FROM_ALL "${test}.cpp")
endif(BUILD_TESTING)
target_link_libraries(${test} PUBLIC ${PROJECT_NAME})
set_target_properties(${test} PROPERTIES PREFIX "")
set_target_properties(${test} PROPERTIES SUFFIX ${PYTHON_EXT_SUFFIX})
add_test(NAME ${test} COMMAND ${PYTHON_EXECUTABLE} -c "import ${test}")
add_dependencies(build_tests ${test})
if(NOT BUILD_TESTING)
set_tests_properties(${test} PROPERTIES DEPENDS ctest_build_tests)
endif(NOT BUILD_TESTING)
endmacro(ADD_LIB_UNIT_TEST)
add_lib_unit_test(matrix)
add_lib_unit_test(geometry)
add_lib_unit_test(complex)
add_lib_unit_test(return_by_ref)
add_lib_unit_test(include)
if(NOT ${EIGEN3_VERSION} VERSION_LESS "3.2.0")
add_lib_unit_test(eigen_ref)
endif()
add_lib_unit_test(user_type)
add_python_unit_test("py-matrix" "unittest/python/test_matrix.py" "unittest")
add_python_unit_test("py-geometry" "unittest/python/test_geometry.py"
"unittest")
add_python_unit_test("py-complex" "unittest/python/test_complex.py" "unittest")
add_python_unit_test("py-return-by-ref" "unittest/python/test_return_by_ref.py"
"unittest")
add_python_unit_test("py-eigen-ref" "unittest/python/test_eigen_ref.py"
"unittest")
add_python_unit_test("py-user-type" "unittest/python/test_user_type.py"
"unittest")
add_python_unit_test("py-switch" "unittest/python/test_switch.py"
"python;unittest")
set_tests_properties("py-switch" PROPERTIES DEPENDS ${PYWRAP})
add_python_unit_test("py-dimensions" "unittest/python/test_dimensions.py"
"python;unittest")
set_tests_properties("py-dimensions" PROPERTIES DEPENDS ${PYWRAP})
add_python_unit_test("py-version" "unittest/python/test_version.py"
"python;unittest")
set_tests_properties("py-version" PROPERTIES DEPENDS ${PYWRAP})
add_python_unit_test("py-eigen-solver" "unittest/python/test_eigen_solver.py"
"python;unittest")
set_tests_properties("py-eigen-solver" PROPERTIES DEPENDS ${PYWRAP})
add_python_unit_test(
"py-self-adjoint-eigen-solver"
"unittest/python/test_self_adjoint_eigen_solver.py" "python;unittest")
set_tests_properties("py-self-adjoint-eigen-solver" PROPERTIES DEPENDS
${PYWRAP})
add_python_unit_test("py-LLT" "unittest/python/test_LLT.py" "python;unittest")
set_tests_properties("py-LLT" PROPERTIES DEPENDS ${PYWRAP})
add_python_unit_test("py-LDLT" "unittest/python/test_LDLT.py" "python;unittest")
set_tests_properties("py-LDLT" PROPERTIES DEPENDS ${PYWRAP})
if(NOT WIN32)
add_python_unit_test("py-MINRES" "unittest/python/test_MINRES.py"
"python;unittest")
set_tests_properties("py-MINRES" PROPERTIES DEPENDS ${PYWRAP})
endif(NOT WIN32)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment