Avoid trying to re-create targets in cmake config (#2471)

When `find_package(Rizin ...)` would be called multiple times, the
second add_library call would error because the target already exists.
This commit is contained in:
Florian Märkl 2022-03-30 20:11:56 +02:00 committed by GitHub
parent 907f296f57
commit be48ddcd9f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -88,6 +88,11 @@ foreach(_comp ${Rizin_FIND_COMPONENTS})
set(Rizin_NOT_FOUND_MESSAGE "Unsupported component: ${_comp}")
return()
endif()
if (rz_${_comp_lower}_FOUND)
# Already got this component, trying to re-add the
# target below would be an error
continue()
endif()
find_package(rz_${_comp_lower} PATHS ${_rizin_cmake_path})
if (NOT rz_${_comp_lower}_FOUND)
set(Rizin_FOUND False)
@ -103,4 +108,4 @@ foreach(_comp ${Rizin_FIND_COMPONENTS})
INTERFACE_INCLUDE_DIRECTORIES "${rz_${_comp_lower}_INCLUDE_DIRS}")
endforeach()
set(Rizin_PLUGINDIR @INSTALL_PLUGDIR@)
set(Rizin_PLUGINDIR @INSTALL_PLUGDIR@)