From 51a8cebe303ec21f86474cba65e168ad7826e5a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dietrich=20Kr=C3=B6nke?= Date: Tue, 24 Aug 2021 13:58:57 +0200 Subject: [PATCH] iox-#905 Fix libcxx support for clang --- CHANGELOG.md | 1 + cmake/cyclonedds/CMakeLists.txt | 7 ++++++- cmake/googletest/CMakeLists.txt | 9 +++++++-- .../benchmark_optional_and_expected.cpp | 2 +- tools/iceoryx_build_test.sh | 7 +++++++ 5 files changed, 22 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 69412215b7..d40406c315 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ **Bugfixes:** +- Fix support for libc++ on clang[\#905](https://github.com/eclipse-iceoryx/iceoryx/issues/905) - Fix warnings for gcc-11.1[\#838](https://github.com/eclipse-iceoryx/iceoryx/issues/838) - Incremental builds with the build script are broken[\#821](https://github.com/eclipse-iceoryx/iceoryx/issues/821) - Compile failed because of missing for GCC 11[\#811](https://github.com/eclipse-iceoryx/iceoryx/issues/811) thanks to @homalozoa diff --git a/cmake/cyclonedds/CMakeLists.txt b/cmake/cyclonedds/CMakeLists.txt index b748ffa72c..0bdf78bc41 100644 --- a/cmake/cyclonedds/CMakeLists.txt +++ b/cmake/cyclonedds/CMakeLists.txt @@ -38,6 +38,11 @@ if(DEFINED CMAKE_TOOLCHAIN_FILE) set(TOOLCHAIN_FILE "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}") endif() +set(EXTRA_CMAKE_ARGS) +if(DEFINED CMAKE_CXX_FLAGS) + list(APPEND EXTRA_CMAKE_ARGS -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}) +endif() + # ===== Helpers function(fetch_and_install name) set(DOWNLOAD_CONFIG_DIR ${CMAKE_BINARY_DIR}/dependencies/${name}/download) @@ -76,7 +81,7 @@ function(fetch_and_install name) endforeach() string( REPLACE ";" " " ADDITIONAL_CMAKE_FLAGS "${ADDITIONAL_CMAKE_FLAGS}") - execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" "-DCMAKE_INSTALL_PREFIX=${INSTALL_DIR}" "${ADDITIONAL_CMAKE_FLAGS}" "${TOOLCHAIN_FILE}" "${SOURCE_DIR}" + execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" "-DCMAKE_INSTALL_PREFIX=${INSTALL_DIR}" "${ADDITIONAL_CMAKE_FLAGS}" "${TOOLCHAIN_FILE}" "${EXTRA_CMAKE_ARGS}" "${SOURCE_DIR}" RESULT_VARIABLE result WORKING_DIRECTORY ${BUILD_DIR} ) if(result) diff --git a/cmake/googletest/CMakeLists.txt b/cmake/googletest/CMakeLists.txt index 368e81f4bc..a754e5e3b4 100644 --- a/cmake/googletest/CMakeLists.txt +++ b/cmake/googletest/CMakeLists.txt @@ -40,6 +40,11 @@ if(BUILD_TEST) set(GTest_DIR ${GTest_DIR} CACHE PATH "" FORCE) endif() + set(EXTRA_CMAKE_ARGS) + if(DEFINED CMAKE_CXX_FLAGS) + list(APPEND EXTRA_CMAKE_ARGS -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}) + endif() + # set download confi, source and build paths set(DOWNLOAD_CONFIG_DIR ${CMAKE_BINARY_DIR}/dependencies/googletest/download) set(SOURCE_DIR ${CMAKE_BINARY_DIR}/dependencies/googletest/src) @@ -49,7 +54,7 @@ if(BUILD_TEST) # Download and unpack googletest at configure time configure_file(googletest.cmake.in ${DOWNLOAD_CONFIG_DIR}/CMakeLists.txt) - execute_process(COMMAND ${CMAKE_COMMAND} ${ENABLE_STATIC_DEBUG} -G "${CMAKE_GENERATOR}" "${TOOLCHAIN_FILE}" "${DOWNLOAD_CONFIG_DIR}" + execute_process(COMMAND ${CMAKE_COMMAND} ${ENABLE_STATIC_DEBUG} -G "${CMAKE_GENERATOR}" "${COMPILER_FLAGS}" "${TOOLCHAIN_FILE}" "${DOWNLOAD_CONFIG_DIR}" RESULT_VARIABLE result WORKING_DIRECTORY ${DOWNLOAD_CONFIG_DIR} ) if(result) @@ -76,7 +81,7 @@ if(BUILD_TEST) endif() endif() - execute_process(COMMAND ${CMAKE_COMMAND} ${ENABLE_STATIC_DEBUG} -G "${CMAKE_GENERATOR}" "-DCMAKE_INSTALL_PREFIX=${INSTALL_DIR}" "${TOOLCHAIN_FILE}" "${SOURCE_DIR}" + execute_process(COMMAND ${CMAKE_COMMAND} ${ENABLE_STATIC_DEBUG} -G "${CMAKE_GENERATOR}" "-DCMAKE_INSTALL_PREFIX=${INSTALL_DIR}" "${TOOLCHAIN_FILE}" "${EXTRA_CMAKE_ARGS}" "${SOURCE_DIR}" RESULT_VARIABLE result WORKING_DIRECTORY ${BUILD_DIR} ) if(result) diff --git a/iceoryx_hoofs/test/stresstests/benchmark_optional_and_expected/benchmark_optional_and_expected.cpp b/iceoryx_hoofs/test/stresstests/benchmark_optional_and_expected/benchmark_optional_and_expected.cpp index 1a4c835981..37543697c6 100644 --- a/iceoryx_hoofs/test/stresstests/benchmark_optional_and_expected/benchmark_optional_and_expected.cpp +++ b/iceoryx_hoofs/test/stresstests/benchmark_optional_and_expected/benchmark_optional_and_expected.cpp @@ -88,7 +88,7 @@ bool popFromFiFoImpl(uint64_t& value) void popFromFiFo() { - uint64_t maybeValue; + uint64_t maybeValue{0U}; if (popFromFiFoImpl(maybeValue)) { globalCounter += maybeValue; diff --git a/tools/iceoryx_build_test.sh b/tools/iceoryx_build_test.sh index 76a16f6a69..265765a74d 100755 --- a/tools/iceoryx_build_test.sh +++ b/tools/iceoryx_build_test.sh @@ -51,6 +51,7 @@ BUILD_SHARED="OFF" TOML_FLAG="ON" COMPONENTS="iceoryx_posh iceoryx_hoofs iceoryx_introspection iceoryx_binding_c iceoryx_component iceoryx_dds" TOOLCHAIN_FILE="" +CMAKE_CXX_FLAGS="" while (( "$#" )); do case "$1" in @@ -174,6 +175,11 @@ while (( "$#" )); do export CXX=$(which clang++) shift 1 ;; + "libcxx") + echo " [i] Build with libc++ library" + CMAKE_CXX_FLAGS="-stdlib=libc++" + shift 1 + ;; "doc") echo " [i] Build and generate doxygen" BUILD_DOC="ON" @@ -281,6 +287,7 @@ cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE \ -DBUILD_SHARED_LIBS=$BUILD_SHARED \ -DSANITIZE=$SANITIZE_FLAG \ -DTEST_WITH_ADDITIONAL_USER=$TEST_ADD_USER $TOOLCHAIN_FILE \ + -DCMAKE_CXX_FLAGS=$CMAKE_CXX_FLAGS \ $WORKSPACE/iceoryx_meta cmake --build . --target install -- -j$NUM_JOBS