Skip to content

Commit

Permalink
Adjust python passdowns for all projects
Browse files Browse the repository at this point in the history
  • Loading branch information
mattdawkins committed Jul 28, 2023
1 parent 99b6534 commit 074e2f3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
7 changes: 1 addition & 6 deletions cmake/add_project_viame.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,7 @@ if( VIAME_ENABLE_CUDNN )
endif()

if( VIAME_ENABLE_PYTHON )
set( VIAME_PYTHON_FLAGS
# Backwards compatibility for sub-projects which use "PYTHON_" cmake
# variables and the old find_package( PythonInterp ) commands instead
# of the newer find Python. CMake fills in other python vars from exec.
-DPython_EXECUTABLE:PATH=${Python_EXECUTABLE}
-DPYTHON_EXECUTABLE:PATH=${PYTHON_EXECUTABLE} )
FormatPassdowns( "PYTHON" VIAME_PYTHON_FLAGS )
endif()

ExternalProject_Add(viame
Expand Down
25 changes: 23 additions & 2 deletions cmake/common_macros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,32 @@ function( FormatPassdownsCond _str _varResult _bothCases _ignoreStr )
set( ${_varResult} ${_tmpResult} PARENT_SCOPE )
endfunction()

function( FormatPassdowns _str _varResult )
FormatPassdownsCond( ${_str} _tmpResult ON "" )
function( FormatPassdownsPython _varResult )
# Backwards compatibility for sub-projects which use "PYTHON_" cmake
# variables and the old find_package( PythonInterp ) commands instead
# of the newer find Python. CMake fills in other python vars from exec.
#
# We don't pass down all PYTHON_* variables due to confusion amongst
# different values for these fields across OS (some are lists, values).
set( _tmpResult
-DPython_EXECUTABLE:PATH=${Python_EXECUTABLE}
-DPYTHON_EXECUTABLE:PATH=${PYTHON_EXECUTABLE})

set( ${_varResult} ${_tmpResult} PARENT_SCOPE )
endfunction()

function( FormatPassdowns _str _varResult )
# Special Cases
if( ${_str} MATCHES "PYTHON" )
FormatPassdownsPython( _tmpResult )
set( ${_varResult} ${_tmpResult} PARENT_SCOPE )
# Default Case
else()
FormatPassdownsCond( ${_str} _tmpResult ON "" )
set( ${_varResult} ${_tmpResult} PARENT_SCOPE )
endif()
endfunction()

function( FormatPassdownsWithIgnore _str _varResult _ignoreStr )
FormatPassdownsCond( ${_str} _tmpResult OFF ${_ignoreStr} )
set( ${_varResult} ${_tmpResult} PARENT_SCOPE )
Expand Down

0 comments on commit 074e2f3

Please sign in to comment.