Skip to content

Commit 8eeaf80

Browse files
committed
build system
directly derived from other files inside eigenpy
1 parent a936ae7 commit 8eeaf80

File tree

2 files changed

+258
-0
lines changed

2 files changed

+258
-0
lines changed
Lines changed: 226 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,226 @@
1+
# derived from eigenpy/CMakeLists.txt for this example
2+
3+
cmake_minimum_required(VERSION 3.1)
4+
5+
set(PROJECT_NAME eigenpy_example_custom_numeric_type)
6+
set(PROJECT_DESCRIPTION "An example of using eigenpy with a custom numeric type: Boost.Multiprecision complex numbers")
7+
set(PROJECT_URL "http://github.com/stack-of-tasks/eigenpy/examples/custom_numeric_type")
8+
set(PROJECT_USE_CMAKE_EXPORT TRUE)
9+
set(PROJECT_USE_KEYWORD_LINK_LIBRARIES TRUE)
10+
set(PROJECT_CUSTOM_HEADER_EXTENSION "hpp")
11+
set(PROJECT_COMPATIBILITY_VERSION AnyNewerVersion)
12+
13+
14+
15+
# Check if the submodule cmake have been initialized
16+
set(JRL_CMAKE_MODULES "${CMAKE_CURRENT_LIST_DIR}/cmake")
17+
if(NOT EXISTS "${CMAKE_SOURCE_DIR}/cmake/base.cmake")
18+
if(${CMAKE_VERSION} VERSION_LESS "3.14.0")
19+
message(
20+
FATAL_ERROR
21+
"\nPlease run the following command first:\ngit submodule update --init\n"
22+
)
23+
else()
24+
message(STATUS "JRL cmakemodules not found. Let's fetch it.")
25+
include(FetchContent)
26+
FetchContent_Declare(
27+
"jrl-cmakemodules"
28+
GIT_REPOSITORY "https://github.com/jrl-umi3218/jrl-cmakemodules.git")
29+
FetchContent_MakeAvailable("jrl-cmakemodules")
30+
FetchContent_GetProperties("jrl-cmakemodules" SOURCE_DIR JRL_CMAKE_MODULES)
31+
endif()
32+
endif()
33+
34+
35+
# Disable -Werror on Unix for now.
36+
set(CXX_DISABLE_WERROR True)
37+
set(CMAKE_VERBOSE_MAKEFILE True)
38+
39+
option(INSTALL_DOCUMENTATION "Generate and install the documentation" OFF)
40+
option(SUFFIX_SO_VERSION "Suffix library name with its version" OFF)
41+
42+
if(DEFINED BUILD_UNIT_TESTS)
43+
message(
44+
AUTHOR_WARNING
45+
"BUILD_UNIT_TESTS is deprecated. Use BUILD_TESTING instead.")
46+
set(BUILD_TESTING ${BUILD_UNIT_TESTS})
47+
endif(DEFINED BUILD_UNIT_TESTS)
48+
49+
50+
include("${JRL_CMAKE_MODULES}/base.cmake")
51+
compute_project_args(PROJECT_ARGS LANGUAGES CXX)
52+
project(${PROJECT_NAME} ${PROJECT_ARGS})
53+
54+
55+
include("${JRL_CMAKE_MODULES}/boost.cmake")
56+
include("${JRL_CMAKE_MODULES}/python.cmake")
57+
include("${JRL_CMAKE_MODULES}/ide.cmake")
58+
include("${JRL_CMAKE_MODULES}/apple.cmake")
59+
60+
61+
option(GENERATE_PYTHON_STUBS
62+
"Generate the Python stubs associated to the Python library" OFF)
63+
64+
string(REPLACE "-pedantic" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
65+
66+
67+
# If needed, fix CMake policy for APPLE systems
68+
apply_default_apple_configuration()
69+
check_minimal_cxx_standard(11 ENFORCE)
70+
71+
if(WIN32)
72+
set(LINK copy_if_different)
73+
else(WIN32)
74+
set(LINK create_symlink)
75+
endif(WIN32)
76+
77+
if(CMAKE_CROSSCOMPILING)
78+
set(PYTHON_COMPONENTS Interpreter NumPy)
79+
else()
80+
set(PYTHON_COMPONENTS Interpreter Development.Module NumPy)
81+
endif()
82+
set(PYTHON_EXPORT_DEPENDENCY ON)
83+
findpython(REQUIRED)
84+
85+
86+
if(${NUMPY_VERSION} VERSION_LESS "1.16.0")
87+
set(NUMPY_WITH_BROKEN_UFUNC_SUPPORT TRUE)
88+
endif()
89+
90+
91+
if(WIN32)
92+
link_directories(${PYTHON_LIBRARY_DIRS})
93+
# # Set default Windows build paths SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY
94+
# ${PROJECT_BINARY_DIR}/Bin CACHE PATH "Single directory for all libraries")
95+
# SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/Bin CACHE PATH
96+
# "Single directory for all executables") SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY
97+
# ${PROJECT_BINARY_DIR}/Bin CACHE PATH "Sing$le directory for all archives")
98+
endif(WIN32)
99+
100+
101+
102+
# ----------------------------------------------------
103+
# --- DEPENDENCIES -----------------------------------
104+
# ----------------------------------------------------
105+
add_project_dependency(Eigen3 REQUIRED PKG_CONFIG_REQUIRES "eigen3 >= 3.0.5")
106+
add_project_dependency(eigenpy REQUIRED PKG_CONFIG_REQUIRES "eigenpy >= 3.0.0")
107+
108+
set_boost_default_options()
109+
export_boost_default_options()
110+
find_package(Boost REQUIRED)
111+
search_for_boost_python(REQUIRED)
112+
113+
114+
# ----------------------------------------------------
115+
# --- INCLUDE ----------------------------------------
116+
# ----------------------------------------------------
117+
set(${PROJECT_NAME}_HEADERS
118+
include/header.hpp)
119+
120+
121+
set(${PROJECT_NAME}_SOURCES src/src.cpp)
122+
123+
124+
125+
add_library(${PROJECT_NAME} SHARED ${${PROJECT_NAME}_SOURCES}
126+
${${PROJECT_NAME}_HEADERS})
127+
128+
129+
target_include_directories(
130+
${PROJECT_NAME} SYSTEM
131+
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
132+
$<INSTALL_INTERFACE:include>)
133+
134+
135+
modernize_target_link_libraries(
136+
${PROJECT_NAME}
137+
SCOPE
138+
PUBLIC
139+
TARGETS
140+
Eigen3::Eigen
141+
INCLUDE_DIRS
142+
${EIGEN3_INCLUDE_DIR})
143+
144+
145+
modernize_target_link_libraries(
146+
${PROJECT_NAME}
147+
SCOPE
148+
PUBLIC
149+
TARGETS
150+
Python${PYTHON_VERSION_MAJOR}::NumPy
151+
INCLUDE_DIRS
152+
${NUMPY_INCLUDE_DIRS}
153+
${PYTHON_INCLUDE_DIR})
154+
155+
156+
157+
if(SUFFIX_SO_VERSION)
158+
set_target_properties(${PROJECT_NAME} PROPERTIES SOVERSION ${PROJECT_VERSION})
159+
endif(SUFFIX_SO_VERSION)
160+
161+
162+
163+
164+
if(NOT WIN32)
165+
target_compile_options(
166+
${PROJECT_NAME} PRIVATE $<$<CXX_COMPILER_ID:MSVC>:-bigobj>
167+
"-Wno-conversion")
168+
else()
169+
target_compile_options(${PROJECT_NAME}
170+
PRIVATE $<$<CXX_COMPILER_ID:MSVC>:-bigobj>)
171+
target_compile_definitions(${PROJECT_NAME} PUBLIC "HAVE_SNPRINTF")
172+
endif()
173+
174+
target_link_boost_python(${PROJECT_NAME} PUBLIC)
175+
install(
176+
TARGETS ${PROJECT_NAME}
177+
EXPORT ${TARGETS_EXPORT_NAME}
178+
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
179+
INCLUDES
180+
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
181+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
182+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
183+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
184+
185+
add_header_group(${PROJECT_NAME}_HEADERS)
186+
add_source_group(${PROJECT_NAME}_SOURCES)
187+
188+
# Install package for ROS
189+
install(FILES package.xml DESTINATION share/example_)
190+
# Allows Colcon to find non-Ament packages when using workspace underlays
191+
file(
192+
WRITE
193+
${CMAKE_CURRENT_BINARY_DIR}/share/ament_index/resource_index/packages/${PROJECT_NAME}
194+
"")
195+
install(
196+
FILES
197+
${CMAKE_CURRENT_BINARY_DIR}/share/ament_index/resource_index/packages/${PROJECT_NAME}
198+
DESTINATION share/ament_index/resource_index/packages)
199+
file(
200+
WRITE
201+
${CMAKE_CURRENT_BINARY_DIR}/share/${PROJECT_NAME}/hook/ament_prefix_path.dsv
202+
"prepend-non-duplicate;AMENT_PREFIX_PATH;")
203+
install(
204+
FILES
205+
${CMAKE_CURRENT_BINARY_DIR}/share/${PROJECT_NAME}/hook/ament_prefix_path.dsv
206+
DESTINATION share/${PROJECT_NAME}/hook)
207+
file(WRITE
208+
${CMAKE_CURRENT_BINARY_DIR}/share/${PROJECT_NAME}/hook/python_path.dsv
209+
"prepend-non-duplicate;PYTHONPATH;${PYTHON_SITELIB}")
210+
install(
211+
FILES ${CMAKE_CURRENT_BINARY_DIR}/share/${PROJECT_NAME}/hook/python_path.dsv
212+
DESTINATION share/${PROJECT_NAME}/hook)
213+
214+
# ----------------------------------------------------
215+
# --- PYTHON LIBRARY ---------------------------------
216+
# ----------------------------------------------------
217+
#add_subdirectory(python)
218+
219+
pkg_config_append_libs(${PROJECT_NAME})
220+
pkg_config_append_cflags("-I${PYTHON_INCLUDE_DIRS}")
221+
pkg_config_append_cflags("-I${NUMPY_INCLUDE_DIRS}")
222+
pkg_config_append_boost_libs(${BOOST_COMPONENTS})
223+
224+
225+
226+
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?xml version="1.0"?>
2+
<package format="3">
3+
<name>eigenpy_example_custom_numeric_type</name>
4+
<version>3.0.0</version>
5+
<description>Example of using EigenPy to enable custom numeric types with Eigen</description>
6+
<maintainer email="[email protected]">Justin Carpentier</maintainer>
7+
<maintainer email="[email protected]">Wolfgang Merkt</maintainer>
8+
<author>Justin Carpentier</author>
9+
<author>Nicolas Mansard</author>
10+
<license>BSD</license>
11+
12+
<url type="website">https://github.com/stack-of-tasks/eigenpy/examples/custom_numeric_type</url>
13+
14+
<build_depend>git</build_depend>
15+
<build_depend>doxygen</build_depend>
16+
17+
<!-- The following tag is recommended by REP-136 -->
18+
<exec_depend condition="$ROS_VERSION == 1">catkin</exec_depend>
19+
20+
<depend condition="$ROS_PYTHON_VERSION == 2">python</depend>
21+
<depend condition="$ROS_PYTHON_VERSION == 3">python3</depend>
22+
<depend condition="$ROS_PYTHON_VERSION == 2">python-numpy</depend>
23+
<depend condition="$ROS_PYTHON_VERSION == 3">python3-numpy</depend>
24+
<depend>eigen</depend>
25+
<depend>boost</depend>
26+
<depend>eigenpy</depend>
27+
28+
<buildtool_depend>cmake</buildtool_depend>
29+
<export>
30+
<build_type>cmake</build_type>
31+
</export>
32+
</package>

0 commit comments

Comments
 (0)