Even worse, they seem to acknowledge this problem and created "proxy" macros for the use by the host OS (code at the bottom)
Is it just me or is this really nasty? # macro to find packages on the host OS macro( find_host_package ) set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER ) set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER ) set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER ) if( CMAKE_HOST_WIN32 ) SET( WIN32 1 ) SET( UNIX ) elseif( CMAKE_HOST_APPLE ) SET( APPLE 1 ) SET( UNIX ) endif() find_package( ${ARGN} ) SET( WIN32 ) SET( APPLE ) SET( UNIX 1 ) set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY ) set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY ) set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY ) endmacro() # macro to find programs on the host OS macro( find_host_program ) set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER ) set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER ) set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER ) if( CMAKE_HOST_WIN32 ) SET( WIN32 1 ) SET( UNIX ) elseif( CMAKE_HOST_APPLE ) SET( APPLE 1 ) SET( UNIX ) endif() find_program( ${ARGN} ) SET( WIN32 ) SET( APPLE ) SET( UNIX 1 ) set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY ) set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY ) set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY ) endmacro() On Thu, Apr 6, 2017 at 3:41 PM, Robert Dailey <rcdailey.li...@gmail.com> wrote: > Unsetting these at the bottom of the toolchain file fixes it: > > unset( CMAKE_FIND_ROOT_PATH ) > unset( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ) > unset( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ) > unset( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ) > > However I'm not sure if this is the right solution. They do for some > reason specify PROGRAM to ONLY. Should these values propagate outside > of the toolchain file? > > On Thu, Apr 6, 2017 at 3:38 PM, Brad King <brad.k...@kitware.com> wrote: >> On 04/06/2017 04:32 PM, Robert Dailey wrote: >>> directories coming from PATH can be "rerooted" like this, it makes >>> things very confusing... maybe there is a reason for it, but I'd never >>> want this personally, and I find it concerning that a toolchain file >>> can break this for the whole project. >> >> The toolchain file is using CMAKE_FIND_ROOT_PATH to prevent find >> commands from searching outside of those directories. That is >> why everything is rerooted. >> >> Often one doesn't want this for programs, so the toolchain file >> should set CMAKE_FIND_ROOT_PATH_MODE_PROGRAM to NEVER or BOTH. >> If it has some reason for not doing that then one can always use >> NO_CMAKE_FIND_ROOT_PATH in the individual find_program call. >> >> -Brad >> -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake-developers