CMake Frontend¶
CMakeLists.txt¶
The following is an example CMakeLists.txt for a generic cmake project that utilises the ecl as a standalone set of libraries on a typical *nix system. We use a cmake module to interface with the installed ecl and pkg-config works behind the scenes to provide all the paths to it.
cmake_minimum_required(VERSION 2.4.6)
# Verbosity is useful - helps eclipse find paths also!
set(CMAKE_VERBOSE_MAKEFILE true)
find_package(PkgConfig)
pkg_check_modules(ECL_CMAKE ecl_cmake) # Stores the path to the ecl cmake dir in ECL_CMAKE_PREFIX
set(CMAKE_MODULE_PATH ${ECL_CMAKE_PREFIX}/modules) # Location of the ecl cmake modules
# Include the macro libraries you wish to use. These don't actually do anything, just provide
# cmake macro api's.
include(ecl_build_utilities)
include(ecl_platform_detection)
include(ecl_ros_utilities)
# Find package modules, particular the ecl - this gives us ECL_LIBRARIES
find_package(ECL REQUIRED config devices errors formatters geometry ipc) #...list libraries here
# Call the macros - there are others, see the documentation or cmake files themselves
ecl_detect_platform() # a general purpose platform sniffer
ecl_add_uninstall_target()
ecl_set_platform_cflags() # use with ecl platform modules to set cflags for your cpu
# Do some actual project stuff here, add exes, build libraries etc.
target_link_libraries(target_name ${ECL_LIBRARIES})
# Summaries
ecl_summary_platform()