CMake Error at /opt/openenclave/lib/openenclave/cmake/openenclave-config.cmake:50 (add_executable):
add_executable cannot create imported target "openenclave::oeedger8r"
because another target with the same name already exists
Repro:
find_package(openenclave)
find_package(openenclave)
@andschwa Andy, is this expected? I've hit this before as well
I don't think you're generally supposed to be able to run find_package twice because they add targets.
@andschwa I disagree, this is a common scenario, especially when consuming other projects directly via add_subdirectory, which is what FetchContent was invented for. And in that case it is totally reasonable that two unrelated projects each call find_package on the same dependency. So, this should never ever fail and typically there are checks in place to see whether the target is already defined etc. See e.g. https://github.com/Kitware/CMake/blob/4ccf40e61e02cffb28b549a3de6f4794ea3e3d92/Modules/FindZLIB.cmake#L125.
Ah we can do that.
@aserdean This should probably just check if the target is defined before making it in the CMake package.
Why was this closed? There is no test in the PR and it's still broken.
CMake Error at /.../openenclave/cmake/openenclave-config.cmake:49 (add_library):
add_library cannot create imported target "crypto" because another target
with the same name already exists.
Thanks @letmaik I'll reopen this! Looks like the PR that auto-closed this issue solved the problem for the openenclave:: namespaced targets, but not for the crypto/dl imported targets.
Edit: Looks like the crypto/dl imported targets didn't exist at the time! We added those later. @EmilAlexandruStoica Interested in looking at this problem? :)
@johnkord I'll try to solve this as soon as posible.