diff --git a/CMakeLists.txt b/CMakeLists.txt index ff020404..2e47216c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,12 +1,12 @@ CMAKE_MINIMUM_REQUIRED(VERSION 3.0.2) PROJECT( octomap-distribution ) -ENABLE_TESTING() # enable CTest environment of subprojects set(CMAKE_POSITION_INDEPENDENT_CODE ON) # enables -fPIC in applicable compilers (required to avoid link errors in some cases) option(BUILD_OCTOVIS_SUBPROJECT "Build targets from subproject octovis" ON) option(BUILD_DYNAMICETD3D_SUBPROJECT "Build targets from subproject dynamicEDT3D" ON) option(OCTOVIS_QT5 "Link Octovis against Qt5?" ON) +option(BUILD_EXAMPLE "Build example" OFF) if(OCTOVIS_QT5) # Compiling against QT5 requires C++11. diff --git a/dynamicEDT3D/src/CMakeLists.txt b/dynamicEDT3D/src/CMakeLists.txt index 0b9357c7..ef1b1251 100644 --- a/dynamicEDT3D/src/CMakeLists.txt +++ b/dynamicEDT3D/src/CMakeLists.txt @@ -2,35 +2,31 @@ SET( dynamicEDT3D_SRCS dynamicEDT3D.cpp ) -add_library(dynamicedt3d SHARED ${dynamicEDT3D_SRCS}) +add_library(dynamicedt3d ${dynamicEDT3D_SRCS}) set_target_properties(dynamicedt3d PROPERTIES VERSION ${DYNAMICEDT3D_VERSION} SOVERSION ${DYNAMICEDT3D_SOVERSION} ) target_link_libraries(dynamicedt3d ${OCTOMAP_LIBRARIES}) -add_library(dynamicedt3d-static STATIC ${dynamicEDT3D_SRCS}) -target_link_libraries(dynamicedt3d-static ${OCTOMAP_LIBRARIES}) - -SET_TARGET_PROPERTIES(dynamicedt3d-static PROPERTIES OUTPUT_NAME "dynamicedt3d") - if(NOT EXISTS "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/cmake/dynamicEDT3D") file(MAKE_DIRECTORY "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/cmake/dynamicEDT3D") endif() -export(TARGETS dynamicedt3d dynamicedt3d-static +export(TARGETS dynamicedt3d FILE "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/cmake/dynamicEDT3D/dynamicEDT3DTargets.cmake") # directly depend on the octomap library target when building the # complete distribution, so it it recompiled as needed if (CMAKE_PROJECT_NAME STREQUAL "octomap-distribution") - ADD_DEPENDENCIES(dynamicedt3d-static octomap-static) ADD_DEPENDENCIES(dynamicedt3d octomap) endif() -ADD_SUBDIRECTORY(examples) +if (BUILD_EXAMPLE) + ADD_SUBDIRECTORY(examples) +endif() -install(TARGETS dynamicedt3d dynamicedt3d-static +install(TARGETS dynamicedt3d EXPORT dynamicEDT3DTargets INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" ${INSTALL_TARGETS_DEFAULT_ARGS} diff --git a/octomap/src/CMakeLists.txt b/octomap/src/CMakeLists.txt index 45b384f7..88a6f126 100644 --- a/octomap/src/CMakeLists.txt +++ b/octomap/src/CMakeLists.txt @@ -11,14 +11,11 @@ SET (octomap_SRCS ) # dynamic and static libs, see CMake FAQ: -ADD_LIBRARY( octomap SHARED ${octomap_SRCS}) +ADD_LIBRARY( octomap ${octomap_SRCS}) set_target_properties( octomap PROPERTIES VERSION ${OCTOMAP_VERSION} SOVERSION ${OCTOMAP_SOVERSION} ) -ADD_LIBRARY( octomap-static STATIC ${octomap_SRCS}) -SET_TARGET_PROPERTIES(octomap-static PROPERTIES OUTPUT_NAME "octomap") -add_dependencies(octomap-static octomath-static) TARGET_LINK_LIBRARIES(octomap octomath) @@ -26,10 +23,12 @@ if(NOT EXISTS "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/cmake/octomap") file(MAKE_DIRECTORY "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/cmake/octomap") endif() -export(TARGETS octomap octomap-static +export(TARGETS octomap APPEND FILE "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/cmake/octomap/octomap-targets.cmake") -ADD_SUBDIRECTORY( testing ) +if (ENABLE_TESTING) + ADD_SUBDIRECTORY( testing ) +endif() ADD_EXECUTABLE(graph2tree graph2tree.cpp) TARGET_LINK_LIBRARIES(graph2tree octomap) @@ -67,7 +66,7 @@ TARGET_LINK_LIBRARIES(intersection_example octomap) ADD_EXECUTABLE(octree2pointcloud octree2pointcloud.cpp) TARGET_LINK_LIBRARIES(octree2pointcloud octomap) -install(TARGETS octomap octomap-static +install(TARGETS octomap EXPORT octomap-targets INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" ${INSTALL_TARGETS_DEFAULT_ARGS} diff --git a/octomap/src/math/CMakeLists.txt b/octomap/src/math/CMakeLists.txt index 3b47ec44..9a26c460 100644 --- a/octomap/src/math/CMakeLists.txt +++ b/octomap/src/math/CMakeLists.txt @@ -5,24 +5,21 @@ SET (octomath_SRCS ) -ADD_LIBRARY( octomath SHARED ${octomath_SRCS}) +ADD_LIBRARY( octomath ${octomath_SRCS}) SET_TARGET_PROPERTIES( octomath PROPERTIES VERSION ${OCTOMAP_VERSION} SOVERSION ${OCTOMAP_SOVERSION} ) -ADD_LIBRARY( octomath-static STATIC ${octomath_SRCS}) -SET_TARGET_PROPERTIES(octomath-static PROPERTIES OUTPUT_NAME "octomath") - if(NOT EXISTS "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/cmake/octomap") file(MAKE_DIRECTORY "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/cmake/octomap") endif() -export(TARGETS octomath octomath-static +export(TARGETS octomath APPEND FILE "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/cmake/octomap/octomap-targets.cmake") -install(TARGETS octomath octomath-static +install(TARGETS octomath EXPORT octomap-targets INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" ${INSTALL_TARGETS_DEFAULT_ARGS}