55cmake_minimum_required (VERSION 3.12)
66
77set (PROJECT_NAME proxsuite-nlp)
8- set (PROJECT_DESCRIPTION
9- "A primal-dual augmented Lagrangian-type solver for nonlinear programming on manifolds."
8+ set (
9+ PROJECT_DESCRIPTION
10+ "A primal-dual augmented Lagrangian-type solver for nonlinear programming on manifolds."
1011)
1112set (PROJECT_URL "https://github.com/Simple-Robotics/proxsuite-nlp" )
1213set (PROJECT_CUSTOM_HEADER_EXTENSION "hpp" )
@@ -42,16 +43,17 @@ else()
4243 elseif (${CMAKE_VERSION} VERSION_LESS "3.14.0" )
4344 message (
4445 FATAL_ERROR
45- "\n Can't find jrl-cmakemodules. Please either:\n "
46- " - use git submodule: 'git submodule update --init'\n "
47- " - or install https://github.com/jrl-umi3218/jrl-cmakemodules\n "
48- " - or upgrade your CMake version to >= 3.14 to allow automatic fetching\n "
46+ "\n Can't find jrl-cmakemodules. Please either:\n "
47+ " - use git submodule: 'git submodule update --init'\n "
48+ " - or install https://github.com/jrl-umi3218/jrl-cmakemodules\n "
49+ " - or upgrade your CMake version to >= 3.14 to allow automatic fetching\n "
4950 )
5051 else ()
5152 message (STATUS "JRL cmakemodules not found. Let's fetch it." )
5253 include (FetchContent)
5354 FetchContent_Declare(
54- "jrl-cmakemodules" GIT_REPOSITORY "https://github.com/jrl-umi3218/jrl-cmakemodules.git"
55+ "jrl-cmakemodules"
56+ GIT_REPOSITORY "https://github.com/jrl-umi3218/jrl-cmakemodules.git"
5557 )
5658 FetchContent_MakeAvailable("jrl-cmakemodules" )
5759 FetchContent_GetProperties("jrl-cmakemodules" SOURCE_DIR JRL_CMAKE_MODULES)
@@ -83,33 +85,54 @@ apply_default_apple_configuration()
8385
8486if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES )
8587 message (STATUS "Setting build type to 'Release' as none was specified." )
86- set (CMAKE_BUILD_TYPE
87- Release
88- CACHE STRING "Choose the type of build." FORCE
89- )
88+ set (CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
9089 # Set the possible values of build type for cmake-gui
9190 set_property (
92- CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo"
91+ CACHE CMAKE_BUILD_TYPE
92+ PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo"
9393 )
9494endif ()
9595
9696# --- OPTIONS ----------------------------------------
9797option (BUILD_PYTHON_INTERFACE "Build the Python bindings" ON )
98- option (BUILD_WITH_VERSION_SUFFIX "Build libraries with version appended to suffix" OFF )
99- option (ENABLE_TEMPLATE_INSTANTIATION "Template instantiation of the main library" ON )
98+ option (
99+ BUILD_WITH_VERSION_SUFFIX
100+ "Build libraries with version appended to suffix"
101+ OFF
102+ )
103+ option (
104+ ENABLE_TEMPLATE_INSTANTIATION
105+ "Template instantiation of the main library"
106+ ON
107+ )
100108option (BUILD_EXAMPLES "Build the examples" ON )
101109option (BUILD_BENCHMARK "Build the benchmarks" OFF )
102110
103111# --- OPTIONAL DEPENDENCIES -------------------------
104- option (BUILD_WITH_PINOCCHIO_SUPPORT "Build the library with support for Pinocchio" ON )
105- option (BUILD_WITH_PROXSUITE_SUPPORT "Build the library with ProxSuite's LDLT decomposition" OFF )
112+ option (
113+ BUILD_WITH_PINOCCHIO_SUPPORT
114+ "Build the library with support for Pinocchio"
115+ ON
116+ )
117+ option (
118+ BUILD_WITH_PROXSUITE_SUPPORT
119+ "Build the library with ProxSuite's LDLT decomposition"
120+ OFF
121+ )
106122cmake_dependent_option(
107- GENERATE_PYTHON_STUBS "Generate the Python stubs associated to the Python library" OFF
108- BUILD_PYTHON_INTERFACE OFF
123+ GENERATE_PYTHON_STUBS
124+ "Generate the Python stubs associated to the Python library"
125+ OFF
126+ BUILD_PYTHON_INTERFACE
127+ OFF
109128)
110129
111130option (INITIALIZE_WITH_NAN "Initialize Eigen entries with NaN" OFF )
112- option (CHECK_RUNTIME_MALLOC "Check if some memory allocations are performed at runtime" OFF )
131+ option (
132+ CHECK_RUNTIME_MALLOC
133+ "Check if some memory allocations are performed at runtime"
134+ OFF
135+ )
113136
114137# Variable containing all the cflags definition relative to optional dependencies
115138# and options
@@ -128,7 +151,11 @@ endif(CHECK_RUNTIME_MALLOC)
128151
129152if (ENABLE_TEMPLATE_INSTANTIATION)
130153 add_compile_definitions (PROXSUITE_NLP_ENABLE_TEMPLATE_INSTANTIATION)
131- list (APPEND CFLAGS_DEPENDENCIES "-DPROXSUITE_NLP_ENABLE_TEMPLATE_INSTANTIATION" )
154+ list (
155+ APPEND
156+ CFLAGS_DEPENDENCIES
157+ "-DPROXSUITE_NLP_ENABLE_TEMPLATE_INSTANTIATION"
158+ )
132159endif (ENABLE_TEMPLATE_INSTANTIATION)
133160
134161macro (TAG_LIBRARY_VERSION target )
@@ -159,9 +186,12 @@ if(BUILD_PYTHON_INTERFACE)
159186 add_project_dependency(eigenpy 3.8.0 REQUIRED PKG_CONFIG_REQUIRES "eigenpy >= 3.8.0" )
160187
161188 execute_process (
162- COMMAND ${PYTHON_EXECUTABLE} -c "import platform; print(platform.python_implementation())"
189+ COMMAND
190+ ${PYTHON_EXECUTABLE} -c
191+ "import platform; print(platform.python_implementation())"
163192 OUTPUT_VARIABLE _python_implementation_value
164- OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET
193+ OUTPUT_STRIP_TRAILING_WHITESPACE
194+ ERROR_QUIET
165195 )
166196 message (STATUS "Python compiler: ${_python_implementation_value} " )
167197endif (BUILD_PYTHON_INTERFACE)
@@ -180,63 +210,69 @@ file(GLOB_RECURSE LIB_HEADERS ${LIB_HEADER_DIR}/*.hpp ${LIB_HEADER_DIR}/*.hxx)
180210set (LIB_SOURCES ${PROJECT_SOURCE_DIR} /src/block-kind.cpp)
181211
182212if (ENABLE_TEMPLATE_INSTANTIATION)
183-
184- set ( LIB_TEMPLATE_SOURCES
185- ${PROJECT_SOURCE_DIR} /src/block-ldlt.cpp
186- ${PROJECT_SOURCE_DIR} /src/constraints.cpp
187- ${PROJECT_SOURCE_DIR} /src/constraint-set.cpp
188- ${PROJECT_SOURCE_DIR} /src/constraint-set-product.cpp
189- ${PROJECT_SOURCE_DIR} /src/manifold-base.cpp
190- ${PROJECT_SOURCE_DIR} /src/cartesian-product.cpp
191- ${PROJECT_SOURCE_DIR} /src/function-base.cpp
192- ${PROJECT_SOURCE_DIR} /src/squared-distance.cpp
193- ${PROJECT_SOURCE_DIR} /src/quadratic-residual.cpp
194- ${PROJECT_SOURCE_DIR} /src/cost -function.cpp
195- ${PROJECT_SOURCE_DIR} /src/cost -sum.cpp
196- ${PROJECT_SOURCE_DIR} /src/prox-solver.cpp
197- ${PROJECT_SOURCE_DIR} /src/linesearch-base.cpp
198- ${PROJECT_SOURCE_DIR} /src/linesearch-armijo.cpp
199- ${PROJECT_SOURCE_DIR} /src/results.cpp
200- ${PROJECT_SOURCE_DIR} /src/problem-base.cpp
201- ${PROJECT_SOURCE_DIR} /src/workspace.cpp
202- ${PROJECT_SOURCE_DIR} /src/pdal.cpp
213+ set (
214+ LIB_TEMPLATE_SOURCES
215+ ${PROJECT_SOURCE_DIR} /src/block-ldlt.cpp
216+ ${PROJECT_SOURCE_DIR} /src/constraints.cpp
217+ ${PROJECT_SOURCE_DIR} /src/constraint-set.cpp
218+ ${PROJECT_SOURCE_DIR} /src/constraint-set-product.cpp
219+ ${PROJECT_SOURCE_DIR} /src/manifold-base.cpp
220+ ${PROJECT_SOURCE_DIR} /src/cartesian-product.cpp
221+ ${PROJECT_SOURCE_DIR} /src/function-base.cpp
222+ ${PROJECT_SOURCE_DIR} /src/squared-distance.cpp
223+ ${PROJECT_SOURCE_DIR} /src/quadratic-residual.cpp
224+ ${PROJECT_SOURCE_DIR} /src/cost -function.cpp
225+ ${PROJECT_SOURCE_DIR} /src/cost -sum.cpp
226+ ${PROJECT_SOURCE_DIR} /src/prox-solver.cpp
227+ ${PROJECT_SOURCE_DIR} /src/linesearch-base.cpp
228+ ${PROJECT_SOURCE_DIR} /src/linesearch-armijo.cpp
229+ ${PROJECT_SOURCE_DIR} /src/results.cpp
230+ ${PROJECT_SOURCE_DIR} /src/problem-base.cpp
231+ ${PROJECT_SOURCE_DIR} /src/workspace.cpp
232+ ${PROJECT_SOURCE_DIR} /src/pdal.cpp
203233 )
204- set (LIB_TEMPLATE_DECLARATIONS
205- ${LIB_HEADER_DIR} /linalg/block-ldlt.txx
206- ${LIB_HEADER_DIR} /manifold-base.txx
207- ${LIB_HEADER_DIR} /function-base.txx
208- ${LIB_HEADER_DIR} /cost -function.txx
209- ${LIB_HEADER_DIR} /cost -sum.txx
210- ${LIB_HEADER_DIR} /prox-solver.txx
211- ${LIB_HEADER_DIR} /results.txx
212- ${LIB_HEADER_DIR} /problem-base.txx
213- ${LIB_HEADER_DIR} /workspace.txx
214- ${LIB_HEADER_DIR} /pdal.txx
215- ${LIB_HEADER_DIR} /linesearch.txx
216- ${LIB_HEADER_DIR} /modelling/costs/squared-distance.txx
217- ${LIB_HEADER_DIR} /modelling/costs/quadratic-residual.txx
218- ${LIB_HEADER_DIR} /modelling/spaces/cartesian-product.txx
234+ set (
235+ LIB_TEMPLATE_DECLARATIONS
236+ ${LIB_HEADER_DIR} /linalg/block-ldlt.txx
237+ ${LIB_HEADER_DIR} /manifold-base.txx
238+ ${LIB_HEADER_DIR} /function-base.txx
239+ ${LIB_HEADER_DIR} /cost -function.txx
240+ ${LIB_HEADER_DIR} /cost -sum.txx
241+ ${LIB_HEADER_DIR} /prox-solver.txx
242+ ${LIB_HEADER_DIR} /results.txx
243+ ${LIB_HEADER_DIR} /problem-base.txx
244+ ${LIB_HEADER_DIR} /workspace.txx
245+ ${LIB_HEADER_DIR} /pdal.txx
246+ ${LIB_HEADER_DIR} /linesearch.txx
247+ ${LIB_HEADER_DIR} /modelling/costs/squared-distance.txx
248+ ${LIB_HEADER_DIR} /modelling/costs/quadratic-residual.txx
249+ ${LIB_HEADER_DIR} /modelling/spaces/cartesian-product.txx
219250 )
220251 if (BUILD_WITH_PINOCCHIO_SUPPORT)
221- list (APPEND LIB_TEMPLATE_SOURCES ${PROJECT_SOURCE_DIR} /src/multibody/rigid-transform-point.cpp
222- ${PROJECT_SOURCE_DIR} /src/multibody/spaces.cpp
252+ list (
253+ APPEND
254+ LIB_TEMPLATE_SOURCES
255+ ${PROJECT_SOURCE_DIR} /src/multibody/rigid-transform-point.cpp
256+ ${PROJECT_SOURCE_DIR} /src/multibody/spaces.cpp
223257 )
224- list (APPEND LIB_TEMPLATE_DECLARATIONS
225- ${LIB_HEADER_DIR} /modelling/residuals/rigid-transform-point.txx
226- ${LIB_HEADER_DIR} /modelling/spaces/multibody.txx
258+ list (
259+ APPEND
260+ LIB_TEMPLATE_DECLARATIONS
261+ ${LIB_HEADER_DIR} /modelling/residuals/rigid-transform-point.txx
262+ ${LIB_HEADER_DIR} /modelling/spaces/multibody.txx
227263 )
228264 endif (BUILD_WITH_PINOCCHIO_SUPPORT)
229265 list (APPEND LIB_HEADERS ${LIB_TEMPLATE_DECLARATIONS} )
230266 list (APPEND LIB_SOURCES ${LIB_TEMPLATE_SOURCES} )
231-
232267endif (ENABLE_TEMPLATE_INSTANTIATION)
233268
234269function (set_standard_output_directory target )
235270 set_target_properties (
236271 ${target}
237- PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR} /bin
238- LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR} /lib
239- ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR} /lib
272+ PROPERTIES
273+ RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR} /bin
274+ LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR} /lib
275+ ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR} /lib
240276 )
241277endfunction ()
242278
@@ -248,12 +284,19 @@ function(create_library)
248284 add_library (proxsuite::nlp ALIAS ${PROJECT_NAME} )
249285 add_library (${PROJECT_NAME} ::${PROJECT_NAME} ALIAS ${PROJECT_NAME} )
250286 set_standard_output_directory(${PROJECT_NAME} )
251- set_target_properties (${PROJECT_NAME} PROPERTIES LINKER_LANGUAGE CXX INSTALL_RPATH "\$ ORIGIN" )
287+ set_target_properties (
288+ ${PROJECT_NAME}
289+ PROPERTIES LINKER_LANGUAGE CXX INSTALL_RPATH "\$ ORIGIN"
290+ )
252291 target_compile_definitions (
253- ${PROJECT_NAME} PUBLIC ${CURRENT_COMPILE_DEFINITIONS} $<$<PLATFORM_ID:Windows>:NOMINMAX>
292+ ${PROJECT_NAME}
293+ PUBLIC ${CURRENT_COMPILE_DEFINITIONS} $<$<PLATFORM_ID:Windows>:NOMINMAX>
254294 )
255295
256- set_target_properties (${PROJECT_NAME} PROPERTIES LINKER_LANGUAGE CXX VERSION ${PROJECT_VERSION} )
296+ set_target_properties (
297+ ${PROJECT_NAME}
298+ PROPERTIES LINKER_LANGUAGE CXX VERSION ${PROJECT_VERSION}
299+ )
257300 if (BUILD_LIBRARY_WITH_VERSION_SUFFIX)
258301 tag_library_version(${PROJECT_NAME} )
259302 endif ()
@@ -266,27 +309,40 @@ function(create_library)
266309 target_link_libraries (${PROJECT_NAME} PUBLIC Boost::boost)
267310 target_link_libraries (${PROJECT_NAME} PUBLIC fmt::fmt)
268311 if (BUILD_WITH_PROXSUITE_SUPPORT)
269- target_link_libraries (${PROJECT_NAME} PUBLIC proxsuite::proxsuite-vectorized)
312+ target_link_libraries (
313+ ${PROJECT_NAME}
314+ PUBLIC proxsuite::proxsuite-vectorized
315+ )
270316 endif ()
271317 target_include_directories (
272318 ${PROJECT_NAME}
273- PUBLIC $<INSTALL_INTERFACE:include > $<BUILD_INTERFACE:${PROJECT_BINARY_DIR} /include >
274- $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR} /include >
319+ PUBLIC
320+ $<INSTALL_INTERFACE:include >
321+ $<BUILD_INTERFACE:${PROJECT_BINARY_DIR} /include >
322+ $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR} /include >
275323 )
276324
277325 set (MSVC_CMD_OPTIONS /bigobj)
278- target_compile_options (${PROJECT_NAME} PUBLIC $<$<CXX_COMPILER_ID:MSVC >:${MSVC_CMD_OPTIONS} >)
326+ target_compile_options (
327+ ${PROJECT_NAME}
328+ PUBLIC $<$<CXX_COMPILER_ID:MSVC >:${MSVC_CMD_OPTIONS} >
329+ )
279330
280331 foreach (headerFile ${LIB_HEADERS} )
281- string (REGEX REPLACE "${PROJECT_SOURCE_DIR} /" "" headerFileRelative ${headerFile} )
332+ string (
333+ REGEX REPLACE
334+ "${PROJECT_SOURCE_DIR} /"
335+ ""
336+ headerFileRelative
337+ ${headerFile}
338+ )
282339 get_filename_component (headerPath ${headerFileRelative} PATH )
283340 install (
284341 FILES ${headerFileRelative}
285342 DESTINATION ${CMAKE_INSTALL_PREFIX} /${headerPath}
286343 PERMISSIONS OWNER_READ GROUP_READ WORLD_READ OWNER_WRITE
287344 )
288345 endforeach (headerFile ${LIB_HEADERS} )
289-
290346endfunction ()
291347
292348create_library()
@@ -297,8 +353,7 @@ add_source_group(LIB_SOURCES)
297353install (
298354 TARGETS ${PROJECT_NAME}
299355 EXPORT ${TARGETS_EXPORT_NAME}
300- INCLUDES
301- DESTINATION ${CMAKE_INSTALL_FULL_INCLUDEDIR}
356+ INCLUDES DESTINATION ${CMAKE_INSTALL_FULL_INCLUDEDIR}
302357 LIBRARY DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}
303358 ARCHIVE DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}
304359 RUNTIME DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}
@@ -317,10 +372,7 @@ endif()
317372macro (EXPORT_VARIABLE var_name var_value)
318373 get_directory_property (has_parent PARENT_DIRECTORY )
319374 if (has_parent)
320- set (${var_name}
321- ${var_value}
322- PARENT_SCOPE
323- )
375+ set (${var_name} ${var_value} PARENT_SCOPE)
324376 else ()
325377 set (${var_name} ${var_value} )
326378 endif ()
0 commit comments