Skip to content

Commit 6c46eb7

Browse files
committed
now exporting linked libraries from ct_optcon correctly
1 parent fd7ea8f commit 6c46eb7

14 files changed

+96
-126
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ CMakeCache.txt
44
!clang-cxx-dev-tools.cmake
55
!compilerSettings.cmake
66
!FindIPOPT.cmake
7+
!Findblasfeo.cmake
8+
!Findhpipm.cmake
79
*.a
810
*.o
911
*.so

ct_core/CMakeLists.txt

+10-5
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,17 @@ if(USE_PRESPEC)
8686
endif(USE_PRESPEC)
8787

8888

89-
## create ct_core library
90-
add_library(ct_core SHARED src/core/plot/plot.cpp)
91-
target_include_directories(ct_core PUBLIC ${ct_core_target_include_dirs})
92-
target_link_libraries(ct_core
89+
## create ct_core libraries
90+
add_library(ct_plot SHARED src/core/plot/plot.cpp)
91+
target_include_directories(ct_plot PUBLIC ${ct_core_target_include_dirs})
92+
target_link_libraries(ct_plot ${ct_core_LIBS})
93+
94+
add_library(ct_core INTERFACE)
95+
target_include_directories(ct_core INTERFACE ${ct_core_target_include_dirs})
96+
target_link_libraries(ct_core INTERFACE
9397
${ct_core_LIBS}
9498
${PRESPEC_LIB_NAMES}
99+
ct_plot
95100
pthread
96101
dl # required for gcc compatibility
97102
)
@@ -147,7 +152,7 @@ install(FILES "${PROJECT_BINARY_DIR}/ct_coreConfig.cmake" DESTINATION "share/ct_
147152

148153
## install library and targets
149154
install(
150-
TARGETS ct_core ${PRESPEC_LIB_NAMES}
155+
TARGETS ct_core ct_plot ${PRESPEC_LIB_NAMES}
151156
EXPORT ct_core_export
152157
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
153158
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}

ct_core/cmake/ct_coreConfig.cmake.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ include(${CMAKE_CURRENT_LIST_DIR}/ct_core_export.cmake)
88
get_target_property(ct_core_INCLUDE_DIRS ct_core INTERFACE_INCLUDE_DIRECTORIES)
99

1010
# define libraries in legacy mode
11-
get_property(ct_core_LIB TARGET ct_core PROPERTY LOCATION)
11+
get_property(ct_core_LIB TARGET ct_plot PROPERTY LOCATION)
1212
list(APPEND ct_core_LIBRARIES ${ct_core_LIB})
1313

1414
# Required for catkin_simple to link against these libraries

ct_models/CMakeLists.txt

+11-2
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ endif(BUILD_HYQ_LINEARIZATION_TIMINGS)
118118
add_executable(InvertedPendulumWithActuatorCodeGen src/InvertedPendulum/codegen/InvertedPendulumWithActuatorCodeGen.cpp)
119119
target_include_directories(InvertedPendulumWithActuatorCodeGen PUBLIC ${ct_models_target_include_dirs})
120120
target_link_libraries(InvertedPendulumWithActuatorCodeGen ct_rbd)
121-
list(APPEND CT_MODEL_LIBS InvertedPendulumWithActuatorCodeGen)
122121

123122
add_library(InvertedPendulumActDynLinearizedForward include/ct/models/InvertedPendulum/codegen/InvertedPendulumActDynLinearizedForward.cpp)
124123
target_include_directories(InvertedPendulumWithActuatorCodeGen PUBLIC ${ct_models_target_include_dirs})
@@ -191,6 +190,16 @@ target_link_libraries(irb4600_ik ct_rbd)
191190
list(APPEND CT_MODEL_LIBS irb4600_ik)
192191

193192

193+
## convenience library for passing on includes
194+
add_library(ct_models INTERFACE)
195+
target_include_directories(ct_models INTERFACE ${ct_models_target_include_dirs})
196+
target_link_libraries(ct_models INTERFACE
197+
ct_rbd
198+
${CT_MODEL_LIBS}
199+
)
200+
list(APPEND CT_MODEL_LIBS ct_models)
201+
202+
194203
############
195204
# EXAMPLES #
196205
############
@@ -241,7 +250,7 @@ install(
241250
RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR}
242251
)
243252

244-
## create the ct_rbd.cmake file which holds target includes and dependencies
253+
## create the ct_models.cmake file which holds target includes and dependencies
245254
install (EXPORT ct_models_export DESTINATION share/ct_models/cmake)
246255

247256

ct_models/cmake/ct_modelsConfig.cmake.in

+7
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ set(ct_models_COMPILE_DEFINITIONS "@ct_models_compile_definitions@")
66

77
include(${CMAKE_CURRENT_LIST_DIR}/ct_models_export.cmake)
88

9+
#define includes in legacy mode
10+
get_target_property(ct_models_INCLUDE_DIRS ct_models INTERFACE_INCLUDE_DIRECTORIES)
11+
12+
# define libraries in legacy mode
13+
get_property(ct_models_LIB TARGET ct_models PROPERTY INTERFACE_LINK_LIBRARIES)
14+
list(APPEND ct_models_LIBRARIES ${ct_models_LIB})
15+
916
# Required for catkin_simple to link against these libraries
1017
set(ct_models_FOUND_CATKIN_PROJECT true)
1118

ct_optcon/CMakeLists.txt

+15-30
Original file line numberDiff line numberDiff line change
@@ -57,29 +57,15 @@ else(LAPACK_FOUND)
5757
endif(LAPACK_FOUND)
5858

5959

60-
## include BLASFEO AND HPIPM
61-
set(HPIPM_INCLUDE_DIRS "")
62-
set(HPIPM_LIBS "")
63-
if(HPIPM)
64-
if(DEFINED ENV{BLASFEO_DIR})
65-
if(DEFINED ENV{HPIPM_DIR})
66-
message(WARNING "...Found HPIPM and BLASFEO environment variables")
67-
add_definitions (-DHPIPM)
68-
69-
list(APPEND HPIPM_INCLUDE_DIRS $ENV{BLASFEO_DIR}/include)
70-
list(APPEND HPIPM_INCLUDE_DIRS $ENV{HPIPM_DIR}/include)
71-
72-
link_directories($ENV{BLASFEO_DIR}/lib)
73-
link_directories($ENV{HPIPM_DIR}/lib)
74-
list(APPEND HPIPM_LIBS hpipm blasfeo)
75-
76-
else(DEFINED ENV{HPIPM_DIR})
77-
message(WARNING "Trying to build with HPIPM, but no ENV variable for HPIPM found.")
78-
endif(DEFINED ENV{HPIPM_DIR})
79-
else(DEFINED ENV{BLASFEO_DIR})
80-
message(WARNING "Trying to build with HPIPM, but no ENV variable for Blasfeo found.")
81-
endif(DEFINED ENV{BLASFEO_DIR})
82-
endif(HPIPM)
60+
## include HPIPM (required: environment variables for blasfeo and hpipm set)
61+
find_package(blasfeo QUIET)
62+
find_package(hpipm QUIET)
63+
if(blasfeo_FOUND AND hpipm_FOUND)
64+
message(STATUS "Found HPIPM and BLASFEO")
65+
set(HPIPM ON)
66+
add_definitions(-DHPIPM)
67+
list(APPEND HPIPM_LIBS ${hpipm_LIBRARIES} ${blasfeo_LIBRARIES})
68+
endif()
8369

8470

8571
## include IPOPT (after installation via sudo apt-get install coinor-libipopt-dev)
@@ -122,7 +108,8 @@ endif()
122108
set(ct_optcon_target_include_dirs
123109
${ct_core_INCLUDE_DIRS}
124110
${matlab_cpp_interface_INCLUDE_DIRS}
125-
${HPIPM_INCLUDE_DIRS}
111+
${blasfeo_INCLUDE_DIRS}
112+
${hpipm_INCLUDE_DIRS}
126113
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
127114
$<INSTALL_INTERFACE:include>
128115
)
@@ -153,11 +140,9 @@ endif(USE_PRESPEC)
153140

154141

155142
## create ct_optcon library
156-
add_library(ct_optcon SHARED
157-
src/ct_optcon.cpp
158-
)
159-
target_include_directories(ct_optcon PUBLIC ${ct_optcon_target_include_dirs})
160-
target_link_libraries(ct_optcon
143+
add_library(ct_optcon INTERFACE)
144+
target_include_directories(ct_optcon INTERFACE ${ct_optcon_target_include_dirs})
145+
target_link_libraries(ct_optcon INTERFACE
161146
ct_core
162147
${matlab_cpp_interface_LIBRARIES}
163148
${LAPACK_LIBS}
@@ -220,7 +205,7 @@ install(
220205
RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR}
221206
)
222207

223-
## create the ct_core.cmake file which holds target includes and dependencies
208+
## create the ct_optcon.cmake file which holds target includes and dependencies
224209
install (EXPORT ct_optcon_export DESTINATION share/ct_optcon/cmake)
225210

226211

ct_optcon/cmake/Findblasfeo.cmake

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
## find blasfeo library based on user-defined environment variable
2+
if(DEFINED ENV{BLASFEO_DIR})
3+
message(STATUS "Found BLASFEO environment variable.")
4+
list(APPEND blasfeo_INCLUDE_DIRS $ENV{BLASFEO_DIR}/include)
5+
6+
find_library(blasfeo_libs_found blasfeo $ENV{BLASFEO_DIR}/lib)
7+
8+
add_library(blasfeo STATIC IMPORTED)
9+
set_target_properties(blasfeo PROPERTIES IMPORTED_LOCATION ${blasfeo_libs_found})
10+
11+
set_target_properties(blasfeo PROPERTIES
12+
INTERFACE_INCLUDE_DIRECTORIES "$ENV{BLASFEO_DIR}/include"
13+
INTERFACE_LINK_LIBRARIES ${blasfeo_libs_found}
14+
)
15+
16+
set(blasfeo_LIBRARIES ${blasfeo_libs_found})
17+
18+
set(blasfeo_FOUND true)
19+
else()
20+
message(STATUS "No ENV variable for blasfeo found.")
21+
set(blasfeo_FOUND false)
22+
endif()

ct_optcon/cmake/Findhpipm.cmake

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
## find hpipm library based on user-defined environment variable
2+
if(DEFINED ENV{HPIPM_DIR})
3+
message(STATUS "Found HPIPM environment variable.")
4+
5+
list(APPEND hpipm_INCLUDE_DIRS $ENV{HPIPM_DIR}/include)
6+
7+
find_library(hpipm_libs_found hpipm $ENV{HPIPM_DIR}/lib)
8+
9+
add_library(hpipm STATIC IMPORTED)
10+
set_target_properties(hpipm PROPERTIES IMPORTED_LOCATION ${hpipm_libs_found})
11+
12+
set_target_properties(hpipm PROPERTIES
13+
INTERFACE_INCLUDE_DIRECTORIES "$ENV{HPIPM_DIR}/include"
14+
INTERFACE_LINK_LIBRARIES ${hpipm_libs_found}
15+
)
16+
set(hpipm_LIBRARIES ${hpipm_libs_found})
17+
18+
set(hpipm_FOUND true)
19+
else()
20+
message(STATUS "No ENV variable for HPIPM found.")
21+
set(hpipm_FOUND false)
22+
endif()
23+

ct_optcon/cmake/ct_optconConfig.cmake.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ include(${CMAKE_CURRENT_LIST_DIR}/ct_optcon_export.cmake)
1010
get_target_property(ct_optcon_INCLUDE_DIRS ct_optcon INTERFACE_INCLUDE_DIRECTORIES)
1111

1212
# define libraries in legacy mode
13-
get_property(ct_optcon_LIB TARGET ct_optcon PROPERTY LOCATION)
13+
get_property(ct_optcon_LIB TARGET ct_optcon PROPERTY INTERFACE_LINK_LIBRARIES)
1414
list(APPEND ct_optcon_LIBRARIES ${ct_optcon_LIB})
1515

1616
# Required for catkin_simple to link against these libraries

ct_optcon/cmake/externalSolvers.cmake

-81
This file was deleted.

ct_optcon/src/ct_optcon.cpp

-1
This file was deleted.

ct_rbd/CMakeLists.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ set(ct_rbd_target_include_dirs
3838

3939

4040
## create ct_rbd library
41-
add_library(ct_rbd SHARED src/ct_rbd.cpp)
42-
target_include_directories(ct_rbd PUBLIC ${ct_rbd_target_include_dirs})
43-
target_link_libraries(ct_rbd PUBLIC ct_optcon)
41+
add_library(ct_rbd INTERFACE)
42+
target_include_directories(ct_rbd INTERFACE ${ct_rbd_target_include_dirs})
43+
target_link_libraries(ct_rbd INTERFACE ct_optcon)
4444

4545

4646
###########

ct_rbd/cmake/ct_rbdConfig.cmake.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ include(${CMAKE_CURRENT_LIST_DIR}/ct_rbd_export.cmake)
1010
get_target_property(ct_rbd_INCLUDE_DIRS ct_rbd INTERFACE_INCLUDE_DIRECTORIES)
1111

1212
# define libraries in legacy mode
13-
get_property(ct_rbd_LIB TARGET ct_rbd PROPERTY LOCATION)
13+
get_property(ct_rbd_LIB TARGET ct_rbd PROPERTY INTERFACE_LINK_LIBRARIES)
1414
list(APPEND ct_rbd_LIBRARIES ${ct_rbd_LIB})
1515

1616
# Required for catkin_simple to link against these libraries

ct_rbd/src/ct_rbd.cpp

-1
This file was deleted.

0 commit comments

Comments
 (0)