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

Project option: REPLACE_IGNITION_INCLUDE_PATH #190

Merged
merged 7 commits into from
Nov 12, 2021
Merged
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
6 changes: 3 additions & 3 deletions cmake/IgnConfigureBuild.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 "
Expand Down
13 changes: 11 additions & 2 deletions cmake/IgnConfigureProject.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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.
#
#===============================================================================
Expand All @@ -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

#------------------------------------
Expand Down Expand Up @@ -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 <major>.<minor>
set(PROJECT_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR})

Expand Down
16 changes: 8 additions & 8 deletions cmake/IgnUtils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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 <ignition/${IGN_DESIGNATION}/${header}>\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(
Expand All @@ -700,15 +700,15 @@ 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 <ignition/${IGN_DESIGNATION}/${header}>\n")
set(ign_headers "${ign_headers}#include <${PROJECT_INCLUDE_DIR}/${header}>\n")
endforeach()

if(ign_install_all_headers_COMPONENT)

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)
Expand All @@ -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)
Expand Down Expand Up @@ -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}
adlarkin marked this conversation as resolved.
Show resolved Hide resolved
SOURCES ${sources}
${interface_option})
Expand Down Expand Up @@ -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}
adlarkin marked this conversation as resolved.
Show resolved Hide resolved
SOURCES ${sources}
${interface_option})
Expand Down
2 changes: 1 addition & 1 deletion cmake/ign_auto_headers.hh.in
Original file line number Diff line number Diff line change
Expand Up @@ -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 <ignition/@IGN_DESIGNATION@/config.hh>
#include <@PROJECT_INCLUDE_DIR@/config.hh>
${ign_headers}
2 changes: 1 addition & 1 deletion cmake/pkgconfig/ignition-component.pc.in
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion cmake/pkgconfig/ignition.pc.in
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion config/ignition-cmake.pc.in
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 3 additions & 1 deletion examples/no_ignition_prefix/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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()
24 changes: 20 additions & 4 deletions examples/no_ignition_prefix/README.md
Original file line number Diff line number Diff line change
@@ -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
~~~
1 change: 1 addition & 0 deletions examples/no_ignition_prefix/include/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
add_subdirectory(no_ign)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ign_install_all_headers()
Empty file.
13 changes: 6 additions & 7 deletions examples/no_ignition_prefix/src/AlmostEmpty.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@
*
*/

#include <ignition/no_ignition_prefix/Export.hh>
#include <no_ignition_prefix.hh>
#include <no_ign/config.hh>
#include <no_ign/Export.hh>

namespace ignition
namespace no_ignition_prefix
{
namespace no_ignition_prefix
class IGNITION_NO_IGNITION_PREFIX_VISIBLE AlmostEmpty
{
class IGNITION_NO_IGNITION_PREFIX_VISIBLE AlmostEmpty
{
};
}
};
}