diff --git a/cmake/IgnConfigureBuild.cmake b/cmake/IgnConfigureBuild.cmake index 53eeb922..7f1a67cb 100644 --- a/cmake/IgnConfigureBuild.cmake +++ b/cmake/IgnConfigureBuild.cmake @@ -169,7 +169,7 @@ macro(ign_configure_build) set (CPPCHECK_INCLUDE_DIRS) set (potential_cppcheck_include_dirs ${CMAKE_BINARY_DIR} - ${CMAKE_SOURCE_DIR}/include/ignition/${IGN_DESIGNATION} + ${CMAKE_SOURCE_DIR}/include/${PROJECT_INCLUDE_DIR} ${CMAKE_SOURCE_DIR}/test/integration ${CMAKE_SOURCE_DIR}/test/regression ${CMAKE_SOURCE_DIR}/test/performance) @@ -323,8 +323,8 @@ function(_ign_find_include_script) add_subdirectory("${include_start}/include") elseif(EXISTS "${include_start}/include/ignition/CMakeLists.txt") add_subdirectory("${include_start}/include/ignition") - elseif(EXISTS "${include_start}/include/ignition/${IGN_DESIGNATION}/CMakeLists.txt") - add_subdirectory("${include_start}/include/ignition/${IGN_DESIGNATION}") + elseif(EXISTS "${include_start}/include/${PROJECT_INCLUDE_DIR}/CMakeLists.txt") + add_subdirectory("${include_start}/include/${PROJECT_INCLUDE_DIR}") else() message(AUTHOR_WARNING "You have an include directory [${include_start}/include] without a " diff --git a/cmake/IgnConfigureProject.cmake b/cmake/IgnConfigureProject.cmake index c0eb398a..f979bae1 100644 --- a/cmake/IgnConfigureProject.cmake +++ b/cmake/IgnConfigureProject.cmake @@ -7,7 +7,10 @@ # Sets up an ignition library project. # # NO_IGNITION_PREFIX: Optional. Don't use ignition as prefix in -# cmake project name. +# cmake project name. +# REPLACE_IGNITION_INCLUDE_PATH: Optional. Specify include folder +# names to replace the default value of +# ignition/${IGN_DESIGNATION} # VERSION_SUFFIX: Optional. Specify a prerelease version suffix. # #=============================================================================== @@ -32,7 +35,7 @@ macro(ign_configure_project) #------------------------------------ # Define the expected arguments set(options NO_IGNITION_PREFIX) - set(oneValueArgs VERSION_SUFFIX) + set(oneValueArgs REPLACE_IGNITION_INCLUDE_PATH VERSION_SUFFIX) set(multiValueArgs) # We are not using multiValueArgs yet #------------------------------------ @@ -82,6 +85,12 @@ macro(ign_configure_project) set(PROJECT_EXPORT_NAME ${PROJECT_NAME_LOWER}) set(PROJECT_LIBRARY_TARGET_NAME ${PROJECT_NAME_LOWER}) + if(ign_configure_project_REPLACE_IGNITION_INCLUDE_PATH) + set(PROJECT_INCLUDE_DIR ${ign_configure_project_REPLACE_IGNITION_INCLUDE_PATH}) + else() + set(PROJECT_INCLUDE_DIR ignition/${IGN_DESIGNATION}) + endif() + # version . set(PROJECT_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}) diff --git a/cmake/IgnUtils.cmake b/cmake/IgnUtils.cmake index 8dda557c..ad0ebfa5 100644 --- a/cmake/IgnUtils.cmake +++ b/cmake/IgnUtils.cmake @@ -682,13 +682,13 @@ function(ign_install_all_headers) # Add each header, prefixed by its directory, to the auto headers variable foreach(header ${headers}) - set(ign_headers "${ign_headers}#include \n") + set(ign_headers "${ign_headers}#include <${PROJECT_INCLUDE_DIR}/${header}>\n") endforeach() if("." STREQUAL ${dir}) - set(destination "${IGN_INCLUDE_INSTALL_DIR_FULL}/ignition/${IGN_DESIGNATION}") + set(destination "${IGN_INCLUDE_INSTALL_DIR_FULL}/${PROJECT_INCLUDE_DIR}") else() - set(destination "${IGN_INCLUDE_INSTALL_DIR_FULL}/ignition/${IGN_DESIGNATION}/${dir}") + set(destination "${IGN_INCLUDE_INSTALL_DIR_FULL}/${PROJECT_INCLUDE_DIR}/${dir}") endif() install( @@ -700,7 +700,7 @@ function(ign_install_all_headers) # Add generated headers to the list of includes foreach(header ${ign_install_all_headers_GENERATED_HEADERS}) - set(ign_headers "${ign_headers}#include \n") + set(ign_headers "${ign_headers}#include <${PROJECT_INCLUDE_DIR}/${header}>\n") endforeach() if(ign_install_all_headers_COMPONENT) @@ -708,7 +708,7 @@ function(ign_install_all_headers) set(component_name ${ign_install_all_headers_COMPONENT}) # Define the install directory for the component meta header - set(meta_header_install_dir ${IGN_INCLUDE_INSTALL_DIR_FULL}/ignition/${IGN_DESIGNATION}/${component_name}) + set(meta_header_install_dir ${IGN_INCLUDE_INSTALL_DIR_FULL}/${PROJECT_INCLUDE_DIR}/${component_name}) # Define the input/output of the configuration for the component "master" header set(master_header_in ${IGNITION_CMAKE_DIR}/ign_auto_headers.hh.in) @@ -717,7 +717,7 @@ function(ign_install_all_headers) else() # Define the install directory for the core master meta header - set(meta_header_install_dir ${IGN_INCLUDE_INSTALL_DIR_FULL}/ignition/${IGN_DESIGNATION}) + set(meta_header_install_dir ${IGN_INCLUDE_INSTALL_DIR_FULL}/${PROJECT_INCLUDE_DIR}) # Define the input/output of the configuration for the core "master" header set(master_header_in ${IGNITION_CMAKE_DIR}/ign_auto_headers.hh.in) @@ -936,7 +936,7 @@ function(ign_create_core_library) # Create the target for the core library, and configure it to be installed _ign_add_library_or_component( LIB_NAME ${PROJECT_LIBRARY_TARGET_NAME} - INCLUDE_DIR "ignition/${IGN_DESIGNATION_LOWER}" + INCLUDE_DIR "${PROJECT_INCLUDE_DIR}" EXPORT_BASE IGNITION_${IGN_DESIGNATION_UPPER} SOURCES ${sources} ${interface_option}) @@ -1120,7 +1120,7 @@ function(ign_add_component component_name) # Create the target for this component, and configure it to be installed _ign_add_library_or_component( LIB_NAME ${component_target_name} - INCLUDE_DIR "ignition/${IGN_DESIGNATION_LOWER}/${include_subdir}" + INCLUDE_DIR "${PROJECT_INCLUDE_DIR}/${include_subdir}" EXPORT_BASE IGNITION_${IGN_DESIGNATION_UPPER}_${component_name_upper} SOURCES ${sources} ${interface_option}) diff --git a/cmake/ign_auto_headers.hh.in b/cmake/ign_auto_headers.hh.in index 42fc9642..a078c63b 100644 --- a/cmake/ign_auto_headers.hh.in +++ b/cmake/ign_auto_headers.hh.in @@ -19,5 +19,5 @@ // This file is automatically generated by CMake. Changes should instead be // made to cmake/ign_auto_headers.hh.in in ignition-cmake -#include +#include <@PROJECT_INCLUDE_DIR@/config.hh> ${ign_headers} diff --git a/cmake/pkgconfig/ignition-component.pc.in b/cmake/pkgconfig/ignition-component.pc.in index b542f394..3b2a3710 100644 --- a/cmake/pkgconfig/ignition-component.pc.in +++ b/cmake/pkgconfig/ignition-component.pc.in @@ -1,6 +1,6 @@ prefix=${pcfiledir}/@PC_CONFIG_RELATIVE_PATH_TO_PREFIX@ libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@ -includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@/ignition/@IGN_DESIGNATION@@PROJECT_VERSION_MAJOR@ +includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@/@IGN_INCLUDE_INSTALL_DIR_POSTFIX@ Name: Ignition @IGN_DESIGNATION@ @component_name@ Description: A set of @IGN_DESIGNATION@ @component_name@ classes for robot applications diff --git a/cmake/pkgconfig/ignition.pc.in b/cmake/pkgconfig/ignition.pc.in index d1cace02..2342f716 100644 --- a/cmake/pkgconfig/ignition.pc.in +++ b/cmake/pkgconfig/ignition.pc.in @@ -1,6 +1,6 @@ prefix=${pcfiledir}/@PC_CONFIG_RELATIVE_PATH_TO_PREFIX@ libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@ -includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@/ignition/@IGN_DESIGNATION@@PROJECT_VERSION_MAJOR@ +includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@/@IGN_INCLUDE_INSTALL_DIR_POSTFIX@ Name: Ignition @IGN_DESIGNATION@ Description: A set of @IGN_DESIGNATION@ classes for robot applications diff --git a/config/ignition-cmake.pc.in b/config/ignition-cmake.pc.in index ff8a8973..3bbbe444 100644 --- a/config/ignition-cmake.pc.in +++ b/config/ignition-cmake.pc.in @@ -1,5 +1,5 @@ prefix=${pcfiledir}/@IGN_PC_CONFIG_RELATIVE_PATH_TO_PREFIX@ -includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@/ignition/@IGN_DESIGNATION@@PROJECT_VERSION_MAJOR@ +includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@/@IGN_INCLUDE_INSTALL_DIR_POSTFIX@ Name: Ignition @IGN_DESIGNATION@ Description: Build system package for the ignition libraries diff --git a/examples/no_ignition_prefix/CMakeLists.txt b/examples/no_ignition_prefix/CMakeLists.txt index 1bd6d003..429eda91 100644 --- a/examples/no_ignition_prefix/CMakeLists.txt +++ b/examples/no_ignition_prefix/CMakeLists.txt @@ -1,7 +1,9 @@ cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR) project(no_ignition_prefix VERSION 0.1.0) find_package(ignition-cmake2 REQUIRED) -ign_configure_project(NO_IGNITION_PREFIX) +ign_configure_project( + NO_IGNITION_PREFIX + REPLACE_IGNITION_INCLUDE_PATH no_ign) ign_configure_build(QUIT_IF_BUILD_ERRORS) ign_create_packages() ign_create_docs() diff --git a/examples/no_ignition_prefix/README.md b/examples/no_ignition_prefix/README.md index 513de7e7..85c07d37 100644 --- a/examples/no_ignition_prefix/README.md +++ b/examples/no_ignition_prefix/README.md @@ -1,18 +1,34 @@ -# no\_ignition\_prefix +# no\_ignition\_prefix example -This package uses the `NO_IGNITION_PREFIX` option to `ign_configure_project` +## Configuring project name + +This package uses the `NO_IGNITION_PREFIX` option in `ign_configure_project` to allow a cmake package name without the `ignition-` prefix. -To confirm, build this package and then observe that the tarball, +To confirm, configure this package and +`package_source` and then observe that the tarball, pkg-config `.pc` file, and cmake config files omit the `ignition-` prefix: ~~~ mkdir build cd build cmake .. -make make package_source ~~~ * `no_ignition_prefix-0.1.0.tar.bz2` * `cmake/no_ignition_prefix-config.cmake` * `cmake/pkgconfig/no_ignition_prefix.pc` + +## Configuring include directory names + +This package uses the `REPLACE_IGNITION_INCLUDE_PATH` option in `ign_configure_project` +to allow a custom include path of `no_ign`, which doesn't start with `ignition/`. +To confirm, build the package and observe that `AlmostEmpty.cc` +compiles successfully while including `no_ign/Export.hh`: + +~~~ +mkdir build +cd build +cmake .. +make +~~~ diff --git a/examples/no_ignition_prefix/include/CMakeLists.txt b/examples/no_ignition_prefix/include/CMakeLists.txt index e69de29b..118eec0f 100644 --- a/examples/no_ignition_prefix/include/CMakeLists.txt +++ b/examples/no_ignition_prefix/include/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(no_ign) diff --git a/examples/no_ignition_prefix/include/no_ign/CMakeLists.txt b/examples/no_ignition_prefix/include/no_ign/CMakeLists.txt new file mode 100644 index 00000000..439642e6 --- /dev/null +++ b/examples/no_ignition_prefix/include/no_ign/CMakeLists.txt @@ -0,0 +1 @@ +ign_install_all_headers() diff --git a/examples/no_ignition_prefix/include/no_ign/config.hh.in b/examples/no_ignition_prefix/include/no_ign/config.hh.in new file mode 100644 index 00000000..e69de29b diff --git a/examples/no_ignition_prefix/src/AlmostEmpty.cc b/examples/no_ignition_prefix/src/AlmostEmpty.cc index c769ef47..d3029192 100644 --- a/examples/no_ignition_prefix/src/AlmostEmpty.cc +++ b/examples/no_ignition_prefix/src/AlmostEmpty.cc @@ -15,14 +15,13 @@ * */ -#include +#include +#include +#include -namespace ignition +namespace no_ignition_prefix { - namespace no_ignition_prefix + class IGNITION_NO_IGNITION_PREFIX_VISIBLE AlmostEmpty { - class IGNITION_NO_IGNITION_PREFIX_VISIBLE AlmostEmpty - { - }; - } + }; }