Skip to content
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

rtaudio and rtmidi have CMake target collisions #339

Open
charliehuge opened this issue Dec 13, 2021 · 5 comments
Open

rtaudio and rtmidi have CMake target collisions #339

charliehuge opened this issue Dec 13, 2021 · 5 comments

Comments

@charliehuge
Copy link

I was using rtmidi in a CMake project using FetchContent like this:

    FetchContent_Declare(
            rtmidi
            GIT_REPOSITORY https://github.com/thestk/rtmidi.git)
    FetchContent_MakeAvailable(rtmidi)

This worked fine until I wanted to also include rtaudio. If I do the same as above to get rtaudio and make it available to my targets, I get an error like this:

CMake Error at rtmidi/CMakeLists.txt:271 (add_custom_target):
  add_custom_target cannot create target "uninstall" because another target
  with the same name already exists.  The existing target is a custom target
  created in source directory "/blah/blah/rtaudio".
  See documentation for policy CMP0002 for more details.

I can get around this by including rtaudio and rtmidi directly in my project as submodules, then modifying the CMakeLists.txt for each library to either change the names or just remove the targets (I don't need them). But now I have a fork of each library to maintain just to use both things.

First off, am I missing something obvious? If not, how do users of both libraries typically handle this?

@sonoro1234
Copy link
Contributor

@garyscavone
Copy link
Contributor

Not clear to me whether this is still a problematic issue or not. If I don't see further discussion, I'll close it then next time I cull the issues list.

@DrZlo13
Copy link

DrZlo13 commented Jan 10, 2023

@garyscavone set(RTAUDIO_TARGETNAME_UNINSTALL "uninstall_rtaudio" ... solves the current issue for me.

If anybody after me will face error:

add_custom_target cannot create target "uninstall" because another target with the same name already exists.

This can be fixed with the following lines in your CMakeLists.txt:

set(RTAUDIO_BUILD_TESTING OFF CACHE INTERNAL "RTAudio: Build without tests")
set(RTAUDIO_TARGETNAME_UNINSTALL "uninstall_rtaudio" CACHE INTERNAL "RTAudio: change uninstall target name" FORCE)
add_subdirectory("lib/rtaudio" "rtaudio")

set(RTMIDI_BUILD_TESTING OFF CACHE INTERNAL "RTMidi: Build without tests")
set(RTMIDI_TARGETNAME_UNINSTALL "uninstall_rtmidi" CACHE INTERNAL "RTMidi: change uninstall target name" FORCE)
add_subdirectory("lib/rtmidi" "rtmidi")

@DrZlo13
Copy link

DrZlo13 commented Jan 10, 2023

I think the current issue can be closed, but documentation is needed for using rtmidi and rtaudio in the same project.

@witte
Copy link

witte commented Jan 24, 2024

It would be nice to have an option to disable the uninstall target completely, I could make a PR for that if there's interest 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants