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

Fix static builds and optimize test compilation #1343

Merged
merged 5 commits into from
Nov 27, 2023

Conversation

azeey
Copy link
Collaborator

@azeey azeey commented Nov 1, 2023

🦟 Bug fix

Alternative to #1309

Summary

As alluded to in #1309, building sdformat with `-DBUILD_SHARED_LIBS=OFF ..' results in the following error

CMake Error: install(EXPORT "sdformat13" ...) includes target "sdformat13" which requires target "using_parser_urdf" that is not in any export set.
CMake Error in src/CMakeLists.txt:
  export called with target "sdformat13" which requires target
  "using_parser_urdf" that is not in any export set.

This is because we are creating the using_parser_urdf target and linking it against the core library target, which is then exported. When the core library is built as a static library, CMake requires that other targets linked against it are exported as well (see https://stackoverflow.com/a/71080574/283225 case (2)).

The solution in this PR is to compile the URDF sources directly into the core library instead of creating an extra target. While working on this, I realized we could create a static library that includes all the extra sources needed for tests instead of building each test with its own extra sources. I believe this will marginally improve compilation time, but more importantly, I think it cleans up the CMake file and will make adding tests easier.

Checklist

  • Signed all commits for DCO
  • Added tests
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • Consider updating Python bindings (if the library has them)
  • codecheck passed (See contributing)
  • All tests passed (See test coverage)
  • While waiting for a review on your PR, please help review another open pull request to support the maintainers

Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining Signed-off-by messages.

Signed-off-by: Addisu Z. Taddese <[email protected]>
@github-actions github-actions bot added the 🏯 fortress Ignition Fortress label Nov 1, 2023
@azeey azeey self-assigned this Nov 1, 2023
@azeey azeey force-pushed the fix_static branch 2 times, most recently from e4f081e to fc2090b Compare November 2, 2023 03:22
Copy link

codecov bot commented Nov 2, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (7a9dad5) 92.14% compared to head (2caaadb) 92.14%.
Report is 1 commits behind head on sdf12.

❗ Current head 2caaadb differs from pull request most recent head 639d070. Consider uploading reports for the commit 639d070 to get more accurate results

Additional details and impacted files
@@           Coverage Diff           @@
##            sdf12    #1343   +/-   ##
=======================================
  Coverage   92.14%   92.14%           
=======================================
  Files          79       79           
  Lines       13126    13126           
=======================================
  Hits        12095    12095           
  Misses       1031     1031           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

${CMAKE_CURRENT_SOURCE_DIR}
${PROJECT_SOURCE_DIR}/test
)
if (WIN32)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (WIN32)
if (WIN32 AND USE_INTERNAL_URDF)

Unless I miss something, we do not need this if we are using the external urdfdom.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, that makes sense. 5437306

@azeey azeey marked this pull request as ready for review November 8, 2023 23:05
@azeey azeey requested a review from scpeters as a code owner November 8, 2023 23:05
@azeey
Copy link
Collaborator Author

azeey commented Nov 9, 2023

There's a cmake warning related to psutil which is not present in the stable CI builds. Comparing homebrew stable CI job with this PR jojb, I noticed the stable CI job has PIP_PACKAGES_NEEDED='psutil pytest' while the PR job has PIP_PACKAGES_NEEDED=' pytest' right before pip3 install. @j-rivero Did the recent changes in release-toolls cause this?

@scpeters
Copy link
Member

There's a cmake warning related to psutil which is not present in the stable CI builds. Comparing homebrew stable CI job with this PR jojb, I noticed the stable CI job has PIP_PACKAGES_NEEDED='psutil pytest' while the PR job has PIP_PACKAGES_NEEDED=' pytest' right before pip3 install. @j-rivero Did the recent changes in release-toolls cause this?

yes, see #1346 (comment)

@j-rivero
Copy link
Contributor

yes, see #1346 (comment)

Merged and deployed the change. Relaunched the brew -ci-pr_any- job.

Copy link
Member

@scpeters scpeters left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

two small nits

TINYXML2::TINYXML2)
target_sources(UNIT_XmlUtils_TEST PRIVATE XmlUtils.cc)
endif()
# Link against the publically and privately linked libraries of the core library
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Link against the publically and privately linked libraries of the core library
# Link against the publicly and privately linked libraries of the core library

nit: spelling

LIB_DEPS
library_for_tests
TEST_LIST
test_targets
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I don't think test_targets is used anywhere

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops. I saw this right after I merged. See #1347.

@azeey azeey merged commit ffd7e0d into gazebosim:sdf12 Nov 27, 2023
6 checks passed
@azeey azeey deleted the fix_static branch November 27, 2023 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏯 fortress Ignition Fortress
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

5 participants