Skip to content

Commit ce24063

Browse files
committed
iox-eclipse-iceoryx#1287 Add cmake linter CI target and handle MAKE_UNIQUE_INCLUDEDIR
Signed-off-by: Christian Eltzschig <me@elchris.org>
1 parent 116726e commit ce24063

File tree

5 files changed

+31
-30
lines changed

5 files changed

+31
-30
lines changed

.github/workflows/build-test.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ jobs:
2323
- uses: actions/checkout@v3
2424
- run: ./tools/ci/markdown-link-verificator.sh
2525

26+
cmake-lint-check:
27+
runs-on: ubuntu-20.04
28+
steps:
29+
- uses: actions/checkout@v3
30+
- run: ./tools/ci/cmake-linter.sh
31+
2632
build-test-ubuntu:
2733
runs-on: ubuntu-20.04
2834
needs: pre-flight-check

iceoryx_binding_c/CMakeLists.txt

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,7 @@ if(CMAKE_SYSTEM_NAME MATCHES Linux OR CMAKE_SYSTEM_NAME MATCHES Darwin)
3131
option(BUILD_SHARED_LIBS "Create shared libraries by default" ON)
3232
endif()
3333

34-
option(MAKE_UNIQUE_INCLUDEDIR
35-
"When ON headers are installed to a path ending with folders called \
36-
iceoryx/vX.Y.Z/ . This avoids include directory search order issues when \
37-
overriding this package from a merged catkin, ament, or colcon workspace."
38-
ON)
39-
40-
if(MAKE_UNIQUE_INCLUDEDIR)
41-
set(_unique_dir "iceoryx/v${IOX_VERSION_STRING}")
42-
if(PREFIX STREQUAL "")
43-
set(PREFIX "${_unique_dir}")
44-
else()
45-
set(PREFIX "${PREFIX}/${_unique_dir}")
46-
endif()
47-
endif()
34+
iox_make_unique_includedir()
4835

4936
#
5037
########## build building-block library ##########

iceoryx_hoofs/CMakeLists.txt

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,7 @@ if(CMAKE_SYSTEM_NAME MATCHES Linux OR CMAKE_SYSTEM_NAME MATCHES Darwin)
2828
option(BUILD_SHARED_LIBS "Create shared libraries by default" ON)
2929
endif()
3030

31-
option(MAKE_UNIQUE_INCLUDEDIR
32-
"When ON headers are installed to a path ending with folders called \
33-
iceoryx/vX.Y.Z/ . This avoids include directory search order issues when \
34-
overriding this package from a merged catkin, ament, or colcon workspace."
35-
ON)
36-
37-
if(MAKE_UNIQUE_INCLUDEDIR)
38-
set(_unique_dir "iceoryx/v${IOX_VERSION_STRING}")
39-
if(PREFIX STREQUAL "")
40-
set(PREFIX "${_unique_dir}")
41-
else()
42-
set(PREFIX "${PREFIX}/${_unique_dir}")
43-
endif()
44-
endif()
45-
31+
iox_make_unique_includedir()
4632
add_subdirectory(platform)
4733

4834
#

iceoryx_hoofs/cmake/IceoryxPackageHelper.cmake

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,23 @@ Macro(install_package_files_and_export)
112112
)
113113
endMacro()
114114

115+
Macro(iox_make_unique_includedir)
116+
option(MAKE_UNIQUE_INCLUDEDIR
117+
"When ON headers are installed to a path ending with folders called \
118+
iceoryx/vX.Y.Z/ . This avoids include directory search order issues when \
119+
overriding this package from a merged catkin, ament, or colcon workspace."
120+
ON)
121+
122+
if(MAKE_UNIQUE_INCLUDEDIR)
123+
set(_unique_dir "iceoryx/v${IOX_VERSION_STRING}")
124+
if(PREFIX STREQUAL "")
125+
set(PREFIX "${_unique_dir}")
126+
else()
127+
set(PREFIX "${PREFIX}/${_unique_dir}")
128+
endif()
129+
endif()
130+
endMacro()
131+
115132
Macro(iox_set_rpath)
116133
set(arguments TARGET RPATH )
117134
cmake_parse_arguments(IOX "" "" "${arguments}" ${ARGN} )
@@ -211,7 +228,6 @@ Macro(iox_add_library)
211228
cmake_parse_arguments(IOX "${switches}" "${arguments}" "${multiArguments}" ${ARGN} )
212229

213230
if ( NOT IOX_NO_PACKAGE_SETUP )
214-
message("setup ${IOX_TARGET}")
215231
setup_package_name_and_create_files(
216232
NAME ${IOX_TARGET}
217233
NAMESPACE ${IOX_NAMESPACE}

tools/ci/cmake-linter.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ performCmakeLinting()
4040
echo " please do not use the cmake command \"add_executable\", use \"iox_add_executable\" instead"
4141
EXIT_CODE=1
4242
fi
43+
44+
if ! [[ $(cat $FILE | grep "MAKE_UNIQUE_INCLUDEDIR" | wc -l) == "0" ]]
45+
then
46+
echo " please do not access MAKE_UNIQUE_INCLUDEDIR directly, use \"iox_make_unique_includedir()\" and access it via the variable \"PREFIX\""
47+
EXIT_CODE=1
48+
fi
4349
done
4450
}
4551

0 commit comments

Comments
 (0)