Skip to content

Commit

Permalink
CMake 3.0 is now required
Browse files Browse the repository at this point in the history
Start using a few features and remove all workarounds no longer needed.
  • Loading branch information
drdanz committed Dec 24, 2016
1 parent ca426eb commit 3afdc4d
Show file tree
Hide file tree
Showing 119 changed files with 202 additions and 333 deletions.
1 change: 1 addition & 0 deletions .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,4 @@ YARP Developers <[email protected]> <[email protected]>
YARP Developers <[email protected]> <[email protected]>
YARP Developers <[email protected]> <[email protected]>
YARP Developers <[email protected]> <[email protected]>
YARP Developers <[email protected]> <[email protected]>
30 changes: 10 additions & 20 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,7 @@
# Authors: Paul Fitzpatrick, Giorgio Metta, Lorenzo Natale
# CopyPolicy: Released under the terms of the LGPLv2.1 or later, see LGPL.TXT

cmake_minimum_required(VERSION 2.8.9)

# CMake Policy CMP0020 (Automatically link Qt executables to qtmain
# target on Windows). Can be removed with
# CMAKE_MINIMUM_REQUIRED_VERSION 2.8.11 or later.
if(NOT ${CMAKE_MINIMUM_REQUIRED_VERSION} VERSION_LESS 2.8.11)
message(AUTHOR_WARNING "CMake Policy CMP0020 is now NEW by default. You can remove this.")
endif()
if(NOT ${CMAKE_VERSION} VERSION_LESS 2.8.11)
cmake_policy(SET CMP0020 NEW)
endif()

project(YARP)
cmake_minimum_required(VERSION 3.0)

# Pick up our CMake scripts - they are all in the cmake subdirectory.
set(YARP_MODULE_DIR "${CMAKE_SOURCE_DIR}/cmake")
Expand All @@ -33,6 +21,15 @@ endif()

list(APPEND CMAKE_MODULE_PATH ${YARP_MODULE_PATH})

# Get the current YARP version.
# See cmake/YarpVersion.cmake.
include(YarpVersion)

# Main project
project(YARP
VERSION ${YARP_VERSION_SHORT}
LANGUAGES C CXX)

# The YARP build is fairly flexible, so we need to accumulate some
# information about what libraries are being built (and their dependencies),
# along with the include path. We'll be passing that along to clients
Expand All @@ -41,9 +38,6 @@ set_property(GLOBAL PROPERTY YARP_TREE_INCLUDE_DIRS)
set_property(GLOBAL PROPERTY YARP_LIBS)
set_property(GLOBAL PROPERTY YARP_DEFS)

# Get the current YARP version.
# See cmake/YarpVersion.cmake.
include(YarpVersion)

# Check system configuration.
# See cmake/YarpSystemCheck.cmake.
Expand All @@ -53,10 +47,6 @@ include(YarpSystemCheck)
# See cmake/YarpOptions.cmake.
include(YarpOptions)

# Include some workarounds for older cmake versions
# See cmake/YarpCMakeWorkarounds.cmake
include(YarpCMakeWorkarounds)

# Check YARP dependencies, find necessary libraries.
# See cmake/YarpFindDependencies.cmake.
include(YarpFindDependencies)
Expand Down
2 changes: 1 addition & 1 deletion bindings/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Authors: Paul Fitzpatrick, Arjan Gijsberts, Lorenzo Natale, Fabien Benureau, Stephane Lallee, Ali Paikan
# CopyPolicy: Released under the terms of the LGPLv2.1 or later, see LGPL.TXT

cmake_minimum_required(VERSION 2.8.9)
cmake_minimum_required(VERSION 3.0)

include(CMakeDependentOption)
include(CheckCXXCompilerFlag)
Expand Down
4 changes: 2 additions & 2 deletions cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ install(FILES ${YARP_TEMPLATE_FILES}

if(NOT YARP_NO_DEPRECATED) # since YARP 2.3.68
set(YARP_PRIVATE_CMAKE_FILES YarpDeprecatedOption.cmake
YarpCMakeWorkarounds.cmake
YarpRenamedOption.cmake
YarpBackupVariable.cmake)
install(FILES ${YARP_PRIVATE_CMAKE_FILES}
Expand Down Expand Up @@ -170,7 +169,8 @@ foreach(_f FindACE.cmake # since YARP 2
cmake-3.5/Modules/FindPackageMessage.cmake
cmake-3.5/Modules/SelectLibraryConfigurations.cmake
ycm-0.2/cmake-next/Modules/FindGLEW.cmake
ycm-0.2/find-modules/FindGSL.cmake) # since YARP 2.3.70
ycm-0.2/find-modules/FindGSL.cmake # since YARP 2.3.70
deprecated/YarpCMakeWorkarounds.cmake)
if(EXISTS "${CMAKE_INSTALL_PREFIX}/share/yarp/cmake/${_f}")
install(CODE
"if(EXISTS \"${CMAKE_INSTALL_PREFIX}/share/yarp/cmake/${_f}\")
Expand Down
46 changes: 0 additions & 46 deletions cmake/YarpCMakeWorkarounds.cmake

This file was deleted.

15 changes: 4 additions & 11 deletions cmake/YarpDescribe.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -154,16 +154,9 @@ install(EXPORT YARP
FILE YARPTargets.cmake)

foreach(lib ${YARP_LIBS})
set_target_properties(${lib} PROPERTIES VERSION ${YARP_VERSION_SHORT}
SOVERSION ${YARP_GENERIC_SOVERSION})

# Compile libraries using -fPIC to produce position independent code
# For CMAKE_VERSION >= 2.8.10 this is handled in YarpOptions.cmake
# using the CMAKE_POSITION_INDEPENDENT_CODE flag
if(${CMAKE_MINIMUM_REQUIRED_VERSION} VERSION_GREATER 2.8.9)
message(AUTHOR_WARNING "CMAKE_MINIMUM_REQUIRED_VERSION is now ${CMAKE_MINIMUM_REQUIRED_VERSION}. This check can be removed.")
endif()
if(CMAKE_VERSION VERSION_EQUAL "2.8.9")
set_target_properties(${lib} PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
get_target_property(type ${lib} TYPE)
if("${type}" STREQUAL "SHARED_LIBRARY")
set_target_properties(${lib} PROPERTIES VERSION ${YARP_VERSION_SHORT}
SOVERSION ${YARP_GENERIC_SOVERSION})
endif()
endforeach(lib)
2 changes: 0 additions & 2 deletions cmake/YarpPackage.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
# Packing stuff
#

include(YarpVersion)

set(CPACK_PACKAGE_NAME "YARP")
set(CPACK_PACKAGE_VENDOR "iCub Facility, Istituto Italiano di Tecnologia (IIT)")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "YARP: A thin middleware for humanoid robots and more")
Expand Down
2 changes: 1 addition & 1 deletion cmake/YarpPlugin.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ macro(YARP_END_PLUGIN_LIBRARY bundle_name)

if(NOT YARP_FORCE_DYNAMIC_PLUGINS AND NOT BUILD_SHARED_LIBS)
set_property(TARGET ${X_YARP_PLUGIN_MASTER} APPEND PROPERTY COMPILE_DEFINITIONS YARP_STATIC_PLUGIN)
target_link_libraries(${X_YARP_PLUGIN_MASTER} LINK_PRIVATE ${libs})
target_link_libraries(${X_YARP_PLUGIN_MASTER} PRIVATE ${libs})
endif()
# give user access to a list of all the plugin libraries
set(${X_YARP_PLUGIN_MASTER}_LIBRARIES ${libs})
Expand Down
3 changes: 0 additions & 3 deletions cmake/YarpSystemCheck.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,6 @@ if(WIN32)
endif()
else()

if(NOT CMAKE_MINIMUM_REQUIRED_VERSION VERSION_LESS 3.0)
message(AUTHOR_WARNING "CMAKE_MINIMUM_REQUIRED_VERSION is now ${CMAKE_MINIMUM_REQUIRED_VERSION}. The check in this macro can be removed.")
endif()
macro(YARP_CHECK_AND_APPEND_CXX_COMPILER_FLAG _out _flag)
string(TOUPPER "${_flag}" _VAR)
string(REGEX REPLACE " .+" "" _VAR "${_VAR}")
Expand Down
47 changes: 0 additions & 47 deletions cmake/YarpUseQt5.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,6 @@
include(GNUInstallDirs)


macro(qtyarp_deprecate_with_cmake_version _version)
if(NOT ${CMAKE_MINIMUM_REQUIRED_VERSION} VERSION_LESS ${_version})
message(AUTHOR_WARNING "CMAKE_MINIMUM_REQUIRED_VERSION = ${CMAKE_MINIMUM_REQUIRED_VERSION}. You can remove this.")
endif()
endmacro()


macro(qtyarp_qml_plugin _target _path)
set_property(TARGET ${_target} APPEND PROPERTY COMPILE_DEFINITIONS QT_PLUGIN)

Expand Down Expand Up @@ -63,46 +56,6 @@ macro(qtyarp_use_qml_plugin)
endmacro()


# Hide qt5_use_modules function (that generates several warnings), when
# it can be replaced by target_link_libraries (CMake 2.8.11 or later)
# NOTE: when CMake minimum required version is 2.8.11 or later,
# these calls should be replaced with target_link_libraries.
# Also take care of adding the required -fPIC compile flags to all
# target using Qt5.
# NOTE: when CMake minimum required version is 2.8.12 or later, this
# will no longer be required.
qtyarp_deprecate_with_cmake_version(2.8.12)
macro(qtyarp_use_modules _target)
if(NOT ${CMAKE_VERSION} VERSION_LESS 2.8.11)
foreach(_qt5lib ${ARGN})
target_link_libraries(${_target} Qt5::${_qt5lib})
endforeach()
else()
qt5_use_modules(${_target} ${ARGN})
endif()

# Append executable compile flags (usually -fPIC) when required
if(${CMAKE_VERSION} VERSION_LESS 2.8.12)
get_property(_type TARGET ${_target} PROPERTY TYPE)
if("${_type}" STREQUAL "EXECUTABLE")
foreach(_qt5lib ${ARGN})
if(NOT "${CMAKE_CXX_FLAGS}" MATCHES "${Qt5${_qt5lib}_EXECUTABLE_COMPILE_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5${_qt5lib}_EXECUTABLE_COMPILE_FLAGS}")
endif()
endforeach()

# If -fPIC is enabled, disable POSITION_INDEPENDENT_CODE,
# otherwise -fPIE will be appended on executables and -fPIC will
# not be used
if("${CMAKE_CXX_FLAGS}" MATCHES "-fPIC")
set_property(TARGET ${_target} PROPERTY POSITION_INDEPENDENT_CODE FALSE)
endif()
endif()
endif()

endmacro()


# Instruct CMake to issue deprecation warnings for macros and functions.
set(CMAKE_WARN_DEPRECATED TRUE)

Expand Down
2 changes: 1 addition & 1 deletion doc/add_a_plugin.dox
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ int main(int argc, char *argv[]) {
Here's a CMakeLists.txt ("userlib/CMakeLists.txt") to compile this:

\verbatim
cmake_minimum_required(VERSION 2.8.9)
cmake_minimum_required(VERSION 3.0)
find_package(YARP REQUIRED)
include_directories(${YARP_INCLUDE_DIRS})
add_executable(test_userlib test_userlib.cpp)
Expand Down
2 changes: 1 addition & 1 deletion doc/resource_finder_installation.dox
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ We'll see now how to setup installation rules so that after compilation the conf
The minimal CMake file that allows to build our tutorial modules is this (this CMake file actually builds the two Resource Finder tutorials):

\verbatim
cmake_minimum_required(VERSION 2.8.9)
cmake_minimum_required(VERSION 3.0)
project(resourceFinder)

find_package(YARP REQUIRED)
Expand Down
2 changes: 1 addition & 1 deletion doc/rostypes_tutorial_continued.dox
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ here. Do the following:
+ Create a file called <tt>yarpros_tutorial/src/CMakeLists.txt</tt> and place the following in it:

\code
cmake_minimum_required(VERSION 2.8.9)
cmake_minimum_required(VERSION 3.0)
project(yarp)
find_package(catkin REQUIRED COMPONENTS roscpp rospy std_msgs message_generation)
add_message_files(FILES SharedData.msg)
Expand Down
4 changes: 2 additions & 2 deletions doc/rostypes_tutorial_portable.dox
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ As usual we start with the CMake code, write your CMakeLists.txt:

\code

cmake_minimum_required(VERSION 2.8.9)
cmake_minimum_required(VERSION 3.0)

find_package(YARP REQUIRED)

Expand Down Expand Up @@ -222,7 +222,7 @@ Edit the file CMakeLists.txt:

\code

cmake_minimum_required(VERSION 2.8.9)
cmake_minimum_required(VERSION 3.0)

#find YARP
find_package(YARP REQUIRED)
Expand Down
2 changes: 1 addition & 1 deletion doc/thrift_tutorial_portable.dox
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ As usual we start with the CMake code, write your CMakeLists.txt:

\code

cmake_minimum_required(VERSION 2.8.9)
cmake_minimum_required(VERSION 3.0)

find_package(YARP REQUIRED)

Expand Down
2 changes: 1 addition & 1 deletion doc/thrift_tutorial_simple.dox
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Using CMake, generation of code for our demo.thrift file can be performed automa

\code
#CMakeList.txt
cmake_minimum_required(VERSION 2.8.9)
cmake_minimum_required(VERSION 3.0)

#find YARP
find_package(YARP REQUIRED)
Expand Down
10 changes: 5 additions & 5 deletions doc/using_cmake.dox
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Then save the following as "CMakeLists.txt" within the
same directory:

\verbatim
cmake_minimum_required(VERSION 2.8.9)
cmake_minimum_required(VERSION 3.0)
project(MyProject)
add_executable(hello main.cpp)
\endverbatim
Expand Down Expand Up @@ -224,7 +224,7 @@ Now we update the "CMakeLists.txt" to tell it about the library
and to make sure the header file can be found by both the library
and by "main.cpp":
\verbatim
cmake_minimum_required(VERSION 2.8.9)
cmake_minimum_required(VERSION 3.0)
project(MyProject)
include_directories("${CMAKE_SOURCE_DIR}/namer")
add_library(namer namer/world.cpp namer/world.h)
Expand Down Expand Up @@ -263,7 +263,7 @@ two separate projects.

Add the following CMake file for the library in "namer/CMakeLists.txt":
\verbatim
cmake_minimum_required(VERSION 2.8.9)
cmake_minimum_required(VERSION 3.0)
project(Namer)
include_directories("${CMAKE_SOURCE_DIR}")
add_library(namer world.cpp world.h)
Expand All @@ -275,7 +275,7 @@ Make a subdirectory "hello" and move "main.cpp" into it. Then add
"hello/CMakeLists.txt":

\verbatim
cmake_minimum_required(VERSION 2.8.9)
cmake_minimum_required(VERSION 3.0)
project(hello)
find_package(Namer REQUIRED)
include_directories("${Namer_INCLUDE_DIRS}")
Expand Down Expand Up @@ -333,7 +333,7 @@ then a directory specified by an environment variable.

Now modify "hello/CMakeLists.txt" so that it can find this script:
\verbatim
cmake_minimum_required(VERSION 2.8.9)
cmake_minimum_required(VERSION 3.0)
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}")
find_package(Namer REQUIRED)
include_directories("${Namer_INCLUDE_DIRS}")
Expand Down
2 changes: 1 addition & 1 deletion doc/yarp_code_examples.dox
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Make sure you set the YARP_DIR environment variable to point to
where you compiled YARP (or give the path through the CMake GUI).

\verbatim
cmake_minimum_required(VERSION 2.8.9)
cmake_minimum_required(VERSION 3.0)
find_package(YARP REQUIRED)
include_directories(${YARP_INCLUDE_DIRS})
add_executable(simple_sender simple_sender.cpp)
Expand Down
2 changes: 1 addition & 1 deletion doc/yarp_with_ros_services.dox
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Please see "example/ros" in the YARP source code for full examples. For simple
An example CMakeLists.txt file to compile this and link with YARP would be:

\verbatim
cmake_minimum_required(VERSION 2.8.9)
cmake_minimum_required(VERSION 3.0)
find_package(YARP REQUIRED)
include_directories(${YARP_INCLUDE_DIRS})
add_executable(add_int_client_v1 add_int_client_v1.cpp)
Expand Down
4 changes: 2 additions & 2 deletions doc/yarp_with_ros_writing_code_topics.dox
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
an example CMakeLists.txt file to compile this code would be:

\code
cmake_minimum_required(VERSION 2.8.9)
cmake_minimum_required(VERSION 3.0)
find_package(YARP REQUIRED)
include_directories(${YARP_INCLUDE_DIRS})
add_executable(listener listener.cpp)
Expand Down Expand Up @@ -73,7 +73,7 @@ an example CMakeLists.txt file to compile this code would be:
an example CMakeLists.txt file to compile this code would be:

\code
cmake_minimum_required(VERSION 2.8.9)
cmake_minimum_required(VERSION 3.0)
find_package(YARP REQUIRED)
include_directories(${YARP_INCLUDE_DIRS})
add_executable(talker talker.cpp)
Expand Down
Loading

0 comments on commit 3afdc4d

Please sign in to comment.