How to delete or rename an imported target using cmake?

Dear every one:

When I was using CMake, I encounter a problem.

I am trying to use ccd lib from github for my project. However, the ccd lib exports ccd-targets.cmake using the same name for different configurations such as Debug and Release.

When I am trying to create my project, I would like to import two configurations from different paths to my project at the same time. However one of the target couldn’t be found by find_package command, since both of them share the same target name “ccd”.

I would like to know how to solve this problem? Can I rename the target after the target is imported and then the ccd is available for the second find_package command?

Best wishes~

1 Like

You cannot rename imported targets. The ccd library will need changes to support being imported in release and debug modes at the same time (at least from a non-multi-config generator). If you can, using the Ninja Multi-Config generator to build the Release and Debug builds at one time should help.

Thank you very much.

I have got rid of the .cmake file offered by ccd library and using find_path and find_library to create an imported library from scratch.

1 Like