ecbuild_find_package_search_hints¶
Detect more search hints and possibly add to <name>_ROOT
ecbuild_find_package_search_hints( NAME <name> )
This is called within ecbuild_find_package(). Alternatively it can be called anywhere before a standard find_package()
Motivation¶
Since CMake 3.12 the recommended approach to find_package is via <name>_ROOT which can be set both as variable or in the environment. Many environments still need to be adapted to this, as they are set up with the ecbuild 2 convention <name>_PATH or <NAME>_PATH. Furthermore this allows compatibility with <name>_ROOT for CMake versions < 3.12
Procedure¶
- If neither <name>_ROOT nor <name>_DIR are set in scope:
Try setting <name>_ROOT variable to first valid in list [ <name>_PATH ; <NAME>_PATH ]
- If 1) was not succesfull and neither <name>_ROOT nor <name>_DIR are set in environment:
Try setting <name>_ROOT variable to first valid in list [ ENV{<name>_PATH} ; ENV{<NAME>_PATH} ]
- Overcome CMake versions < 3.12 that do not yet recognize <name>_ROOT in scope or environment
- If CMake version < 3.12:
- If <name>_DIR not defined in scope or environment, but <name>_ROOT IS defined in scope or environment
Try setting <name>_DIR to a valid cmake-dir deduced from <name>_ROOT. Warning: Deduction is not feature-complete (it could be improved, but should now cover 99% of cases)
It is advised to use CMake 3.12 instead.