-
Notifications
You must be signed in to change notification settings - Fork 263
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: export targets #943
cmake: export targets #943
Conversation
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.
Looks pretty good! I've cross-checked this with some of KDE's libraries and have some comments below.
There are two other changes on this second version:
and
Library dependencies are transitive by default with the original signature. When the library target is linked into another target then the libraries linked to this target also were linked to the other targets. That means over-linking for the downstream projects. With the PRIVATE option, the libfluidsynth linked libraries are not included in the I'm afraid that this messed up some tests. Sorry! |
The most recent push has messed up the commit history. Can you please clean it up? The unit tests are built against |
4f8f9a9
to
43d9c86
Compare
done.
I've reverted the changes to the target_link_libraries() because it is not really related to the exported/imported targets, but it is a preexisting issue. The solution that you propose would work, simply applying target_link_libraries(libfluidsynth-OBJ ...) that will propagate the dependencies to the targets where this object library is linked. The only problem with that is that requires cmake 3.12 or later. See: https://cmake.org/cmake/help/latest/command/target_link_libraries.html?highlight=target_link_library#linking-object-libraries |
The build system creates two exported targets: - The executable FluidSynth::fluidsynth - The library FluidSynth::libfluidsynth A downstream project using CMake can find and link the library target directly with cmake (without needing pkg-config) this way: ~~~ project(sample LANGUAGES C) find_package ( FluidSynth ) if (FluidSynth_FOUND) add_executable( sample sample.c ) target_link_libraries ( sample PRIVATE FluidSynth::libfluidsynth ) endif () ~~~ After installing fluidsynth in a prefix like "$HOME/Fluidsynth3": cmake -DCNAKE_PREFIX_PATH="$HOME/Fluidsynth3/;..." Instead installing, the build directory can be used directly, for instance: cmake -DFluidSynth_DIR="$HOME/fluidsynth-2.2.2/build/" ...
* FluidSynthConfigVersion.cmake is created with ${VERSION} instead of ${LIB_VERSION_INFO} * FluidSynthConfig.cmake.in simplified: it doesn't need to include the version file. * Simplified BUILD_INTERFACE generator expression as suggested
25953bc
to
f023d7e
Compare
Kudos, SonarCloud Quality Gate passed! |
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.
Sorry, I didn't received a notification when you marked that ready. I tried to fix our CI at OBS by importing the spec and dsc files, but I made it worse. Will fix it later. Thanks again!
…argets Reverts most of #943 on master as it accidentally broke compilation with CMake < 3.11, but keep the build files for OBS.
The build system creates two exported targets:
A downstream project using CMake can find and link the library target
directly with cmake (without needing pkg-config) this way:
After installing fluidsynth in a prefix like "$HOME/Fluidsynth3":
cmake -DCNAKE_PREFIX_PATH="$HOME/Fluidsynth3/;..."
Instead installing, the build directory can be used directly, for
instance:
cmake -DFluidSynth_DIR="$HOME/fluidsynth-2.2.2/build/" ...