CMake: Use targets for all optionally-external dependencies

This commit is contained in:
TellowKrinkle
2023-04-16 00:57:34 -05:00
parent 63090d411d
commit 5b10a80401
25 changed files with 172 additions and 133 deletions

View File

@ -206,4 +206,20 @@ endif()
# handle success
if(SFML_FOUND)
message(STATUS "Found SFML ${SFML_VERSION_MAJOR}.${SFML_VERSION_MINOR} in ${SFML_INCLUDE_DIR}")
foreach(FIND_SFML_COMPONENT ${SFML_FIND_COMPONENTS})
string(TOLOWER ${FIND_SFML_COMPONENT} FIND_SFML_COMPONENT_LOWER)
string(TOUPPER ${FIND_SFML_COMPONENT} FIND_SFML_COMPONENT_UPPER)
if(NOT TARGET sfml-${FIND_SFML_COMPONENT_LOWER})
add_library(sfml-${FIND_SFML_COMPONENT_LOWER} UNKNOWN IMPORTED)
set_target_properties(sfml-${FIND_SFML_COMPONENT_LOWER} PROPERTIES
IMPORTED_LOCATION "${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${SFML_INCLUDE_DIR}"
)
if(NOT ${FIND_SFML_COMPONENT_LOWER} STREQUAL system)
set_target_properties(sfml-${FIND_SFML_COMPONENT_LOWER} PROPERTIES
INTERFACE_LINK_LIBRARIES sfml-system
)
endif()
endif()
endforeach()
endif()