Skip to content

Commit

Permalink
Convenience function to set find_python HINTS
Browse files Browse the repository at this point in the history
  • Loading branch information
Crivella committed Oct 4, 2024
1 parent 57b03e4 commit 606533b
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions easybuild/easyblocks/generic/cmakemake.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,22 @@ def configure_step(self, srcdir=None, builddir=None):

return out

def set_cmake_env_vars_python(self):
"""Convenience function to set CMake hints for FindPython[_2/3] as environment variables.
Needed to avoid wrong Python being picked up by CMake when not called directly by EasyBuild but as step in a
build and no option is provided to set custom CMake variables.
"""
if LooseVersion(self.cmake_version) < '3.12':
raise EasyBuildError("Setting Python hints for CMake requires CMake version 3.12 or newer")
python_root = get_software_root('Python')
if python_root:
python_version = LooseVersion(get_software_version('Python'))
setvar('Python_ROOT_DIR', python_root)
if python_version >= "3":
setvar('Python3_ROOT_DIR', python_root)
else:
setvar('Python2_ROOT_DIR', python_root)

def test_step(self):
"""CMake specific test setup"""
# When using ctest for tests (default) then show verbose output if a test fails
Expand Down

0 comments on commit 606533b

Please sign in to comment.