Skip to content

Commit cfdc301

Browse files
authored
Fix CMake finder (#487)
1 parent 17a3cf9 commit cfdc301

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

config/modules/crest-utils.cmake

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,10 @@ macro(
9797
"${${_pkg_uc}_BINARY_DIR}"
9898
)
9999

100-
add_library("${package}::${package}" INTERFACE IMPORTED)
101-
target_link_libraries("${package}::${package}" INTERFACE "${package}")
100+
if(NOT TARGET "${package}::${package}")
101+
add_library("${package}::${package}" INTERFACE IMPORTED)
102+
target_link_libraries("${package}::${package}" INTERFACE "${package}")
103+
endif()
102104

103105
# We need the module directory in the subproject before we finish the configure stage
104106
if(NOT EXISTS "${${_pkg_uc}_BINARY_DIR}/include")
@@ -122,8 +124,10 @@ macro(
122124
)
123125
FetchContent_MakeAvailable("${_pkg_lc}")
124126

125-
add_library("${package}::${package}" INTERFACE IMPORTED)
126-
target_link_libraries("${package}::${package}" INTERFACE "${package}")
127+
if(NOT TARGET "${package}::${package}")
128+
add_library("${package}::${package}" INTERFACE IMPORTED)
129+
target_link_libraries("${package}::${package}" INTERFACE "${package}")
130+
endif()
127131

128132
# We need the module directory in the subproject before we finish the configure stage
129133
FetchContent_GetProperties("${_pkg_lc}" SOURCE_DIR "${_pkg_uc}_SOURCE_DIR")

0 commit comments

Comments
 (0)