Skip to content

Commit 787cebd

Browse files
committed
IgnConfigureProject: add INCLUDE_DIR option
The include paths are now configurable and default to ignition/${IGN_DESIGNATION} to match existing behavior. Signed-off-by: Steve Peters <scpeters@openrobotics.org>
1 parent f0974b7 commit 787cebd

File tree

5 files changed

+28
-21
lines changed

5 files changed

+28
-21
lines changed

cmake/IgnConfigureBuild.cmake

+3-3
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ macro(ign_configure_build)
169169
set (CPPCHECK_INCLUDE_DIRS)
170170
set (potential_cppcheck_include_dirs
171171
${CMAKE_BINARY_DIR}
172-
${CMAKE_SOURCE_DIR}/include/ignition/${IGN_DESIGNATION}
172+
${CMAKE_SOURCE_DIR}/include/${PROJECT_INCLUDE_DIR}
173173
${CMAKE_SOURCE_DIR}/test/integration
174174
${CMAKE_SOURCE_DIR}/test/regression
175175
${CMAKE_SOURCE_DIR}/test/performance)
@@ -323,8 +323,8 @@ function(_ign_find_include_script)
323323
add_subdirectory("${include_start}/include")
324324
elseif(EXISTS "${include_start}/include/ignition/CMakeLists.txt")
325325
add_subdirectory("${include_start}/include/ignition")
326-
elseif(EXISTS "${include_start}/include/ignition/${IGN_DESIGNATION}/CMakeLists.txt")
327-
add_subdirectory("${include_start}/include/ignition/${IGN_DESIGNATION}")
326+
elseif(EXISTS "${include_start}/include/${PROJECT_INCLUDE_DIR}/CMakeLists.txt")
327+
add_subdirectory("${include_start}/include/${PROJECT_INCLUDE_DIR}")
328328
else()
329329
message(AUTHOR_WARNING
330330
"You have an include directory [${include_start}/include] without a "

cmake/IgnConfigureProject.cmake

+10-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66
#
77
# Sets up an ignition library project.
88
#
9+
# INCLUDE_DIR: Optional. Specify include folder names. Defaults to
10+
# ignition/${IGN_DESIGNATION}
911
# NO_IGNITION_PREFIX: Optional. Don't use ignition as prefix in
10-
# cmake project name.
12+
# cmake project name.
1113
# VERSION_SUFFIX: Optional. Specify a prerelease version suffix.
1214
#
1315
#===============================================================================
@@ -32,7 +34,7 @@ macro(ign_configure_project)
3234
#------------------------------------
3335
# Define the expected arguments
3436
set(options NO_IGNITION_PREFIX)
35-
set(oneValueArgs VERSION_SUFFIX)
37+
set(oneValueArgs INCLUDE_DIR VERSION_SUFFIX)
3638
set(multiValueArgs) # We are not using multiValueArgs yet
3739

3840
#------------------------------------
@@ -82,6 +84,12 @@ macro(ign_configure_project)
8284
set(PROJECT_EXPORT_NAME ${PROJECT_NAME_LOWER})
8385
set(PROJECT_LIBRARY_TARGET_NAME ${PROJECT_NAME_LOWER})
8486

87+
if(ign_configure_project_INCLUDE_DIR)
88+
set(PROJECT_INCLUDE_DIR ${ign_configure_project_INCLUDE_DIR})
89+
else()
90+
set(PROJECT_INCLUDE_DIR ignition/${IGN_DESIGNATION})
91+
endif()
92+
8593
# version <major>.<minor>
8694
set(PROJECT_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR})
8795

cmake/IgnUtils.cmake

+8-8
Original file line numberDiff line numberDiff line change
@@ -682,13 +682,13 @@ function(ign_install_all_headers)
682682

683683
# Add each header, prefixed by its directory, to the auto headers variable
684684
foreach(header ${headers})
685-
set(ign_headers "${ign_headers}#include <ignition/${IGN_DESIGNATION}/${header}>\n")
685+
set(ign_headers "${ign_headers}#include <${PROJECT_INCLUDE_DIR}/${header}>\n")
686686
endforeach()
687687

688688
if("." STREQUAL ${dir})
689-
set(destination "${IGN_INCLUDE_INSTALL_DIR_FULL}/ignition/${IGN_DESIGNATION}")
689+
set(destination "${IGN_INCLUDE_INSTALL_DIR_FULL}/${PROJECT_INCLUDE_DIR}")
690690
else()
691-
set(destination "${IGN_INCLUDE_INSTALL_DIR_FULL}/ignition/${IGN_DESIGNATION}/${dir}")
691+
set(destination "${IGN_INCLUDE_INSTALL_DIR_FULL}/${PROJECT_INCLUDE_DIR}/${dir}")
692692
endif()
693693

694694
install(
@@ -700,15 +700,15 @@ function(ign_install_all_headers)
700700

701701
# Add generated headers to the list of includes
702702
foreach(header ${ign_install_all_headers_GENERATED_HEADERS})
703-
set(ign_headers "${ign_headers}#include <ignition/${IGN_DESIGNATION}/${header}>\n")
703+
set(ign_headers "${ign_headers}#include <${PROJECT_INCLUDE_DIR}/${header}>\n")
704704
endforeach()
705705

706706
if(ign_install_all_headers_COMPONENT)
707707

708708
set(component_name ${ign_install_all_headers_COMPONENT})
709709

710710
# Define the install directory for the component meta header
711-
set(meta_header_install_dir ${IGN_INCLUDE_INSTALL_DIR_FULL}/ignition/${IGN_DESIGNATION}/${component_name})
711+
set(meta_header_install_dir ${IGN_INCLUDE_INSTALL_DIR_FULL}/${PROJECT_INCLUDE_DIR}/${component_name})
712712

713713
# Define the input/output of the configuration for the component "master" header
714714
set(master_header_in ${IGNITION_CMAKE_DIR}/ign_auto_headers.hh.in)
@@ -717,7 +717,7 @@ function(ign_install_all_headers)
717717
else()
718718

719719
# Define the install directory for the core master meta header
720-
set(meta_header_install_dir ${IGN_INCLUDE_INSTALL_DIR_FULL}/ignition/${IGN_DESIGNATION})
720+
set(meta_header_install_dir ${IGN_INCLUDE_INSTALL_DIR_FULL}/${PROJECT_INCLUDE_DIR})
721721

722722
# Define the input/output of the configuration for the core "master" header
723723
set(master_header_in ${IGNITION_CMAKE_DIR}/ign_auto_headers.hh.in)
@@ -936,7 +936,7 @@ function(ign_create_core_library)
936936
# Create the target for the core library, and configure it to be installed
937937
_ign_add_library_or_component(
938938
LIB_NAME ${PROJECT_LIBRARY_TARGET_NAME}
939-
INCLUDE_DIR "ignition/${IGN_DESIGNATION_LOWER}"
939+
INCLUDE_DIR "${PROJECT_INCLUDE_DIR}"
940940
EXPORT_BASE IGNITION_${IGN_DESIGNATION_UPPER}
941941
SOURCES ${sources}
942942
${interface_option})
@@ -1120,7 +1120,7 @@ function(ign_add_component component_name)
11201120
# Create the target for this component, and configure it to be installed
11211121
_ign_add_library_or_component(
11221122
LIB_NAME ${component_target_name}
1123-
INCLUDE_DIR "ignition/${IGN_DESIGNATION_LOWER}/${include_subdir}"
1123+
INCLUDE_DIR "${PROJECT_INCLUDE_DIR}/${include_subdir}"
11241124
EXPORT_BASE IGNITION_${IGN_DESIGNATION_UPPER}_${component_name_upper}
11251125
SOURCES ${sources}
11261126
${interface_option})
+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR)
22
project(no_ignition_prefix VERSION 0.1.0)
33
find_package(ignition-cmake2 REQUIRED)
4-
ign_configure_project(NO_IGNITION_PREFIX)
4+
ign_configure_project(
5+
INCLUDE_DIR no_ign
6+
NO_IGNITION_PREFIX)
57
ign_configure_build(QUIT_IF_BUILD_ERRORS)
68
ign_create_packages()
79
ign_create_docs()

examples/no_ignition_prefix/src/AlmostEmpty.cc

+4-7
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,11 @@
1515
*
1616
*/
1717

18-
#include <ignition/no_ignition_prefix/Export.hh>
18+
#include <no_ign/Export.hh>
1919

20-
namespace ignition
20+
namespace no_ignition_prefix
2121
{
22-
namespace no_ignition_prefix
22+
class IGNITION_NO_IGNITION_PREFIX_VISIBLE AlmostEmpty
2323
{
24-
class IGNITION_NO_IGNITION_PREFIX_VISIBLE AlmostEmpty
25-
{
26-
};
27-
}
24+
};
2825
}

0 commit comments

Comments
 (0)