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

Remove CMAKE_CXX_FLAGS from test targets #214

Merged
merged 5 commits into from
May 14, 2021
Merged

Conversation

mjcarroll
Copy link
Contributor

@mjcarroll mjcarroll commented May 6, 2021

🦟 Bug fix

Fixes #181

Summary

In general, we should never be setting or appending CMAKE_CXX_FLAGS, as these can be controlled via target specific flags.

Checklist

Note to maintainers: Remember to use Squash-Merge

Fixes #181

Signed-off-by: Michael Carroll <[email protected]>
@github-actions github-actions bot added 🏰 citadel Ignition Citadel 🔮 dome Ignition Dome labels May 6, 2021
@richmattes
Copy link

richmattes commented May 7, 2021

Yes, the change looks good. You can reproduce #181 yourself (and confirm the fix) like so:

docker pull fedora:34
docker run --rm=true -it fedora:34 /bin/bash

dnf install -y gcc-c++ cmake make git eigen3-devel libuuid-devel vim

git clone https://github.com/ignitionrobotics/ign-cmake.git -b ign-cmake2
cmake -B ign-cmake-build -S ign-cmake -DCMAKE_INSTALL_PREFIX=/usr
cmake --build ign-cmake-build --target install -j 4

git clone https://github.com/ignitionrobotics/ign-math.git -b ign-math6
cmake -B ign-math-build -S ign-math -DCMAKE_INSTALL_PREFIX=/usr  -DBUILD_TESTING=OFF
cmake --build ign-math-build --target install -j 4

git clone https://github.com/ignitionrobotics/ign-common.git -b ign-common3
cmake -B ign-common-build -S ign-common -DCMAKE_INSTALL_PREFIX=/usr
cmake --build ign-common-build --target INTEGRATION_plugin

git --git-dir=ign-common/.git --work-tree=ign-common checkout remove_cxx_flags
cmake --build ign-common-build --target INTEGRATION_plugin

I did run into another problem while putting together a repro: #include <thread> is missing from ign_common/include/ignition/common/Util.hh. Reproduce with cmake --build ign-common-build --target UNIT_Time_TEST

@mjcarroll
Copy link
Contributor Author

MacOS doesn't like this for some reason, digging...

@richmattes
Copy link

richmattes commented May 12, 2021

IGNDummyPlugins in test/plugins/CMakeLists.txt doesn't link against libignition_common3, and thus doesn't inherit any CXXFLAGS that override the the default C++ standard version. If AppleClang's default C++ standard version is older than C++11, then it's not finding the alignof operator and failing.

You can work around it by setting a project-wide CMAKE_CXX_STANDARD, or by setting the C++ standard version for the libraries in test/plugins/CMakeLists.txt with target_compile_features or by replacing add_library with an applicable ign-cmake helper function.

Enabling -DCMAKE_VERBOSE_MAKEFILE=ON in CI is helpful for debugging these kinds of errors.

@codecov
Copy link

codecov bot commented May 14, 2021

Codecov Report

Merging #214 (4f65f57) into ign-common3 (7560ac9) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff              @@
##           ign-common3     #214   +/-   ##
============================================
  Coverage        76.56%   76.56%           
============================================
  Files               73       73           
  Lines            10357    10357           
============================================
  Hits              7930     7930           
  Misses            2427     2427           
Impacted Files Coverage Δ
include/ignition/common/Util.hh 100.00% <ø> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7560ac9...4f65f57. Read the comment docs.

Signed-off-by: Michael Carroll <[email protected]>
@mjcarroll
Copy link
Contributor Author

@richmattes Verified the latest on Fedora using your helpful reproduction.

The not including <thread> could potentially be justified because it's only in the macros and not actually used in the header, but I went ahead and added it as it shouldn't have any downstream impacts.

@mjcarroll
Copy link
Contributor Author

Homebrew warnings are known, addressing that next...

@mjcarroll mjcarroll merged commit 32fd74e into ign-common3 May 14, 2021
@mjcarroll mjcarroll deleted the remove_cxx_flags branch May 14, 2021 16:58
@scpeters
Copy link
Member

Homebrew warnings are known, addressing that next...

it was more than warnings:

Build Status https://build.osrfoundation.org/job/ignition_common-ci-pr_any-homebrew-amd64/1055/

@mjcarroll
Copy link
Contributor Author

it was more than warnings:

This is why it's important to read 🙄

@scpeters
Copy link
Member

I wish github actions had a yellow light instead of just red and green

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏰 citadel Ignition Citadel 🔮 dome Ignition Dome
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants