-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
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
or BUILD_SHARED_LIBS=OFF
and your library will be build accordingly. However, your configuration allows to build both, but exports them with different names (tinyxml2
vs tinyxml2_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
find_package(tinyxml2 REQUIRED)
if (TARGET tinyxml2)
target_link_libraries(my_lib PRIVATE tinyxml2)
else()
target_link_libraries(my_lib PRIVATE tinyxml2_static)
endif()
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 as tinyxml2::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.