Use CMake-standard <PackageName>_ROOT variable to locating config module

https://cmake.org/cmake/help/v3.22/command/find_package.html
https://cmake.org/cmake/help/v3.22/variable/PackageName_ROOT.html#variable:%3CPackageName%3E_ROOT

SFML_DIR predates the existence of <PackageName>_ROOT which is now
the preferred way to specify where to find a given package's config
module. User reports have shown that SFML_DIR may be broken at least
in certain circumstances so lets stop mentioning it.
This commit is contained in:
Chris Thrasher 2024-01-16 13:10:58 -07:00
parent a2c003b2b7
commit 30a986e632
No known key found for this signature in database
GPG Key ID: 56FB686C9DFC8E2C
2 changed files with 4 additions and 4 deletions

View File

@ -41,7 +41,7 @@
# Additionally, keep in mind that SFML frameworks are only available as release libraries unlike dylibs which
# are available for both release and debug modes.
#
# If SFML is not installed in a standard path, you can use the SFML_DIR CMake variable
# If SFML is not installed in a standard path, you can use the SFML_ROOT CMake variable
# to tell CMake where SFML's config file is located (PREFIX/lib/cmake/SFML for a library-based installation,
# and PREFIX/SFML.framework/Resources/CMake on macOS for a framework-based installation).
#
@ -109,7 +109,7 @@ list(REMOVE_DUPLICATES SFML_FIND_COMPONENTS)
if(SFML_STATIC_LIBRARIES)
set(SFML_IS_FRAMEWORK_INSTALL "@SFML_BUILD_FRAMEWORKS@")
if(SFML_IS_FRAMEWORK_INSTALL)
message(WARNING "Static frameworks are not supported by SFML. Clear SFML_DIR cache entry, \
message(WARNING "Static frameworks are not supported by SFML. Clear SFML_ROOT cache entry, \
and either change SFML_STATIC_LIBRARIES or CMAKE_FIND_FRAMEWORK before calling find_package(SFML)")
endif()
set(config_name "Static")
@ -134,7 +134,7 @@ if(EXISTS "${targets_config_file}")
if(TARGET SFML::${component})
set(SFML_${UPPER_COMPONENT}_FOUND TRUE)
elseif(SFML_FIND_REQUIRED_${component})
set(FIND_SFML_ERROR "Found SFML but requested component '${component}' is missing in the config defined in ${SFML_DIR}.")
set(FIND_SFML_ERROR "Found SFML but requested component '${component}' is missing in the config defined in ${SFML_ROOT}.")
set(SFML_FOUND FALSE)
endif()
endforeach()

View File

@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.22)
project(sfml-example CXX)
set(SFML_DIR "${CMAKE_ANDROID_NDK}/sources/third_party/sfml/lib/${CMAKE_ANDROID_ARCH_ABI}/cmake/SFML")
set(SFML_ROOT "${CMAKE_ANDROID_NDK}/sources/third_party/sfml/lib/${CMAKE_ANDROID_ARCH_ABI}/cmake/SFML")
# Create the libsfml-example.so library that contains the application's c++ code
add_library(sfml-example SHARED main.cpp)