From 984fa20664f4f64d83307b8876cc51e63bede8af Mon Sep 17 00:00:00 2001 From: Christian Eltzschig Date: Mon, 23 May 2022 20:21:44 +0200 Subject: [PATCH] iox-#1287 Include doc dir for cmake linter, adjust doc example to new cmake api Signed-off-by: Christian Eltzschig --- .../example/iceoryx_component/CMakeLists.txt | 62 +++++-------------- iceoryx_binding_c/CMakeLists.txt | 4 +- .../cmake/IceoryxPackageHelper.cmake | 2 +- tools/ci/cmake-linter.sh | 2 +- 4 files changed, 21 insertions(+), 49 deletions(-) diff --git a/doc/aspice_swe3_4/example/iceoryx_component/CMakeLists.txt b/doc/aspice_swe3_4/example/iceoryx_component/CMakeLists.txt index b252dc2251..16280c9ab6 100644 --- a/doc/aspice_swe3_4/example/iceoryx_component/CMakeLists.txt +++ b/doc/aspice_swe3_4/example/iceoryx_component/CMakeLists.txt @@ -24,36 +24,18 @@ include(IceoryxPlatform) # ########## lib ########## # -add_library(iceoryx_component - source/example_module/example_base_class.cpp +iox_add_library( + TARGET iceoryx_component + NAMESPACE iceoryx_component + PRIVATE_INCLUDES source/example_module + BUILD_INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include + ${CMAKE_BINARY_DIR}/generated/iceoryx/include + INSTALL_INTERFACE include/${PREFIX} + PRIVATE_LIBS ${CMAKE_THREAD_LIBS_INIT} + FILES + source/example_module/example_base_class.cpp ) -add_library(iceoryx_component::iceoryx_component ALIAS iceoryx_component) - -set_target_properties(iceoryx_component PROPERTIES - CXX_STANDARD_REQUIRED ON - CXX_STANDARD ${ICEORYX_CXX_STANDARD} - POSITION_INDEPENDENT_CODE ON - RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" -) - -target_include_directories(iceoryx_component - PUBLIC - $ - $ - $ - PRIVATE - source/example_module -) -target_link_libraries(iceoryx_component - PRIVATE - ${ICEORYX_SANITIZER_FLAGS} - ${CMAKE_THREAD_LIBS_INIT} -) - -target_compile_options(iceoryx_component PRIVATE ${ICEORYX_WARNINGS} ${ICEORYX_SANITIZER_FLAGS}) - - # ########## test ########## # @@ -66,27 +48,17 @@ set(PROJECT_PREFIX "iceoryx_component") file(GLOB_RECURSE MODULETESTS_SRC "${CMAKE_CURRENT_SOURCE_DIR}/test/moduletests/*.cpp") -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${PROJECT_PREFIX}/test) - set(TEST_LINK_LIBS GTest::gtest GTest::gmock iceoryx_component::iceoryx_component ) -if(LINUX) - set(TEST_LINK_LIBS ${TEST_LINK_LIBS} dl ) -endif() - -# unittests -add_executable(${PROJECT_PREFIX}_moduletests ${MODULETESTS_SRC}) -target_include_directories(${PROJECT_PREFIX}_moduletests PRIVATE . source/example_module) -# TODO: fix conversion warnings -target_compile_options(${PROJECT_PREFIX}_moduletests PRIVATE ${TEST_CXX_FLAGS}) -target_link_libraries(${PROJECT_PREFIX}_moduletests ${TEST_LINK_LIBS}) -set_target_properties(${PROJECT_PREFIX}_moduletests PROPERTIES - CXX_STANDARD_REQUIRED ON - CXX_STANDARD ${ICEORYX_CXX_STANDARD} - POSITION_INDEPENDENT_CODE ON +iox_add_executable( + TARGET ${PROJECT_PREFIX}_moduletests + INCLUDE_DIRECTORIES . + source/example_module + FILES ${MODULETESTS_SRC} + LIBS ${TEST_LINK_LIBS} + LIBS_LINUX dl ) - diff --git a/iceoryx_binding_c/CMakeLists.txt b/iceoryx_binding_c/CMakeLists.txt index c0c9d6b0a2..9cd3e688ba 100644 --- a/iceoryx_binding_c/CMakeLists.txt +++ b/iceoryx_binding_c/CMakeLists.txt @@ -37,8 +37,8 @@ iox_make_unique_includedir() ########## build building-block library ########## # iox_add_library( - TARGET iceoryx_binding_c - NAMESPACE iceoryx_binding_c + TARGET ${PROJECT_NAME} + NAMESPACE ${PROJECT_NAME} PROJECT_PREFIX ${PREFIX} BUILD_INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_BINARY_DIR}/generated/iceoryx/include diff --git a/iceoryx_hoofs/cmake/IceoryxPackageHelper.cmake b/iceoryx_hoofs/cmake/IceoryxPackageHelper.cmake index 66e62b0511..350e7f3027 100644 --- a/iceoryx_hoofs/cmake/IceoryxPackageHelper.cmake +++ b/iceoryx_hoofs/cmake/IceoryxPackageHelper.cmake @@ -246,7 +246,7 @@ Macro(iox_add_executable) iox_set_file_language( FILES ${IOX_FILES} ) endif() - target_compile_options(${IOX_TARGET} ${IOX_WARNINGS} ${ICEORYX_SANITIZER}) + target_compile_options(${IOX_TARGET} ${IOX_WARNINGS} ${ICEORYX_SANITIZER_FLAGS}) if ( IOX_STACK_SIZE ) if(WIN32) diff --git a/tools/ci/cmake-linter.sh b/tools/ci/cmake-linter.sh index 5c86760636..ff811ab4f0 100755 --- a/tools/ci/cmake-linter.sh +++ b/tools/ci/cmake-linter.sh @@ -24,7 +24,7 @@ performCmakeLinting() NUMBER_OF_FILES=$(find $ICEORYX_ROOT_PATH -type f -name "CMakeLists.txt" | grep -v ${ICEORYX_ROOT_PATH}/build | grep -v ${ICEORYX_ROOT_PATH}/.github | grep -v ${ICEORYX_ROOT_PATH}/.git | wc -l) CURRENT_FILE=0 - for FILE in $(find $ICEORYX_ROOT_PATH -type f -iname "CMakeLists.txt" | grep -v ${ICEORYX_ROOT_PATH}/build | grep -v ${ICEORYX_ROOT_PATH}/.github | grep -v ${ICEORYX_ROOT_PATH}/.git | grep -v ${ICEORYX_ROOT_PATH}/doc) + for FILE in $(find $ICEORYX_ROOT_PATH -type f -iname "CMakeLists.txt" | grep -v ${ICEORYX_ROOT_PATH}/build | grep -v ${ICEORYX_ROOT_PATH}/.github | grep -v ${ICEORYX_ROOT_PATH}/.git) do let CURRENT_FILE=$CURRENT_FILE+1 echo -e "[$CURRENT_FILE/$NUMBER_OF_FILES] $FILE"