-
Notifications
You must be signed in to change notification settings - Fork 132
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
Allow static library builds #64
base: master
Are you sure you want to change the base?
Conversation
# If building static libraries, set URDFDOM_STATIC definition for symbol | ||
# visibility settings. | ||
if (NOT BUILD_SHARED_LIBS) | ||
add_definitions(-DURDFDOM_STATIC) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding the definition only here will mean that client binaries that link urdfdom
as a static library will import the headers with URDFDOM_DLLAPI
set to __declspec(dllimport)
.
This at least by inspection of https://github.com/ros/urdfdom/blob/master/urdf_parser/include/urdf_parser/exportdecl.h and knowing that client libraries will not have the URDFDOM_STATIC
definition set.
Are you sure this is ok and not causing linking problems?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are correct. This cannot resolve the linking problems since the client libraries will not have URDFDOM_STATIC
.
There are two possible ways I can think:
- pass the definition set to the client through
urdfdom.pc
orFindUrdfdom.cmake
- directly config
exportedcl.h
to define proper preprocessors in the cmake process
I'm not sure which one is preferred way.
Edit: It seems urdfdom.pc
is not generated for Windows though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked how is this implemented in YARP (a library that we use that I am 100% sure that supports building as static library in Windows) and apparently the approach used is the second one that you suggested : https://github.com/robotology/yarp/blob/master/conf/template/yarp_config_api.h.in .
Basically the exportdecl.h
equivalent file is configured at cmake time and proper definition is added with a #cmakedefine
command.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the guide.
I added distinct config.h
file instead of configuring exportdecl.h
because I prefer to use config.h
file to includes all the definitions configured at cmake time. But I'm fine with using exportdecl.h
for if this is not a preferable way to urdfdom
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess your approach is sound. 👍
By the way I just noticed that in
|
@jslee02 can you resolve conflicts? |
# Resolved conflicts: # CMakeLists.txt # urdf_parser/CMakeLists.txt
I resolved the conflicts in the latest commit.
|
Should |
I think it should be. One concern is that the definition Alternatively, since |
|
cc @j-rivero we have a question about a weird |
I buy Steve's hypothesis about what Thomas did. He was the first implementing packaging for urdfdom and console_bridge. Makes no sense to me to mix different variable names in an exportdecl file. |
I've submitted #75 to fix |
I am not sure how I introduced this bug but I believe replacing |
This PR enables urdfdom to build static libraries by:
add_library(~)
This does not change the default build behavior (i.e., shared build) when the build type is not specified.