Skip to content

Commit

Permalink
Review CMake code, require CMake 2.8.9
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterBowman committed Nov 8, 2018
1 parent c28eac5 commit 8f0c76b
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 115 deletions.
83 changes: 4 additions & 79 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,96 +1,21 @@
# Copyright: Universidad Carlos III de Madrid (C) 2016;
# Copyright: Universidad Carlos III de Madrid (C) 2018;
# Authors: ASROB
# CopyPolicy: Released under the terms of the GNU GPL v2.0.

# Exploit new cmake 2.6 features (export).
cmake_minimum_required(VERSION 2.8.9 FATAL_ERROR)

# reduce warning level with cmake 2.6
cmake_minimum_required(VERSION 2.6)
#cmake policies
if(COMMAND cmake_policy)
cmake_policy(SET CMP0003 NEW)
endif(COMMAND cmake_policy)
project(ROBOT_DEVASTATION_ROBOTS NONE)

project(ROBOT_DEVASTATION_ROBOTS)

option(BUILD_SHARED_LIBS "All shared libs" TRUE)

### options: cpp libraries
#option(ENABLE_ExampleLibrary "Choose if you want to compile ExampleLibrary" TRUE)

### options: cpp programs
#option(ENABLE_exampleProgram "Choose if you want to compile exampleProgram" TRUE)

### options: force default
#option(ENABLE_exampleExtraOption "Enable/disable option exampleExtraOption" TRUE)

option(INSTALL_SERVICES "Choose if you want to install Robot Devastation services" TRUE)

if(MSVC)
MESSAGE(STATUS "Running on windows")
set(CMAKE_DEBUG_POSTFIX "d")
endif(MSVC)

if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING
"Choose the type of build, recommanded options are: Debug or Release")
endif(NOT CMAKE_BUILD_TYPE)
# Hide variable to MSVC users, since it is not needed
if (MSVC)
mark_as_advanced(CMAKE_BUILD_TYPE)
endif(MSVC)

######################

### this makes everything go in $ROBOT_DEVASTATION_ROBOTS_DIR/lib and $ROBOT_DEVASTATION_ROBOTS_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})
# and let us clean their contents on a "make clean"
##set_directory_properties(PROPERTIES LIBRARY_OUTPUT_PATH ADDITIONAL_MAKE_CLEAN_FILES)
##set_directory_properties(PROPERTIES EXECUTABLE_OUTPUT_PATH ADDITIONAL_MAKE_CLEAN_FILES)
mark_as_advanced(LIBRARY_OUTPUT_PATH EXECUTABLE_OUTPUT_PATH)
mark_as_advanced(CMAKE_BACKWARDS_COMPATIBILITY)
##########################################

# Pick up our cmake modules - they are all in the cmake subdirectory
set(ROBOT_DEVASTATION_ROBOTS_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
# let cmake use them
list(APPEND CMAKE_MODULE_PATH ${ROBOT_DEVASTATION_ROBOTS_MODULE_PATH})

set(ROBOT_DEVASTATION_ROBOTS_INCLUDE_DIRS CACHE INTERNAL "appended header dirs" FORCE)
set(ROBOT_DEVASTATION_ROBOTS_LINK_DIRS CACHE INTERNAL "appended link dirs" FORCE)
set(ROBOT_DEVASTATION_ROBOTS_LIBRARIES CACHE INTERNAL "appended libraries" FORCE)
option(INSTALL_SERVICES "Choose if you want to install Robot Devastation services" ON)

# add main contents
add_subdirectory(share)
#add_subdirectory(libraries)
#add_subdirectory(programs)
add_subdirectory(scripts)

# export our variables to a ROBOT_DEVASTATION_ROBOTSConfig.cmake creation
set(ROBOT_DEVASTATION_ROBOTS_LINK_DIRS ${ROBOT_DEVASTATION_ROBOTS_LINK_DIRS} ${LIBRARY_OUTPUT_PATH})
configure_file(${CMAKE_SOURCE_DIR}/cmake/template/ROBOT_DEVASTATION_ROBOTSConfig.cmake.in
${CMAKE_BINARY_DIR}/ROBOT_DEVASTATION_ROBOTSConfig.cmake @ONLY)

# create a symbolic link to the shared directory (as contains models and may be heavy)
# If you want a deep copy, you can use the copy_directory command instead of create_symlink.
#add_custom_target(install_applications COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_SOURCE_DIR}/share ${CMAKE_SOURCE_DIR}/../share)

#endif(MSVC)
##add_custom_target(nuke
## "${CMAKE_COMMAND}" -E "remove_directory" "${CMAKE_SOURCE_DIR}/bin" ";"
## "${CMAKE_COMMAND}" -E "remove_directory" "${CMAKE_SOURCE_DIR}/lib")

# uninstall target
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/template/ROBOT_DEVASTATION_ROBOTSConfigUninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/ROBOT_DEVASTATION_ROBOTSConfigUninstall.cmake" IMMEDIATE @ONLY)

add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/ROBOT_DEVASTATION_ROBOTSConfigUninstall.cmake)

14 changes: 0 additions & 14 deletions cmake/template/ROBOT_DEVASTATION_ROBOTSConfig.cmake.in

This file was deleted.

12 changes: 3 additions & 9 deletions scripts/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
# Copyright: UC3M 2016
# Copyright: UC3M 2018
# Author: ASROB
# CopyPolicy: Released under the terms of the GNU GPL v2.0.
#

#find_package(YARP REQUIRED)
#list(APPEND CMAKE_MODULE_PATH ${YARP_MODULE_PATH})
#include(YarpInstallationHelpers)
#yarp_configure_external_installation(robotDevastation-robots)

# Install services for autostart
IF(INSTALL_SERVICES)
if(INSTALL_SERVICES)
install(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/etc/service/launchCamera/run
DESTINATION /etc/service/launchCamera)
install(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/etc/service/launchRobot/run
DESTINATION /etc/service/launchRobot)
ENDIF()
endif()
4 changes: 1 addition & 3 deletions share/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Copyright: UC3M 2016
# Copyright: UC3M 2018
# Author: ASROB
# CopyPolicy: Released under the terms of the GNU GPL v2.0.
#

find_package(YARP REQUIRED)
list(APPEND CMAKE_MODULE_PATH ${YARP_MODULE_PATH})
Expand All @@ -11,4 +10,3 @@ yarp_configure_external_installation(robotDevastation-robots)
### Go through single applications

add_subdirectory(launch)

14 changes: 4 additions & 10 deletions share/launch/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
# Copyright: 2014 ASROB
# Copyright: 2018 ASROB
# Author: Juan G Victores
# CopyPolicy: Released under the terms of the GNU GPL v2.0.

set(appname launch)


file(GLOB conf ${CMAKE_CURRENT_SOURCE_DIR}/*.ini)
#file(GLOB scripts ${CMAKE_CURRENT_SOURCE_DIR}/scripts/*.template)

yarp_install(FILES ${conf} DESTINATION ${ROBOTDEVASTATION-ROBOTS_CONTEXTS_INSTALL_DIR}/${appname})
#yarp_install(FILES ${scripts} DESTINATION ${RD_APPLICATIONS_TEMPLATES_INSTALL_DIR})

yarp_install(FILES launchCamera.ini
launchRobot.ini
DESTINATION ${ROBOTDEVASTATION-ROBOTS_CONTEXTS_INSTALL_DIR}/launch)

0 comments on commit 8f0c76b

Please sign in to comment.