-
Notifications
You must be signed in to change notification settings - Fork 31
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
Improve static library support #203
Conversation
Port of gazebosim/sdformat#394 to ign-cmake2. This publicly defines the *_STATIC_DEFINE symbol for a library target if BUILD_SHARED_LIBS is Off. Signed-off-by: Steve Peters <[email protected]>
This adds an example that builds a static library and a second example that links against that static library. Signed-off-by: Steve Peters <[email protected]>
Restore functionality of gazebosim#394. Submitted a fix upstream in gazebosim/gz-cmake#203. Signed-off-by: Steve Peters <[email protected]>
Restore functionality of gazebosim#394. Submitted a fix upstream in gazebosim/gz-cmake#203. Signed-off-by: Steve Peters <[email protected]>
I am currently away from laptop keyboard, but if I recall correctly this should not be necessary as the static case is already handled by the generate_export_header macro. Manually defining the static macro is only necessary when using the same header for both shared and static variants of a library (see https://cmake.org/cmake/help/latest/module/GenerateExportHeader.html) or when using an hardcoded export header file (as we were doing in sdformat if I recall correctly). |
I guess also @Ace314159 could be interested. |
Related code: https://github.com/Kitware/CMake/blob/master/Modules/GenerateExportHeader.cmake#L302 . |
ah, I believe you are right. I had noticed the |
examples only in #202 |
🦟 Bug fix
Port of gazebosim/sdformat#394 from @joxoby to ign-cmake2. This publicly defines the
*_STATIC_DEFINE
symbol for a library target ifBUILD_SHARED_LIBS
is Off.Summary
I believe a special symbol needs to be defined when building with static libraries on Windows. Logic for defining this symbol was added to libsdformat11 in gazebosim/sdformat#394, and I noticed it while preparing to forward-port gazebosim/sdformat#780 to libsdformat11, since I noticed that ign-cmake2 doesn't currently define this symbol. I've added some examples using static libraries, but I'm not sure they're rich enough to prove this fixes any problems on Windows. Perhaps @traversaro @joxoby @madebr have some suggestions?
Checklist
codecheck
passed (See contributing)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.