Openenclave: find_package(openenclave) fails the second time

Created on 25 Apr 2019  路  8Comments  路  Source: openenclave/openenclave

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)
bug build

All 8 comments

@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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

johnkord picture johnkord  路  8Comments

andschwa picture andschwa  路  3Comments

radhikaj picture radhikaj  路  7Comments

eozturk1 picture eozturk1  路  6Comments

wintersteiger picture wintersteiger  路  8Comments