-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix CMake for installing the package (#3)
- Loading branch information
Showing
23 changed files
with
1,769 additions
and
343 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,57 @@ | ||
cmake_minimum_required(VERSION 3.22) | ||
project(fast_forward_kinematics) | ||
|
||
# Set C++ standard to C++20 | ||
set(CMAKE_CXX_STANDARD 20) | ||
set(FFK_VERSION_MAJOR 0) | ||
set(FFK_VERSION_MINOR 1) | ||
set(FFK_VERSION ${FFK_VERSION_MAJOR}.${FFK_VERSION_MINOR}) | ||
|
||
# Generate the module for the python | ||
include(cmake/fast_forward_kinematics-extras.cmake) | ||
option(BUILD_TESTING "Build fast_forward_kinematics tests" OFF) | ||
|
||
configure_file( | ||
${CMAKE_CURRENT_SOURCE_DIR}/cmake/fast_forward_kinematics-extras.cmake | ||
"${PROJECT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/fast_forward_kinematics-extras.cmake" @ONLY | ||
# Include GNUInstallDirs to get canonical paths | ||
include(GNUInstallDirs) | ||
include(CTest) | ||
|
||
# Add cmake macro to project | ||
include(fast_forward_kinematics.cmake) | ||
|
||
add_library(fast_forward_kinematics_header INTERFACE) | ||
target_include_directories(fast_forward_kinematics_header INTERFACE | ||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> | ||
$<INSTALL_INTERFACE:include> | ||
) | ||
if (BUILD_TESTING) | ||
add_subdirectory(test) | ||
endif () | ||
|
||
|
||
include(CMakePackageConfigHelpers) | ||
|
||
install(DIRECTORY include DESTINATION include/) | ||
configure_package_config_file(fast_forward_kinematics-config.cmake.in fast_forward_kinematics-config.cmake | ||
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/fast_forward_kinematics" | ||
PATH_VARS CMAKE_INSTALL_INCLUDEDIR CMAKE_INSTALL_LIBDIR | ||
NO_CHECK_REQUIRED_COMPONENTS_MACRO) | ||
|
||
add_subdirectory(test) | ||
write_basic_package_version_file(fast_forward_kinematics-config-version.cmake | ||
VERSION ${FFK_VERSION} COMPATIBILITY AnyNewerVersion) | ||
|
||
install(FILES | ||
"${CMAKE_BINARY_DIR}/fast_forward_kinematics-config.cmake" | ||
"${CMAKE_BINARY_DIR}/fast_forward_kinematics-config-version.cmake" | ||
"${CMAKE_SOURCE_DIR}/fast_forward_kinematics.cmake" | ||
DESTINATION "${CMAKE_INSTALL_DATADIR}/fast_forward_kinematics/cmake") | ||
|
||
install(DIRECTORY "${CMAKE_SOURCE_DIR}/code_generation" DESTINATION "${CMAKE_INSTALL_DATADIR}/fast_forward_kinematics/cmake") | ||
install(DIRECTORY include/ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/fast_forward_kinematics") | ||
|
||
# Create an export set | ||
install(TARGETS fast_forward_kinematics_header EXPORT fast_forward_kinematicsTargets) | ||
# Targets files | ||
export( | ||
EXPORT fast_forward_kinematicsTargets | ||
FILE ${CMAKE_CURRENT_BINARY_DIR}/fast_forward_kinematics-targets.cmake | ||
) | ||
install( | ||
EXPORT fast_forward_kinematicsTargets | ||
FILE fast_forward_kinematics-targets.cmake | ||
DESTINATION lib/cmake/fast_forward_kinematics | ||
) |
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
@PACKAGE_INIT@ | ||
|
||
set(FFK_VERSION_MAJOR @FFK_VERSION_MAJOR@) | ||
set(FFK_VERSION_MINOR @FFK_VERSION_MINOR@) | ||
set(FFK_VERSION @FFK_VERSION@) | ||
|
||
set(fast_forward_kinematics_FOUND ON) | ||
set_and_check(fast_forward_kinematics_INCLUDE_DIRS "@PACKAGE_CMAKE_INSTALL_INCLUDEDIR@") | ||
|
||
include("${CMAKE_CURRENT_LIST_DIR}/fast_forward_kinematics-targets.cmake") | ||
include("${CMAKE_CURRENT_LIST_DIR}/cmake/fast_forward_kinematics.cmake") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
include(CMakeParseArguments) | ||
function(generate_fast_forward_kinematics_library_common target_name) | ||
cmake_parse_arguments(ARG "" "URDF_FILE;ROOT_LINK;TIP_LINK;EXT" "" ${ARGN}) | ||
if (ARG_UNPARSED_ARGUMENTS) | ||
message(FATAL_ERROR "generate_fast_forward_kinematics_library_common() called with invalid arguments.") | ||
endif () | ||
|
||
# Set cmake build type to Release if not specified | ||
if (NOT DEFINED CMAKE_BUILD_TYPE OR "${CMAKE_BUILD_TYPE}" STREQUAL "") | ||
set(CMAKE_BUILD_TYPE Release) | ||
endif () | ||
|
||
find_package(Python REQUIRED COMPONENTS Interpreter) | ||
if (Python_Interpreter_FOUND) | ||
message(STATUS "Python executable: ${Python_EXECUTABLE}") | ||
else () | ||
message(FATAL_ERROR "Python interpreter not found.") | ||
endif () | ||
|
||
execute_process( | ||
COMMAND ${Python_EXECUTABLE} ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/code_generation/get_num_joints.py ${ARG_URDF_FILE} ${ARG_ROOT_LINK} ${ARG_TIP_LINK} | ||
OUTPUT_VARIABLE FAST_FK_NUMBER_OF_JOINTS | ||
OUTPUT_STRIP_TRAILING_WHITESPACE | ||
COMMAND_ECHO STDOUT | ||
) | ||
|
||
add_custom_command( | ||
OUTPUT forward_kinematics_lib.${ARG_EXT} | ||
COMMAND ${Python_EXECUTABLE} ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/code_generation/robot_gen.py ${ARG_URDF_FILE} ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/code_generation/robot_config.${ARG_EXT}.template | ||
${CMAKE_CURRENT_BINARY_DIR}/forward_kinematics_lib.${ARG_EXT} ${ARG_ROOT_LINK} ${ARG_TIP_LINK} | ||
DEPENDS ${ARG_URDF_FILE} ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/code_generation/robot_config.${ARG_EXT}.template | ||
COMMENT | ||
"Running `${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/code_generation/robot_gen.py | ||
${ARG_URDF_FILE} | ||
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/code_generation/robot_config.cpp.template | ||
${CMAKE_CURRENT_BINARY_DIR}/forward_kinematics_test.cpp | ||
${ROOT_LINK} | ||
${TIP_LINK}`" | ||
VERBATIM | ||
) | ||
add_custom_target(code_generation DEPENDS forward_kinematics_lib.${ARG_EXT}) | ||
add_library(${target_name} SHARED forward_kinematics_lib.${ARG_EXT}) | ||
add_dependencies(${target_name} code_generation) | ||
|
||
target_link_libraries(${target_name} PUBLIC fast_forward_kinematics_header) | ||
target_compile_definitions(${target_name} PUBLIC "${FAST_FK_NUMBER_OF_JOINTS}") | ||
|
||
|
||
endfunction() | ||
|
||
|
||
macro(ffk_failed_arg_parse) | ||
message(FATAL_ERROR "generate_fast_forward_kinematics_library() called with unused arguments: ${ARG_UNPARSED_ARGUMENTS}. " | ||
"Expected arguments: generate_fast_forward_kinematics_library(target_name URDF_FILE val1 ROOT_LINK val2 TIP_LINK val3)") | ||
endmacro() | ||
|
||
function(generate_fast_forward_kinematics_library target_name) | ||
cmake_parse_arguments(ARG "" "URDF_FILE;ROOT_LINK;TIP_LINK" "" ${ARGN}) | ||
if (ARG_UNPARSED_ARGUMENTS) | ||
ffk_failed_arg_parse() | ||
endif () | ||
|
||
include(ExternalProject) | ||
ExternalProject_Add( | ||
LBFGSpp | ||
PREFIX ${CMAKE_BINARY_DIR}/LBFGSpp | ||
GIT_REPOSITORY https://github.com/yixuan/LBFGSpp.git | ||
GIT_TAG v0.3.0 | ||
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR} -DBUILD_TESTING=OFF | ||
) | ||
ExternalProject_Get_Property(LBFGSpp source_dir) | ||
set(LBFGSppIncludeDir ${source_dir}/include) | ||
|
||
generate_fast_forward_kinematics_library_common(fast_forward_kinematics_library | ||
URDF_FILE "${ARG_URDF_FILE}" | ||
ROOT_LINK "${ARG_ROOT_LINK}" | ||
TIP_LINK "${ARG_TIP_LINK}" | ||
EXT "cpp") | ||
|
||
add_dependencies(fast_forward_kinematics_library LBFGSpp) | ||
target_compile_definitions(fast_forward_kinematics_library PUBLIC FAST_FK_USE_IK) | ||
target_include_directories(fast_forward_kinematics_library PUBLIC ${LBFGSppIncludeDir}) | ||
find_package(Eigen3 3.3 NO_MODULE) | ||
if(NOT Eigen3_FOUND) | ||
include(FetchContent) | ||
set(PROJECT_BUILD_TESTING ${BUILD_TESTING}) | ||
set(BUILD_TESTING OFF) | ||
FetchContent_Declare( | ||
eigen | ||
GIT_REPOSITORY https://gitlab.com/libeigen/eigen.git | ||
GIT_TAG 3.4.0 | ||
) | ||
FetchContent_MakeAvailable(eigen) | ||
set(BUILD_TESTING ${PROJECT_BUILD_TESTING}) | ||
|
||
endif () | ||
target_link_libraries(fast_forward_kinematics_library PUBLIC Eigen3::Eigen) | ||
|
||
target_compile_options(fast_forward_kinematics_library PUBLIC -Ofast -march=native) | ||
|
||
endfunction() | ||
|
||
function(generate_fast_forward_kinematics_library_cuda target_name) | ||
cmake_parse_arguments(ARG "" "URDF_FILE;ROOT_LINK;TIP_LINK" "" ${ARGN}) | ||
if (ARG_UNPARSED_ARGUMENTS) | ||
ffk_failed_arg_parse() | ||
endif () | ||
enable_language(CUDA) | ||
generate_fast_forward_kinematics_library_common(fast_forward_kinematics_library | ||
URDF_FILE "${ARG_URDF_FILE}" | ||
ROOT_LINK "${ARG_ROOT_LINK}" | ||
TIP_LINK "${ARG_TIP_LINK}" | ||
EXT "cu") | ||
endfunction() |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.