-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
CMake build static vs. shared libs #588
Comments
I should probably be more involved in all the build options than I am, and I hope someone else can contribute an answer. But it's always my hope that including source will work. |
@KerstinKeller Using namespace for export is definitely the modern approach but it might break all current builds. Do you plan to submit a PR for this? @leethomason I can do this sometime later if you don't mind require everyone who use tinyxml2 to change target link to tinyxml2::tinyxml2 from target link to tinyxml2 in their downstream CMakeLists. |
You can have both actually. add_library(tinyxml2::tinyxml2 ALIAS tinyxml2) FWIW: Yes! Please add the namespace. This is currently non-idiomatic. Also here's some reasons:
|
Would this pull request originally intended for Hunter package manager be of interest? hunter-packages#2 It essentially does what you are suggesting (+introduces It could pretty much be applied out of the box with minimal modifications. Of course downstream projects would no longer be able to use |
@lsolanka The PR hunter-packages#2 looks great to me too. |
I have seen that the CMake build is now supported and it exports its targets with a config, which is great.
However, I am a little confused as on how you're handling static vs dynamic libs.
From my understanding, with a CMake build, you specify
BUILD_SHARED_LIBS=ON
orBUILD_SHARED_LIBS=OFF
and your library will be build accordingly. However, your configuration allows to build both, but exports them with different names (tinyxml2
vstinyxml2_static
).I am also developing a library, which uses tinyxml2, but in my CMakeLists.txt files, I don't want to care about if someone has installed the static or non-static version of tinyxml2.
I would have to do something like
So basically this is not a bug or anything, but I am just wondering if you're willing to reconsider this design.
On a sidenote, many libraries chose to export their libraries to a namespace, e.g.
export(EXPORT tinyxml2 NAMESPACE tinyxml2)
to later be referenced astinyxml2::tinyxml2
. I guess as tinyxml2 only has one component, it is not strictly necessary, but it could be helpful in seeing that you're referencing an installed library.The text was updated successfully, but these errors were encountered: