Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve cmake for package manager #419

Open
wants to merge 1 commit into
base: devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
16 changes: 6 additions & 10 deletions dynamicEDT3D/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
13 changes: 6 additions & 7 deletions octomap/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,24 @@ 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)

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)
Expand Down Expand Up @@ -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}
Expand Down
9 changes: 3 additions & 6 deletions octomap/src/math/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
Loading