consider simple cmake script below trying find fictional theheader.h
c header file. far know, typical way locate include directory of library in findxxx.cmake
modules.
cmake_minimum_required(version 2.6) project(test) find_path( test_includes names "theheader.h" ) message(status "test_includes: ${test_includes}")
now assume that, in way unrelated cmake script, have edited path
environment variable (i'm running linux) contain custom bin
directory:
path="/home/cschreib/someapp/bin:$path"
turns out, directory /home/cschreib/someapp/include
exists, , contains file named theheader.h
. header used locally build someapp
, never meant used other programs*.
before cmake 3.3, custom location never found cmake. however, starting version 3.3, cmake tries smart , substitutes bin
include
directories in $path
. therefore, cmake 3.3 (and above) find theheader.h
in custom directory. because never intended, causing sorts of trouble, including mismatch between headers , shared objects versions.
i know can tell cmake not in $path
using no_system_environment_path
option in find_path
, looking more generic solution issue. indeed, problem can happen library. make copy of findxxx.cmake modules need , systematically add no_system_environment_path
option, rather avoid this.
is there global switch use turn off unwanted feature? or other way out?
*: before comments on this. aware not practice. aware that, in community, people tend not care , bad practices, , situation common. since not going change community, want cmake scripts robust against bad practices.
this behavior removed again non-windows platform cmake version 3.6.
if run problem update the latest cmake version. see version 3.6 release notes deprecated , removed features:
the
find_library()
,find_path()
, ,find_file()
commands no longer search in installation prefixes derivedpath
environment variable on non-windows platforms. behavior added in cmake 3.3 support windows hosts has proven problematic on unix hosts. users keep<prefix>/bin
directories in path tools not want supporting<prefix>/lib
directories searched. 1 may setcmake_prefix_path
environment variable ;-list of prefixes searched.