diff --git a/CMakeLists.txt b/CMakeLists.txt index 24a1c92..aa6751a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,102 +1,104 @@ project( liboncilla C CXX ) cmake_minimum_required(VERSION 2.8 ) find_package(Boost) if("${CMAKE_CXX_COMPILER}" MATCHES ".*clang.*") if( "${Boost_VERSION}" VERSION_LESS "104801") message(FATAL_ERROR "There is some incompatibility with boost <= 1.48.0 (here ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}) and C++11 features. Since your compiler (Clang) fully support C++11, you should use a more recent version of Boost to compile this library. C++11 is needed by NemoMath dependency.") endif( "${Boost_VERSION}" VERSION_LESS "104801") endif("${CMAKE_CXX_COMPILER}" MATCHES ".*clang.*") find_package(BiorobCMakeUtils 0.3.4 REQUIRED) include_all_biorob_cmake_utils() # Only project root installation model +option(LIBONCILLA_SYSTEM_INSTALL "Enable system install " OFF) +if(NOT LIBONCILLA_SYSTEM_INSTALL) + set(LIBONCILLA_WEBOTS_PROJECT_ROOT "" CACHE string "Root of the webots project to compile for") + set(LIBONCILLA_ENABLED_CONTROLLERS "" CACHE string "List of enabled controllers") -set(LIBONCILLA_WEBOTS_PROJECT_ROOT "" CACHE string "Root of the webots project to compile for") -set(LIBONCILLA_ENABLED_CONTROLLERS "" CACHE string "List of enabled controllers") + if(NOT LIBONCILLA_WEBOTS_PROJECT_ROOT) + message(FATAL_ERROR "This project is now meant to be installed on a per-webots project basis, please set LIBONCILLA_WEBOTS_PROJECT_ROOT") + endif(NOT LIBONCILLA_WEBOTS_PROJECT_ROOT) -if(NOT LIBONCILLA_WEBOTS_PROJECT_ROOT) - message(FATAL_ERROR "This project is now meant to be installed on a per-webots project basis, please set LIBONCILLA_WEBOTS_PROJECT_ROOT") -endif(NOT LIBONCILLA_WEBOTS_PROJECT_ROOT) - -set(CMAKE_INSTALL_PREFIX ${LIBONCILLA_WEBOTS_PROJECT_ROOT}/dependencies) + set(CMAKE_INSTALL_PREFIX ${LIBONCILLA_WEBOTS_PROJECT_ROOT}/dependencies) +endif(NOT LIBONCILLA_SYSTEM_INSTALL) # --- user options --- option(BUILD_TESTS "Decide whether unit-tests are built" ON) option(BUILD_EXAMPLES "Decide whether the examples are built" ON) option(BUILD_DOCS "Decide whether the docygen documentation is built" OFF) find_package(RCI 0.4 REQUIRED) add_definitions(${RCI_DEFINITIONS}) find_package(PkgConfig REQUIRED) set(BIOROB_CPP_DEP biorob-cpp-0.4) pkg_check_modules(BIOROB_CPP ${BIOROB_CPP_DEP}>=0.4.2 REQUIRED) # --- global definitions --- make_std_versionning(MAJOR 0 MINOR 3 PATCH 0~rc20) # Includes include_directories(${PROJECT_BINARY_DIR}/src ${PROJECT_SOURCE_DIR}/src ${BIOROB_CPP_INCLUDE_DIRS} ${RCI_INCLUDE_DIRS}) # Link directories link_directories(${BIOROB_CPP_LIBRARY_DIRS}) set(INCLUDE_DIR include/liboncilla-${VERSION_API}) add_subdirectory(src) # --- cmake config file --- configure_file(liboncillaConfig.cmake.in LibOncillaConfig.cmake @ONLY) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/LibOncillaConfig.cmake DESTINATION share/liboncilla) export(TARGETS oncilla FILE "${CMAKE_BINARY_DIR}/LibOncillaDepends.cmake") install(EXPORT LibOncillaDepends DESTINATION "share/liboncilla") find_package(GMock) if(BUILD_TESTS AND GMOCK_FOUND) enable_testing() message(STATUS "Building tests - deactivate by adapting BUILD_TESTS") add_subdirectory(test) elseif(BUILD_TESTS AND NOT GMOCK_FOUND) message(WARNING "Could not build unit tests even though desired because Google Mock could not be installed.") endif(BUILD_TESTS AND GMOCK_FOUND) if(BUILD_EXAMPLES) add_subdirectory(examples) endif(BUILD_EXAMPLES) # --- pkgconfig file --- set(PKG_CONFIG_FILE liboncilla-${VERSION_MAJOR}.pc ) configure_file(liboncilla.pc.in ${PKG_CONFIG_FILE} @ONLY) install(FILES ${CMAKE_BINARY_DIR}/${PKG_CONFIG_FILE} DESTINATION lib/pkgconfig) # --- documentation generation --- if(BUILD_DOCS) add_subdirectory(doc) endif(BUILD_DOCS) # --- coverage --- #if(BUILD_TESTS) # enable_coverage_report(TARGETS liboncilla TESTS ${DTO_TEST_NAME} ${INTEGRATED_TEST_NAME} FILTER "*3rdparty*" "*test/*") #endif(BUILD_TESTS) # --- sloccount --- #enable_sloccount(FOLDERS src test examples) # --- cppcheck --- #generate_cppcheck(SOURCES src test examples # "${CMAKE_CURRENT_BINARY_DIR}/src" "${CMAKE_CURRENT_BINARY_DIR}/test" "${CMAKE_CURRENT_BINARY_DIR}/examples" # ENABLE_IDS style) diff --git a/src/liboncilla/CMakeLists.txt b/src/liboncilla/CMakeLists.txt index d9dbf60..db24000 100644 --- a/src/liboncilla/CMakeLists.txt +++ b/src/liboncilla/CMakeLists.txt @@ -1,62 +1,64 @@ set(ONCILLAHEADERS nodes/Trunk.h nodes/L0.h nodes/L1L2.h nodes/L3.h nodes/Nodes.h nodes/SupervisorL4.h nodes/SupervisorTrunk.h nodes/SupervisorWorld.h nodes/SupervisorNodes.h Oncilla.h Synchronizer.h Supervisor.h utils/BackendLoader.h utils/OncillaBackend.h common.h exceptions/LoadingError.h exceptions/NotImplementedError.h exceptions/UnavailableInterfaceError.h) set(ONCILLASOURCES nodes/Trunk.cpp nodes/L0.cpp nodes/L1L2.cpp nodes/L3.cpp nodes/SupervisorTrunk.cpp nodes/SupervisorL4.cpp nodes/SupervisorWorld.cpp Oncilla.cpp Synchronizer.cpp Supervisor.cpp utils/OncillaBackend.cpp exceptions/LoadingError.cpp exceptions/NotImplementedError.cpp exceptions/UnavailableInterfaceError.cpp utils/BackendLoader.cpp) add_library(oncilla SHARED ${ONCILLASOURCES} ${ONCILLAHEADERS}) target_link_libraries(oncilla ${RCI_LIBRARIES} ${BIOROB_CPP_LIBRARIES}) set_target_properties(oncilla PROPERTIES VERSION ${VERSION_STRING} SOVERSION ${VERSION_ABI} LINK_FLAGS "-Wl,-unresolved-symbols=ignore-in-shared-libs") install(TARGETS oncilla EXPORT LibOncillaDepends DESTINATION lib) install(DIRECTORY ${PROJECT_SOURCE_DIR}/src/liboncilla ${PROJECT_BINARY_DIR}/src/liboncilla DESTINATION ${INCLUDE_DIR} FILES_MATCHING PATTERN "*.h" PATTERN "CMakeFiles" EXCLUDE ) -foreach(controller ${LIBONCILLA_ENABLED_CONTROLLERS}) - set(controller_dir ${LIBONCILLA_WEBOTS_PROJECT_ROOT}/controllers/${controller}) - install(TARGETS oncilla DESTINATION ${controller_dir}) -endforeach(controller ${LIBONCILLA_ENABLED_CONTROLLERS}) +if(NOT LIBONCILLA_SYSTEM_INSTALL) + foreach(controller ${LIBONCILLA_ENABLED_CONTROLLERS}) + set(controller_dir ${LIBONCILLA_WEBOTS_PROJECT_ROOT}/controllers/${controller}) + install(TARGETS oncilla DESTINATION ${controller_dir}) + endforeach(controller ${LIBONCILLA_ENABLED_CONTROLLERS}) +endif(NOT LIBONCILLA_SYSTEM_INSTALL)