The current implementation of FindSFML.cmake is using the cmake command find_path together with the PATHS argument.
My Request is to use HITNS additional to PATHS
Story:I am using sfml for two projects. one is using sfml version 2.1 from the ubuntu packages. I want to keep working with this version (in order not to force the whole team to install sfml manually)
For another project I started using sfgui, which has sfml 2.3 as prerequirement.
So I downloaded the compiled version of SFML. (I am using the precompiled version, as I am planning to also work on a computer on my university, where I don't have root privileges, so I don't want to need to install the dev versions of all dependencies)
Problem:The current FindSFML.cmake script finds always the sfml version installed with the ubuntu packages, although I am using SFML_ROOT to override the path.
The Problem is, that the PATHS attribute will cause cmake to look first at the default locations (I think it is CMAKE_MODULE_PATH, but I am not 100% sure), bevore checking the paths of the PATHS attribute. I've modified the FindSFML.cmake script to use HINTS, they are checked before the CMAKE_MODULE PATH. SO instead of
# define the list of search paths for headers and libraries
set(FIND_SFML_PATHS
${SFML_ROOT}
$ENV{SFML_ROOT}
~/Library/Frameworks
/Library/Frameworks
/usr/local
/usr
/sw
/opt/local
/opt/csw
/opt)
# find the SFML include directory
find_path(SFML_INCLUDE_DIR SFML/Config.hpp
PATH_SUFFIXES include
PATHS ${FIND_SFML_PATHS})
I have now
# define the list of search paths for headers and libraries
set(FIND_SFML_PATHS
${SFML_ROOT}
$ENV{SFML_ROOT}
~/Library/Frameworks
/Library/Frameworks
/usr/local
/usr
/sw
/opt/local
/opt/csw
/opt)
#################### ADDED
set(FIND_SFML_HINTS
${SFML_ROOT}
$ENV{SFML_ROOT}
)
# find the SFML include directory
find_path(SFML_INCLUDE_DIR SFML/Config.hpp
PATH_SUFFIXES include
HINTS ${FIND_SFML_HINTS} ################### ADDED
PATHS ${FIND_SFML_PATHS})
What now?This fix is working perfectly for me, so I wanted to share it with you
I you thik that's usefull, use it as you whish