From 8f1955af173bb9d4e0e57d49f66ab5c26477f4be Mon Sep 17 00:00:00 2001 From: Chris Thrasher Date: Thu, 27 Jan 2022 13:22:59 -0700 Subject: [PATCH] Don't add SFML:: namespace to external targets The SFML target export set includes a number of external targets which are not owned by the project itself. This includes targets like Freetype and OpenGL. By specifying a namespace for the export set, a SFML:: namespace was prepended to all targets. This is not a problem when using shared libraries but when building and using static libraries caused a problem where CMake was attempting and failing to find targets with names like SFML::Freetype or SFML::OpenGL which did not exist. Luckily CMake allows you put namespaces in the EXPORT_NAME target property so now we can just add the SFML:: namespace in the macro which creates SFML targets and remove the `NAMESPACE SFML::` line which was adding namespaces to all targets. --- cmake/Macros.cmake | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cmake/Macros.cmake b/cmake/Macros.cmake index d1e440bd..b0d13684 100644 --- a/cmake/Macros.cmake +++ b/cmake/Macros.cmake @@ -81,7 +81,7 @@ macro(sfml_add_library module) set_target_properties(${target} PROPERTIES DEFINE_SYMBOL ${NAME_UPPER}_EXPORTS) # define the export name of the module - set_target_properties(${target} PROPERTIES EXPORT_NAME ${module}) + set_target_properties(${target} PROPERTIES EXPORT_NAME SFML::${module}) # adjust the output file prefix/suffix to match our conventions if(BUILD_SHARED_LIBS AND NOT THIS_STATIC) @@ -452,7 +452,6 @@ function(sfml_export_targets) install(EXPORT SFMLConfigExport FILE ${targets_config_filename} - NAMESPACE SFML:: DESTINATION ${config_package_location}) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/SFMLConfig.cmake"