Skip to content

Commit 6cdcde3

Browse files
authored
Merge pull request #14 from jcarpent/master
Simplify cmake files
2 parents b63ad91 + adc5ebd commit 6cdcde3

File tree

5 files changed

+42
-53
lines changed

5 files changed

+42
-53
lines changed

CMakeLists.txt

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2017 CNRS
2+
# Copyright (c) 2017-2018 CNRS
33
#
44
# This file is part of tsid
55
# pinocchio is free software: you can redistribute it
@@ -21,25 +21,18 @@ INCLUDE(cmake/boost.cmake)
2121
INCLUDE(cmake/eigen.cmake)
2222
INCLUDE(cmake/python.cmake)
2323
INCLUDE(cmake/ide.cmake)
24+
INCLUDE(cmake/apple.cmake)
2425

2526
SET(PROJECT_NAME tsid)
2627
SET(PROJECT_DESCRIPTION "Efficient Task Space Inverse Dynamics for Multi-body Systems based on Pinocchio")
2728
SET(PROJECT_URL "http://github.com/stack-of-tasks/tsid")
28-
OPTION(INSTALL_DOCUMENTATION "Generate and install the documentation" FALSE)
29+
OPTION(INSTALL_DOCUMENTATION "Generate and install the documentation" OFF)
2930

3031
SET(DOXYGEN_USE_MATHJAX YES)
3132

33+
# Handle APPLE Cmake policy
3234
IF(APPLE)
33-
SET(CMAKE_MACOSX_RPATH TRUE)
34-
SET(CMAKE_SKIP_BUILD_RPATH FALSE)
35-
SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
36-
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
37-
38-
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
39-
list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
40-
if("${isSystemDir}" STREQUAL "-1")
41-
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
42-
endif("${isSystemDir}" STREQUAL "-1")
35+
APPLY_DEFAULT_APPLE_CONFIGURATION()
4336
ENDIF(APPLE)
4437

4538
# Disable -Werror on Unix for now.

cmake

include/tsid/math/utils.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ namespace tsid
9494
const se3::SE3 & Mdes,
9595
se3::Motion & error);
9696

97-
void solveWithDampingFromSvd(Eigen::JacobiSVD<Eigen::MatrixXd::PlainObject> & svd,
97+
void solveWithDampingFromSvd(Eigen::JacobiSVD<Eigen::MatrixXd> & svd,
9898
ConstRefVector b,
9999
RefVector sol, double damping=0.0);
100100

@@ -107,13 +107,13 @@ namespace tsid
107107
unsigned int computationOptions = Eigen::ComputeThinU | Eigen::ComputeThinV);
108108

109109
void pseudoInverse(ConstRefMatrix A,
110-
Eigen::JacobiSVD<Eigen::MatrixXd::PlainObject>& svdDecomposition,
110+
Eigen::JacobiSVD<Eigen::MatrixXd>& svdDecomposition,
111111
RefMatrix Apinv,
112112
double tolerance,
113113
unsigned int computationOptions);
114114

115115
void pseudoInverse(ConstRefMatrix A,
116-
Eigen::JacobiSVD<Eigen::MatrixXd::PlainObject>& svdDecomposition,
116+
Eigen::JacobiSVD<Eigen::MatrixXd>& svdDecomposition,
117117
RefMatrix Apinv,
118118
double tolerance,
119119
double * nullSpaceBasisOfA,
@@ -122,20 +122,20 @@ namespace tsid
122122
unsigned int computationOptions);
123123

124124
void dampedPseudoInverse(ConstRefMatrix A,
125-
Eigen::JacobiSVD<Eigen::MatrixXd::PlainObject>& svdDecomposition,
125+
Eigen::JacobiSVD<Eigen::MatrixXd>& svdDecomposition,
126126
RefMatrix Apinv,
127127
double tolerance,
128128
double dampingFactor,
129129
unsigned int computationOptions = Eigen::ComputeThinU | Eigen::ComputeThinV,
130130
double * nullSpaceBasisOfA=0,
131131
int *nullSpaceRows=0, int *nullSpaceCols=0);
132132

133-
void nullSpaceBasisFromDecomposition(const Eigen::JacobiSVD<Eigen::MatrixXd::PlainObject> & svdDecomposition,
133+
void nullSpaceBasisFromDecomposition(const Eigen::JacobiSVD<Eigen::MatrixXd> & svdDecomposition,
134134
double tolerance,
135135
double * nullSpaceBasisMatrix,
136136
int &rows, int &cols);
137137

138-
void nullSpaceBasisFromDecomposition(const Eigen::JacobiSVD<Eigen::MatrixXd::PlainObject> & svdDecomposition,
138+
void nullSpaceBasisFromDecomposition(const Eigen::JacobiSVD<Eigen::MatrixXd> & svdDecomposition,
139139
int rank,
140140
double * nullSpaceBasisMatrix,
141141
int &rows, int &cols);

src/math/utils.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ namespace tsid
5252
error = se3::log6(Mdes.inverse() * M);
5353
}
5454

55-
void solveWithDampingFromSvd(Eigen::JacobiSVD<Eigen::MatrixXd::PlainObject> & svd,
55+
void solveWithDampingFromSvd(Eigen::JacobiSVD<Eigen::MatrixXd> & svd,
5656
ConstRefVector b,
5757
RefVector sol, double damping)
5858
{
@@ -77,7 +77,7 @@ namespace tsid
7777
RefVector sol, double damping)
7878
{
7979
assert(A.rows()==b.size());
80-
Eigen::JacobiSVD<typename Eigen::MatrixXd::PlainObject> svd(A.rows(), A.cols());
80+
Eigen::JacobiSVD<Eigen::MatrixXd> svd(A.rows(), A.cols());
8181
svd.compute(A, Eigen::ComputeThinU | Eigen::ComputeThinV);
8282

8383
solveWithDampingFromSvd(svd, b, sol, damping);
@@ -89,12 +89,12 @@ namespace tsid
8989
unsigned int computationOptions)
9090

9191
{
92-
Eigen::JacobiSVD<Eigen::MatrixXd::PlainObject> svdDecomposition(A.rows(), A.cols());
92+
Eigen::JacobiSVD<Eigen::MatrixXd> svdDecomposition(A.rows(), A.cols());
9393
pseudoInverse(A, svdDecomposition, Apinv, tolerance, computationOptions);
9494
}
9595

9696
void pseudoInverse(ConstRefMatrix A,
97-
Eigen::JacobiSVD<Eigen::MatrixXd::PlainObject>& svdDecomposition,
97+
Eigen::JacobiSVD<Eigen::MatrixXd> & svdDecomposition,
9898
RefMatrix Apinv,
9999
double tolerance,
100100
unsigned int computationOptions)
@@ -106,7 +106,7 @@ namespace tsid
106106
}
107107

108108
void pseudoInverse(ConstRefMatrix A,
109-
Eigen::JacobiSVD<Eigen::MatrixXd::PlainObject>& svdDecomposition,
109+
Eigen::JacobiSVD<Eigen::MatrixXd> & svdDecomposition,
110110
RefMatrix Apinv,
111111
double tolerance,
112112
double * nullSpaceBasisOfA,
@@ -118,7 +118,7 @@ namespace tsid
118118
if (computationOptions == 0) return; //if no computation options we cannot compute the pseudo inverse
119119
svdDecomposition.compute(A, computationOptions);
120120

121-
JacobiSVD<MatrixXd::PlainObject>::SingularValuesType singularValues = svdDecomposition.singularValues();
121+
JacobiSVD<MatrixXd>::SingularValuesType singularValues = svdDecomposition.singularValues();
122122
long int singularValuesSize = singularValues.size();
123123
int rank = 0;
124124
for (long int idx = 0; idx < singularValuesSize; idx++) {
@@ -140,7 +140,7 @@ namespace tsid
140140
}
141141

142142
void dampedPseudoInverse(ConstRefMatrix A,
143-
Eigen::JacobiSVD<Eigen::MatrixXd::PlainObject>& svdDecomposition,
143+
Eigen::JacobiSVD<Eigen::MatrixXd>& svdDecomposition,
144144
RefMatrix Apinv,
145145
double tolerance,
146146
double dampingFactor,
@@ -153,7 +153,7 @@ namespace tsid
153153
if (computationOptions == 0) return; //if no computation options we cannot compute the pseudo inverse
154154
svdDecomposition.compute(A, computationOptions);
155155

156-
JacobiSVD<MatrixXd::PlainObject>::SingularValuesType singularValues = svdDecomposition.singularValues();
156+
JacobiSVD<MatrixXd>::SingularValuesType singularValues = svdDecomposition.singularValues();
157157

158158
//rank will be used for the null space basis.
159159
//not sure if this is correct
@@ -178,13 +178,13 @@ namespace tsid
178178
}
179179
}
180180

181-
void nullSpaceBasisFromDecomposition(const Eigen::JacobiSVD<Eigen::MatrixXd::PlainObject>& svdDecomposition,
181+
void nullSpaceBasisFromDecomposition(const Eigen::JacobiSVD<Eigen::MatrixXd>& svdDecomposition,
182182
double tolerance,
183183
double * nullSpaceBasisMatrix,
184184
int &rows, int &cols)
185185
{
186186
using namespace Eigen;
187-
JacobiSVD<MatrixXd::PlainObject>::SingularValuesType singularValues = svdDecomposition.singularValues();
187+
JacobiSVD<MatrixXd>::SingularValuesType singularValues = svdDecomposition.singularValues();
188188
int rank = 0;
189189
for (int idx = 0; idx < singularValues.size(); idx++) {
190190
if (tolerance > 0 && singularValues(idx) > tolerance) {
@@ -195,7 +195,7 @@ namespace tsid
195195

196196
}
197197

198-
void nullSpaceBasisFromDecomposition(const Eigen::JacobiSVD<Eigen::MatrixXd::PlainObject> & svdDecomposition,
198+
void nullSpaceBasisFromDecomposition(const Eigen::JacobiSVD<Eigen::MatrixXd> & svdDecomposition,
199199
int rank,
200200
double * nullSpaceBasisMatrix,
201201
int &rows, int &cols)

unittest/CMakeLists.txt

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,20 @@
1818
# --- MACROS ------------------------------------------------------------------
1919
# --- MACROS ------------------------------------------------------------------
2020

21+
IF(BUILD_UNIT_TESTS)
22+
SET(DISABLE_TESTS OFF)
23+
ELSE(BUILD_UNIT_TESTS)
24+
SET(DISABLE_TESTS ON)
25+
ENDIF(BUILD_UNIT_TESTS)
26+
include(../cmake/test.cmake)
27+
2128
MACRO(ADD_TEST_CFLAGS target flag)
2229
SET_PROPERTY(TARGET ${target} APPEND_STRING PROPERTY COMPILE_FLAGS " ${flag}")
2330
ENDMACRO(ADD_TEST_CFLAGS)
2431

25-
MACRO(ADD_UNIT_TEST NAME PKGS)
26-
IF (BUILD_UNIT_TESTS)
27-
ADD_EXECUTABLE(${NAME} ${NAME})
28-
ELSE (BUILD_UNIT_TESTS)
29-
ADD_EXECUTABLE(${NAME} EXCLUDE_FROM_ALL ${NAME})
30-
ENDIF (BUILD_UNIT_TESTS)
32+
MACRO(ADD_TESTCASE NAME PKGS)
33+
ADD_UNIT_TEST(${NAME} ${NAME})
34+
3135
SET_TARGET_PROPERTIES(${NAME} PROPERTIES LINKER_LANGUAGE CXX)
3236
ADD_TEST_CFLAGS(${NAME} "-DBOOST_TEST_DYN_LINK")
3337
SET(MODULE_NAME "${NAME}Test")
@@ -40,34 +44,26 @@ MACRO(ADD_UNIT_TEST NAME PKGS)
4044

4145
TARGET_LINK_LIBRARIES(${NAME} ${PROJECT_NAME})
4246
TARGET_LINK_LIBRARIES(${NAME} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
43-
44-
ADD_TEST(NAME ${NAME} COMMAND ${NAME})
45-
ADD_DEPENDENCIES(check ${NAME})
46-
ENDMACRO(ADD_UNIT_TEST)
47+
ENDMACRO(ADD_TESTCASE)
4748

4849
# --- RULES -------------------------------------------------------------------
4950
# --- RULES -------------------------------------------------------------------
5051
# --- RULES -------------------------------------------------------------------
51-
IF(APPLE)
52-
ADD_CUSTOM_TARGET(check COMMAND export DYLD_LIBRARY_PATH=$ENV{DYLD_LIBRARY_PATH} && ${CMAKE_CTEST_COMMAND})
53-
ELSE(APPLE)
54-
ADD_CUSTOM_TARGET(check COMMAND ${CMAKE_CTEST_COMMAND})
55-
ENDIF(APPLE)
5652

57-
ADD_UNIT_TEST(constraints "eigen3;pinocchio")
58-
ADD_UNIT_TEST(trajectories "eigen3;pinocchio")
53+
ADD_TESTCASE(constraints "eigen3;pinocchio")
54+
ADD_TESTCASE(trajectories "eigen3;pinocchio")
5955

60-
ADD_UNIT_TEST(robot-wrapper "eigen3;pinocchio")
56+
ADD_TESTCASE(robot-wrapper "eigen3;pinocchio")
6157
ADD_TEST_CFLAGS(robot-wrapper '-DTSID_SOURCE_DIR=\\\"${${PROJECT_NAME}_SOURCE_DIR}\\\"')
6258

63-
ADD_UNIT_TEST(tasks "eigen3;pinocchio")
59+
ADD_TESTCASE(tasks "eigen3;pinocchio")
6460
ADD_TEST_CFLAGS(tasks '-DTSID_SOURCE_DIR=\\\"${${PROJECT_NAME}_SOURCE_DIR}\\\"')
6561

66-
ADD_UNIT_TEST(contacts "eigen3;pinocchio")
62+
ADD_TESTCASE(contacts "eigen3;pinocchio")
6763
ADD_TEST_CFLAGS(contacts '-DTSID_SOURCE_DIR=\\\"${${PROJECT_NAME}_SOURCE_DIR}\\\"')
6864

69-
ADD_UNIT_TEST(tsid-formulation "eigen3;pinocchio")
65+
ADD_TESTCASE(tsid-formulation "eigen3;pinocchio")
7066
ADD_TEST_CFLAGS(tsid-formulation '-DTSID_SOURCE_DIR=\\\"${${PROJECT_NAME}_SOURCE_DIR}\\\"')
7167

72-
ADD_UNIT_TEST(math_utils "eigen3;pinocchio")
73-
ADD_UNIT_TEST(hqp_solvers "eigen3;pinocchio")
68+
ADD_TESTCASE(math_utils "eigen3;pinocchio")
69+
ADD_TESTCASE(hqp_solvers "eigen3;pinocchio")

0 commit comments

Comments
 (0)