Skip to content

Commit

Permalink
Fix "target with the same name already exists"
Browse files Browse the repository at this point in the history
```
CMake Error at /__w/parPE/parPE/deps/AMICI/build/AmiciConfig.cmake:60 (add_library):
  add_library cannot create imported target "SUNDIALS::KLU" because another
  target with the same name already exists.
Call Stack (most recent call first):
  model/CMakeLists.txt:38 (find_package)


CMake Error at /__w/parPE/parPE/deps/AMICI/build/AmiciConfig.cmake:61 (target_link_libraries):
  Cannot specify link libraries for target "SUNDIALS::KLU" which is not built
  by this project.
Call Stack (most recent call first):
  model/CMakeLists.txt:38 (find_package)


-- Configuring incomplete, errors occurred!
```
  • Loading branch information
dweindl committed Sep 17, 2024
1 parent b1a1084 commit e4e6bdc
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions deps/AMICI/cmake/AmiciConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,18 @@ find_dependency(KLU REQUIRED)

include("${CMAKE_CURRENT_LIST_DIR}/AmiciFindBLAS.cmake")

add_library(SUNDIALS::KLU INTERFACE IMPORTED)
target_link_libraries(
SUNDIALS::KLU
INTERFACE "${KLU_STATIC}"
INTERFACE "${COLAMD_STATIC}"
INTERFACE "${BTF_STATIC}"
INTERFACE "${AMD_STATIC}"
INTERFACE "${SUITESPARSE_CONFIG_STATIC}")
set_target_properties(SUNDIALS::KLU PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
"${KLU_INCLUDE_DIR}")
if(NOT TARGET SUNDIALS::KLU)
add_library(SUNDIALS::KLU INTERFACE IMPORTED)
target_link_libraries(
SUNDIALS::KLU
INTERFACE "${KLU_STATIC}"
INTERFACE "${COLAMD_STATIC}"
INTERFACE "${BTF_STATIC}"
INTERFACE "${AMD_STATIC}"
INTERFACE "${SUITESPARSE_CONFIG_STATIC}")
set_target_properties(SUNDIALS::KLU PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
"${KLU_INCLUDE_DIR};${KLU_INCLUDE_DIR}/suitesparse")
endif()

find_dependency(SUNDIALS REQUIRED PATHS
"@CMAKE_SOURCE_DIR@/ThirdParty/sundials/build/@CMAKE_INSTALL_LIBDIR@/cmake/sundials/")
Expand Down

0 comments on commit e4e6bdc

Please sign in to comment.