Skip to content

Commit

Permalink
Just first commit, it compiles and install correctly, but the job is …
Browse files Browse the repository at this point in the history
…not done
  • Loading branch information
Nicogene committed May 15, 2020
1 parent 0351f2b commit fb40900
Show file tree
Hide file tree
Showing 5 changed files with 145 additions and 68 deletions.
149 changes: 95 additions & 54 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@

cmake_minimum_required(VERSION 3.12)

project(iCub)

set(ROOT_PROJECT_NAME ICUB)
set(ICUB_INSTALL_INCLUDE_DIR ${CMAKE_INSTALL_PREFIX}/include/iCub)
project(${ROOT_PROJECT_NAME} LANGUAGES C CXX
VERSION 1.15.100)


set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD 14)
Expand Down Expand Up @@ -38,10 +43,12 @@ set_property(GLOBAL PROPERTY ICUB_DEPENDENCIES_FLAGS) # this is populated iCubFi
set(ICUB_MODULE_PATH ${PROJECT_SOURCE_DIR}/conf)
set(CMAKE_MODULE_PATH ${ICUB_MODULE_PATH} ${CMAKE_MODULE_PATH})

# get the current version of the iCub build
include(${PROJECT_SOURCE_DIR}/conf/iCubVersion.cmake)

# add functionalities like icub_add_library/icub_add_executable
#TODO we need it??
## get the current version of the iCub build
#include(${PROJECT_SOURCE_DIR}/conf/iCubVersion.cmake)
#
## add functionalities like icub_add_library/icub_add_executable
#todo remove it
include(${PROJECT_SOURCE_DIR}/conf/iCubHelpers.cmake)

# Import common options (disable flags in windows, rpath, etc..)
Expand All @@ -51,6 +58,35 @@ include(${PROJECT_SOURCE_DIR}/conf/iCubOptions.cmake)
# find dependencies and set variables
include(${PROJECT_SOURCE_DIR}/conf/iCubFindDependencies.cmake)

# To build shared libraries in Windows, we set CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS to TRUE.
# See https://cmake.org/cmake/help/v3.4/variable/CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS.html
# See https://blog.kitware.com/create-dlls-on-windows-without-declspec-using-new-cmake-export-all-feature/
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)

# Build position independent code.
# Position Independent Code (PIC) is commonly used for shared libraries so that
# the same shared library code can be loaded in each program address space in a
# location where it will not overlap with any other uses of such memory.
# In particular, this option avoids problems occurring when a process wants to
# load more than one shared library at the same virtual address.
# Since shared libraries cannot predict where other shared libraries could be
# loaded, this is an unavoidable problem with the traditional shared library
# concept.
# Generating position-independent code is often the default behavior for most
# modern compilers.
# Moreover linking a static library that is not built with PIC from a shared
# library will fail on some compiler/architecture combinations.
# Further details on PIC can be found here:
# https://eli.thegreenplace.net/2011/11/03/position-independent-code-pic-in-shared-libraries/
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
# Enable RPATH support for installed binaries and libraries
include(AddInstallRPATHSupport)
add_install_rpath_support(BIN_DIRS "${CMAKE_INSTALL_FULL_BINDIR}"
LIB_DIRS "${CMAKE_INSTALL_FULL_LIBDIR}"
INSTALL_NAME_DIR "${CMAKE_INSTALL_FULL_LIBDIR}"
USE_LINK_PATH)


### enable testing
option(ICUB_DASHBOARD_SUBMIT "Submit compile tests to cdash" FALSE)

Expand All @@ -59,27 +95,29 @@ if(ICUB_DASHBOARD_SUBMIT)
endif()

### this makes everything go in $ICUB_DIR/lib and $ICUB_DIR/bin
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib)
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
message(STATUS "Libraries go to ${LIBRARY_OUTPUT_PATH}")
message(STATUS "Executables go to ${EXECUTABLE_OUTPUT_PATH}")
# this doesn't happen automatically for makefiles
make_directory(${LIBRARY_OUTPUT_PATH})
make_directory(${EXECUTABLE_OUTPUT_PATH})
mark_as_advanced(LIBRARY_OUTPUT_PATH EXECUTABLE_OUTPUT_PATH)
mark_as_advanced(CMAKE_BACKWARDS_COMPATIBILITY)
#TODO do we need it?
#set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib)
#set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
#message(STATUS "Libraries go to ${LIBRARY_OUTPUT_PATH}")
#message(STATUS "Executables go to ${EXECUTABLE_OUTPUT_PATH}")
## this doesn't happen automatically for makefiles
#make_directory(${LIBRARY_OUTPUT_PATH})
#make_directory(${EXECUTABLE_OUTPUT_PATH})
#mark_as_advanced(LIBRARY_OUTPUT_PATH EXECUTABLE_OUTPUT_PATH)
#mark_as_advanced(CMAKE_BACKWARDS_COMPATIBILITY)

# clean up:
# icub-export-build.cmake, icub-export-build-includes.cmake and icub-export-inst-includes.cmake
# this is a required step because we will append data to these files during the build
file(WRITE ${CMAKE_BINARY_DIR}/icub-export-build.cmake "")
file(WRITE ${CMAKE_BINARY_DIR}/icub-export-build-includes.cmake "")
file(WRITE ${CMAKE_BINARY_DIR}/icub-export-inst-includes.cmake "")
#file(WRITE ${CMAKE_BINARY_DIR}/icub-export-build.cmake "")
#file(WRITE ${CMAKE_BINARY_DIR}/icub-export-build-includes.cmake "")
#file(WRITE ${CMAKE_BINARY_DIR}/icub-export-inst-includes.cmake "")

#TODO do we need it?
# Some options: mostly cache variables
file(TO_CMAKE_PATH "$ENV{ICUB_ROOT}" env_icub_root)
set(ICUB_APPLICATIONS_PREFIX ${env_icub_root} CACHE PATH "Prefix directory for installing applications. Read only, set ICUB_ROOT environment variable to affect this setting." FORCE)
mark_as_advanced(ICUB_APPLICATIONS_PREFIX)
#file(TO_CMAKE_PATH "$ENV{ICUB_ROOT}" env_icub_root)
#set(ICUB_APPLICATIONS_PREFIX ${env_icub_root} CACHE PATH "Prefix directory for installing applications. Read only, set ICUB_ROOT environment variable to affect this setting." FORCE)
#mark_as_advanced(ICUB_APPLICATIONS_PREFIX)

# Force dynamic plugins. Must be set before
# yarp_configure_external_installation to ensure that iCub.ini is
Expand All @@ -99,52 +137,55 @@ set(ICUB_ASK_REFERENCE_TO_FIRMWARE TRUE CACHE BOOL "Pos/Vel/Trq references will

########### populate applications
add_subdirectory(app)

# Create everything needed to build our executables.
add_subdirectory(src)


include(InstallBasicPackageFiles)
install_basic_package_files(${ROOT_PROJECT_NAME}
VERSION ${${ROOT_PROJECT_NAME}_VERSION}
COMPATIBILITY AnyNewerVersion
VARS_PREFIX ${ROOT_PROJECT_NAME}
NO_CHECK_REQUIRED_COMPONENTS_MACRO)

########### propagate version info to targets
get_property(ICUB_TARGETS GLOBAL PROPERTY ICUB_TARGETS)
foreach(t ${ICUB_TARGETS})
set_target_properties(${t} PROPERTIES VERSION ${ICUB_GENERIC_VERSION}
SOVERSION ${ICUB_GENERIC_SOVERSION})
endforeach()
#TODO we need it???
#get_property(ICUB_TARGETS GLOBAL PROPERTY ICUB_TARGETS)
#foreach(t ${ICUB_TARGETS})
# set_target_properties(${t} PROPERTIES VERSION ${ICUB_GENERIC_VERSION}
# SOVERSION ${ICUB_GENERIC_SOVERSION})
#endforeach()
######################

# export the build tree
message(STATUS "Now exporting build tree")
include(${PROJECT_SOURCE_DIR}/conf/iCubExportBuildTree.cmake)

# export the installed project
message(STATUS "Now exporting for install")
include(${PROJECT_SOURCE_DIR}/conf/iCubExportForInstall.cmake)

## install cmake scripts
message(STATUS "Installing cmake scripts")
set(ICUB_CMAKE_SCRIPTS iCubHelpers.cmake iCubOptions.cmake)

foreach(conf ${ICUB_CMAKE_SCRIPTS})
# in YARP we used to copy Find* scripts to the build directory
# this has changed in YARP but NOT in iCub.
configure_file(${CMAKE_SOURCE_DIR}/conf/${conf}
${CMAKE_BINARY_DIR}/conf/${conf} COPYONLY IMMEDIATE)

# on the other hand we do need to install Find* script at install time
install(FILES conf/${conf} DESTINATION share/iCub/cmake/ COMPONENT Development)

endforeach(conf)
#TODO probably remove
#message(STATUS "Now exporting build tree")
#include(${PROJECT_SOURCE_DIR}/conf/iCubExportBuildTree.cmake)
#
## export the installed project
#message(STATUS "Now exporting for install")
#include(${PROJECT_SOURCE_DIR}/conf/iCubExportForInstall.cmake)
#
### install cmake scripts
#message(STATUS "Installing cmake scripts")
#set(ICUB_CMAKE_SCRIPTS iCubHelpers.cmake iCubOptions.cmake)
#
#foreach(conf ${ICUB_CMAKE_SCRIPTS})
# # in YARP we used to copy Find* scripts to the build directory
# # this has changed in YARP but NOT in iCub.
# configure_file(${CMAKE_SOURCE_DIR}/conf/${conf}
# ${CMAKE_BINARY_DIR}/conf/${conf} COPYONLY IMMEDIATE)
#
# # on the other hand we do need to install Find* script at install time
# install(FILES conf/${conf} DESTINATION share/iCub/cmake/ COMPONENT Development)
#
#endforeach(conf)

## add the "uninstall" target
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/conf/template/icub-config-uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/icub-config-uninstall.cmake"
IMMEDIATE @ONLY)
include(AddUninstallTarget)

include(${PROJECT_SOURCE_DIR}/conf/iCubPackage.cmake)

add_custom_target(uninstall
"${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/icub-config-uninstall.cmake")

if(ICUB_COMPILE_BINDINGS)
add_subdirectory(bindings)
endif()
17 changes: 13 additions & 4 deletions src/libraries/actionPrimitives/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,18 @@ target_include_directories(${PROJECT_NAME} PUBLIC "$<BUILD_INTERFACE:${PROJECT_S

target_link_libraries(${PROJECT_NAME} perceptiveModels ${YARP_LIBRARIES})

icub_export_library(${PROJECT_NAME} INTERNAL_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/include
DEPENDS perceptiveModels
DESTINATION include/iCub/action
FILES ${folder_header})
#icub_export_library(${PROJECT_NAME} INTERNAL_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/include
# DEPENDS perceptiveModels
# DESTINATION include/iCub/action
# FILES ${folder_header})

set_target_properties(${PROJECT_NAME} PROPERTIES PUBLIC_HEADER "${folder_header}")

install(TARGETS ${PROJECT_NAME}
EXPORT ${ROOT_PROJECT_NAME}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${ICUB_INSTALL_INCLUDE_DIR}/action)


15 changes: 12 additions & 3 deletions src/libraries/ctrlLib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,16 @@ if(ICUB_USE_GSL)
target_link_libraries(${PROJECT_NAME} ${GSL_LIBRARIES})
endif()

icub_export_library(${PROJECT_NAME} INTERNAL_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/include
DESTINATION include/iCub/ctrl
FILES ${folder_header})
#icub_export_library(${PROJECT_NAME} INTERNAL_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/include
# DESTINATION include/iCub/ctrl
# FILES ${folder_header})

set_target_properties(${PROJECT_NAME} PROPERTIES PUBLIC_HEADER "${folder_header}")

install(TARGETS ${PROJECT_NAME}
EXPORT ${ROOT_PROJECT_NAME}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${ICUB_INSTALL_INCLUDE_DIR}/ctrl)

15 changes: 12 additions & 3 deletions src/libraries/learningMachine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,17 @@ if(YARP_gsl_FOUND)
target_link_libraries(${LM_LIB} PUBLIC YARP::YARP_os YARP::YARP_sig YARP::YARP_math
PRIVATE YARP::YARP_gsl ${GSL_LIBRARIES})

icub_export_library(${LM_LIB} INTERNAL_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/include
DESTINATION include/iCub/learningMachine
FILES ${LM_HEADER})
# icub_export_library(${LM_LIB} INTERNAL_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/include
# DESTINATION include/iCub/learningMachine
# FILES ${LM_HEADER})

set_target_properties(${PROJECT_NAME} PROPERTIES PUBLIC_HEADER "${LM_HEADER}")

install(TARGETS ${PROJECT_NAME}
EXPORT ${ROOT_PROJECT_NAME}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${ICUB_INSTALL_INCLUDE_DIR}/learningMachine)
endif()

17 changes: 13 additions & 4 deletions src/libraries/perceptiveModels/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,17 @@ target_link_libraries(${PROJECT_NAME} ctrlLib
learningMachine
${YARP_LIBRARIES})

icub_export_library(${PROJECT_NAME} INTERNAL_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/include
DEPENDS ctrlLib learningMachine
DESTINATION include/iCub/perception
FILES ${folder_header})
#icub_export_library(${PROJECT_NAME} INTERNAL_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/include
# DEPENDS ctrlLib learningMachine
# DESTINATION include/iCub/perception
# FILES ${folder_header})

set_target_properties(${PROJECT_NAME} PROPERTIES PUBLIC_HEADER "${folder_header}")

install(TARGETS ${PROJECT_NAME}
EXPORT ${ROOT_PROJECT_NAME}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${ICUB_INSTALL_INCLUDE_DIR}/perception)

0 comments on commit fb40900

Please sign in to comment.