-
Notifications
You must be signed in to change notification settings - Fork 692
Modernize CMake scripts #439
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
7d80acd
Modernize CMake scripts
roehling a32dcde
Update vendored copy of QGLViewer to version 2.9.1
roehling 1de7243
Try harder to pick matching Qt and QGLViewer libraries
roehling ba36dff
Add option to make octovis build optional
roehling 892944d
Fix increase_version.py to deal with new CMakeLists.txt files
roehling c3cb7a3
Add missing return()
roehling File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,21 +1,23 @@ | ||
| CMAKE_MINIMUM_REQUIRED(VERSION 3.10) | ||
| PROJECT( octomap-distribution ) | ||
| cmake_minimum_required(VERSION 3.10...4.1) | ||
| project( | ||
| octomap-distribution | ||
| VERSION 1.10.0 | ||
| LANGUAGES NONE | ||
| ) | ||
|
|
||
| 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) | ||
| include(CTest) | ||
|
|
||
| option(BUILD_SHARED_LIBS "Build shared libraries" ON) | ||
| option(BUILD_OCTOVIS_SUBPROJECT "Build targets from subproject octovis" ON) | ||
| option(BUILD_DYNAMICETD3D_SUBPROJECT "Build targets from subproject dynamicEDT3D" ON) | ||
| option(OCTOVIS_QT6 "Link Octovis against Qt6?" ON) | ||
|
|
||
| set(CMAKE_CXX_STANDARD 11) | ||
|
|
||
| ADD_SUBDIRECTORY( octomap ) | ||
| option(BUILD_DYNAMICETD3D_SUBPROJECT | ||
| "Build targets from subproject dynamicEDT3D" ON | ||
| ) | ||
|
|
||
| add_subdirectory(octomap) | ||
| if(BUILD_OCTOVIS_SUBPROJECT) | ||
| ADD_SUBDIRECTORY( octovis ) | ||
| set(OCTOVIS_BUILD_OPTIONAL TRUE) | ||
| add_subdirectory(octovis) | ||
| endif() | ||
|
|
||
| if(BUILD_DYNAMICETD3D_SUBPROJECT) | ||
| ADD_SUBDIRECTORY( dynamicEDT3D ) | ||
| add_subdirectory(dynamicEDT3D) | ||
| endif() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,177 +1,139 @@ | ||
| CMAKE_MINIMUM_REQUIRED(VERSION 3.10) | ||
| PROJECT(dynamicEDT3D) | ||
|
|
||
| include(CTest) | ||
| include(GNUInstallDirs) | ||
| cmake_minimum_required(VERSION 3.10...4.1) | ||
| project( | ||
| dynamicEDT3D | ||
| VERSION 1.10.0 | ||
ahornung marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| LANGUAGES CXX | ||
| ) | ||
|
|
||
| # version (e.g. for packaging) | ||
| set(DYNAMICEDT3D_MAJOR_VERSION 1) | ||
| set(DYNAMICEDT3D_MINOR_VERSION 10) | ||
| set(DYNAMICEDT3D_PATCH_VERSION 0) | ||
| set(DYNAMICEDT3D_VERSION ${DYNAMICEDT3D_MAJOR_VERSION}.${DYNAMICEDT3D_MINOR_VERSION}.${DYNAMICEDT3D_PATCH_VERSION}) | ||
| set(DYNAMICEDT3D_SOVERSION ${DYNAMICEDT3D_MAJOR_VERSION}.${DYNAMICEDT3D_MINOR_VERSION}) | ||
|
|
||
| if(COMMAND cmake_policy) | ||
| cmake_policy(SET CMP0003 NEW) | ||
| if(POLICY CMP0042) | ||
| # Enable MACOSX_RPATH by default. | ||
| cmake_policy(SET CMP0042 NEW) | ||
| endif(POLICY CMP0042) | ||
| endif(COMMAND cmake_policy) | ||
|
|
||
| SET (CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/CMakeModules") | ||
|
|
||
| # COMPILER SETTINGS (default: Release) and flags | ||
| INCLUDE(CompilerSettings) | ||
|
|
||
|
|
||
| # Set output directories for libraries and executables | ||
| SET( BASE_DIR ${CMAKE_SOURCE_DIR} ) | ||
| SET( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${BASE_DIR}/lib ) | ||
| SET( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${BASE_DIR}/lib ) | ||
| SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${BASE_DIR}/bin ) | ||
| # output dirs for multi-config builds (MSVC) | ||
| foreach( OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES} ) | ||
| STRING( TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG ) | ||
| SET( CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${BASE_DIR}/lib ) | ||
| SET( CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${BASE_DIR}/lib ) | ||
| SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${BASE_DIR}/bin ) | ||
| endforeach( OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES ) | ||
|
|
||
| set(INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/include") | ||
| INCLUDE_DIRECTORIES(${INCLUDE_DIRS}) | ||
|
|
||
| LINK_DIRECTORIES(${CMAKE_LIBRARY_OUTPUT_DIRECTORY}) | ||
| option(DYNAMICEDT3D_BUILD_EXAMPLES "Build examples" ON) | ||
|
|
||
| # Installation | ||
| include(CMakePackageConfigHelpers) | ||
| include(GNUInstallDirs) | ||
|
|
||
| set(INSTALL_TARGETS_DEFAULT_ARGS | ||
| RUNTIME DESTINATION bin | ||
| LIBRARY DESTINATION lib | ||
| ARCHIVE DESTINATION lib | ||
| ) | ||
| set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/CMakeModules") | ||
| include(CompilerSettings) | ||
| include(InstallPkgConfigFile) | ||
|
|
||
| find_package(octomap REQUIRED | ||
| HINTS ${CMAKE_SOURCE_DIR}/lib/cmake/octomap | ||
| ${CMAKE_SOURCE_DIR}/../octomap/lib/cmake/octomap | ||
| # version (e.g. for packaging) | ||
| set(DYNAMICEDT3D_MAJOR_VERSION ${PROJECT_VERSION_MAJOR}) | ||
| set(DYNAMICEDT3D_MINOR_VERSION ${PROJECT_VERSION_MINOR}) | ||
| set(DYNAMICEDT3D_PATCH_VERSION ${PROJECT_VERSION_PATCH}) | ||
| set(DYNAMICEDT3D_VERSION ${PROJECT_VERSION}) | ||
| set(DYNAMICEDT3D_SOVERSION | ||
| "${DYNAMICEDT3D_MAJOR_VERSION}.${DYNAMICEDT3D_MINOR_VERSION}" | ||
| ) | ||
| MESSAGE(STATUS "Found octomap version: " ${octomap_VERSION}) | ||
| MESSAGE(STATUS "octomap libraries: ${OCTOMAP_LIBRARIES}") | ||
|
|
||
| INCLUDE_DIRECTORIES(BEFORE SYSTEM ${OCTOMAP_INCLUDE_DIRS}) | ||
|
|
||
| ADD_SUBDIRECTORY(src) | ||
| if(NOT TARGET octomap::octomap) | ||
| find_package(octomap "${DYNAMICEDT3D_VERSION}" REQUIRED) | ||
| endif() | ||
|
|
||
| set(DYNAMICEDT3D_FIND_DEPENDENCIES | ||
| "include(CMakeFindDependencyMacro)\nfind_dependency(octomap ${DYNAMICEDT3D_VERSION})" | ||
| ) | ||
|
|
||
| file(GLOB dynamicEDT3D_HDRS ${PROJECT_SOURCE_DIR}/include/dynamicEDT3D/*.h ${PROJECT_SOURCE_DIR}/include/dynamicEDT3D/*.hxx) | ||
| install(FILES ${dynamicEDT3D_HDRS} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/dynamicEDT3D") | ||
| set(dynamicEDT3D_SOURCES src/dynamicEDT3D.cpp) | ||
|
|
||
| # Install catkin package.xml, attention package.xml names the catkin package "dynamic_edt_3d", so this is also the location where it needs to be installed to (and not "dynamicEDT3D") | ||
| install(FILES package.xml DESTINATION "${CMAKE_INSTALL_DATADIR}/dynamic_edt_3d") | ||
| add_library(dynamicEDT3D ${dynamicEDT3D_SOURCES}) | ||
| target_compile_features(dynamicEDT3D PUBLIC cxx_std_11) | ||
ahornung marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| target_include_directories( | ||
| dynamicEDT3D PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> | ||
| $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> | ||
| ) | ||
| set_target_properties( | ||
| dynamicEDT3D | ||
| PROPERTIES VERSION "${DYNAMICEDT3D_VERSION}" | ||
| SOVERSION "${DYNAMICEDT3D_SOVERSION}" | ||
| OUTPUT_NAME "dynamicedt3d" | ||
| ) | ||
| target_link_libraries(dynamicEDT3D PUBLIC octomap::octomap) | ||
| add_library(octomap::dynamicEDT3D ALIAS dynamicEDT3D) | ||
|
|
||
| # Allows Colcon to find non-Ament packages when using workspace underlays | ||
| file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/share/ament_index/resource_index/packages/${PROJECT_NAME} "") | ||
| install(FILES ${CMAKE_CURRENT_BINARY_DIR}/share/ament_index/resource_index/packages/${PROJECT_NAME} DESTINATION share/ament_index/resource_index/packages) | ||
| # Examples | ||
| if(DYNAMICEDT3D_BUILD_EXAMPLES) | ||
| add_executable(exampleEDT3D src/examples/exampleEDT3D.cpp) | ||
| target_link_libraries(exampleEDT3D PRIVATE dynamicEDT3D) | ||
|
|
||
| #TODO: this conflicts with the octomap uninstall | ||
| #it is not only a target name problem, also both will use the same manifest file | ||
| #in the same binary directory | ||
| if(NOT TARGET uninstall) | ||
| configure_file( | ||
| "${PROJECT_SOURCE_DIR}/CMakeModules/CMakeUninstall.cmake.in" | ||
| "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" | ||
| IMMEDIATE @ONLY) | ||
| add_executable(exampleEDTOctomap src/examples/exampleEDTOctomap.cpp) | ||
| target_link_libraries(exampleEDTOctomap PRIVATE dynamicEDT3D) | ||
|
|
||
| add_custom_target(uninstall | ||
| COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake) | ||
| add_executable( | ||
| exampleEDTOctomapStamped src/examples/exampleEDTOctomapStamped.cpp | ||
| ) | ||
| target_link_libraries(exampleEDTOctomapStamped PRIVATE dynamicEDT3D) | ||
| endif() | ||
|
|
||
| # Export the package for use from the build-tree | ||
| # (this registers the build-tree with a global CMake-registry) | ||
| # Export build tree | ||
| configure_package_config_file( | ||
| dynamicedt3d-config.cmake.in | ||
| "${CMAKE_CURRENT_BINARY_DIR}/dynamicedt3d-config.cmake" | ||
| INSTALL_DESTINATION "${CMAKE_CURRENT_BINARY_DIR}" | ||
| ) | ||
| write_basic_package_version_file( | ||
| "${CMAKE_CURRENT_BINARY_DIR}/dynamicedt3d-config-version.cmake" | ||
| VERSION ${DYNAMICEDT3D_VERSION} | ||
| COMPATIBILITY SameMinorVersion | ||
| ) | ||
| export( | ||
| TARGETS dynamicEDT3D | ||
| NAMESPACE octomap:: | ||
| FILE "${CMAKE_CURRENT_BINARY_DIR}/dynamicedt3d-targets.cmake" | ||
| ) | ||
| export(PACKAGE dynamicEDT3D) | ||
|
|
||
| # Create a dynamicEDT3DConfig.cmake file for the use from the build tree | ||
| set(DYNAMICEDT3D_INCLUDE_DIRS "${INCLUDE_DIRS}") | ||
| set(DYNAMICEDT3D_LIB_DIR "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}") | ||
| # Set library names as absolute paths | ||
| # Windows, spec. MSVC requires the .lib suffix for imported libs | ||
| IF(WIN32) | ||
| set(DYNAMICEDT3D_LIBRARY | ||
| "${CMAKE_IMPORT_LIBRARY_PREFIX}dynamicedt3d${CMAKE_IMPORT_LIBRARY_SUFFIX}" | ||
| ) | ||
| ELSE() | ||
| set(DYNAMICEDT3D_LIBRARY | ||
| "${CMAKE_SHARED_LIBRARY_PREFIX}dynamicedt3d${CMAKE_SHARED_LIBRARY_SUFFIX}" | ||
| ) | ||
| ENDIF() | ||
| # not used right now (export depends?) | ||
| #set(DYNEDT3D_CMAKE_DIR "${PROJECT_BINARY_DIR}") | ||
| include(CMakePackageConfigHelpers) | ||
| # Installation | ||
| install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) | ||
| install(TARGETS dynamicEDT3D EXPORT dynamicedt3d-targets) | ||
| install( | ||
| EXPORT dynamicedt3d-targets | ||
| NAMESPACE octomap:: | ||
| DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/dynamicEDT3D" | ||
| ) | ||
| set(DYNAMICEDT3D_INCLUDE_DIRS "${CMAKE_INSTALL_INCLUDEDIR}") | ||
| set(DYNAMICEDT3D_LIBRARY_DIRS "${CMAKE_INSTALL_LIBDIR}") | ||
| configure_package_config_file( | ||
| dynamicedt3d-config.cmake.in | ||
| "${CMAKE_CURRENT_BINARY_DIR}/InstallFiles/dynamicedt3d-config.cmake" | ||
| INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/dynamicEDT3D" | ||
| ) | ||
| write_basic_package_version_file( | ||
| "${CMAKE_CURRENT_BINARY_DIR}/InstallFiles/dynamicedt3d-config-version.cmake" | ||
| VERSION ${DYNAMICEDT3D_VERSION} | ||
| COMPATIBILITY SameMinorVersion | ||
| ) | ||
| install( | ||
| FILES | ||
| "${CMAKE_CURRENT_BINARY_DIR}/InstallFiles/dynamicedt3d-config.cmake" | ||
| "${CMAKE_CURRENT_BINARY_DIR}/InstallFiles/dynamicedt3d-config-version.cmake" | ||
| DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/dynamicEDT3D" | ||
| ) | ||
|
|
||
| CONFIGURE_PACKAGE_CONFIG_FILE( | ||
| dynamicEDT3DConfig.cmake.in | ||
| "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/cmake/dynamicEDT3D/dynamicEDT3DConfig.cmake" | ||
| PATH_VARS DYNAMICEDT3D_INCLUDE_DIRS DYNAMICEDT3D_LIB_DIR | ||
| INSTALL_DESTINATION "${CMAKE_INSTALL_FULL_DATADIR}/dynamicEDT3D") | ||
|
|
||
| WRITE_BASIC_PACKAGE_VERSION_FILE( | ||
| "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/cmake/dynamicEDT3D/dynamicEDT3DConfig-version.cmake" | ||
| VERSION ${DYNAMICEDT3D_VERSION} | ||
| COMPATIBILITY AnyNewerVersion) | ||
|
|
||
| # Install the export set for use with the install-tree | ||
| #install(EXPORT FooBarLibraryDepends DESTINATION | ||
| # "${INSTALL_DATA_DIR}/FooBar/CMake" | ||
| # COMPONENT dev) | ||
|
|
||
| # Create a dynamicEDT3DConfig.cmake file for the use from the install tree | ||
| # and install it | ||
| set(DYNAMICEDT3D_INCLUDE_DIRS "${CMAKE_INSTALL_FULL_INCLUDEDIR}") | ||
| set(DYNAMICEDT3D_LIB_DIR "${CMAKE_INSTALL_FULL_LIBDIR}") | ||
| #set(DYNAMICEDT3D_CMAKE_DIR "${INSTALL_DATA_DIR}/FooBar/CMake") | ||
|
|
||
| set(DYNAMICEDT3D_INCLUDE_TARGETS | ||
| "include(\${CMAKE_CURRENT_LIST_DIR}/dynamicEDT3DTargets.cmake)") | ||
|
|
||
| CONFIGURE_PACKAGE_CONFIG_FILE( | ||
| dynamicEDT3DConfig.cmake.in | ||
| "${PROJECT_BINARY_DIR}/InstallFiles/dynamicEDT3DConfig.cmake" | ||
| PATH_VARS DYNAMICEDT3D_INCLUDE_DIRS DYNAMICEDT3D_LIB_DIR | ||
| INSTALL_DESTINATION "${CMAKE_INSTALL_FULL_DATADIR}/dynamicEDT3D") | ||
|
|
||
| WRITE_BASIC_PACKAGE_VERSION_FILE( | ||
| "${PROJECT_BINARY_DIR}/InstallFiles/dynamicEDT3DConfig-version.cmake" | ||
| VERSION ${DYNAMICEDT3D_VERSION} | ||
| COMPATIBILITY AnyNewerVersion) | ||
|
|
||
| install(FILES | ||
| "${PROJECT_BINARY_DIR}/InstallFiles/dynamicEDT3DConfig.cmake" | ||
| "${PROJECT_BINARY_DIR}/InstallFiles/dynamicEDT3DConfig-version.cmake" | ||
| DESTINATION "${CMAKE_INSTALL_DATADIR}/dynamicEDT3D") | ||
|
|
||
| # Write pkgconfig-file: | ||
| # ROS support | ||
| install(FILES package.xml DESTINATION "${CMAKE_INSTALL_DATADIR}/dynamicEDT3D") | ||
|
|
||
| # pkg-config support | ||
| include(InstallPkgConfigFile) | ||
| install_pkg_config_file(dynamicEDT3D | ||
| install_pkg_config_file( | ||
| dynamicEDT3D | ||
| CFLAGS | ||
| LIBS -ldynamicEDT3D | ||
| LIBS | ||
| -ldynamicedt3d | ||
| REQUIRES | ||
| VERSION ${DYNAMICEDT3D_VERSION}) | ||
|
|
||
| octomap | ||
| VERSION | ||
| ${DYNAMICEDT3D_VERSION} | ||
| ) | ||
|
|
||
| # Documentation | ||
| FIND_PACKAGE(Doxygen) | ||
| IF(DOXYGEN_FOUND) | ||
| ADD_CUSTOM_TARGET(docs_dynamicEDT3D ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/dynamicEDT3D.dox | ||
| WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} | ||
| COMMENT "Generating documentation (Doxygen)...") | ||
| ENDIF(DOXYGEN_FOUND) | ||
| find_package(Doxygen QUIET) | ||
| if(DOXYGEN_FOUND) | ||
| add_custom_target( | ||
| docs_dynamicEDT3D | ||
| COMMAND ${DOXYGEN_EXECUTABLE} | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/dynamicEDT3D.dox | ||
| WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} | ||
| COMMENT "Generating documentation (Doxygen)" | ||
| ) | ||
| endif(DOXYGEN_FOUND) | ||
|
|
||
| # Needs to be last statement: | ||
| INCLUDE(CPackSettings) | ||
|
|
||
| # Finished: | ||
| MESSAGE (STATUS "\n") | ||
| MESSAGE (STATUS "Compile dynamicEDT3D using: make") | ||
| MESSAGE (STATUS "Install dynamicEDT3D using: make install") | ||
| MESSAGE (STATUS " (be sure to set the correct CMAKE_INSTALL_PREFIX before)") | ||
| MESSAGE (STATUS "Compile API-documentation using: make docs_dynamicEDT3D\n") | ||
| include(CPackSettings) | ||
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.