c++ - CMAKE use environment variables without passing them as commandline arguments? -


i use modules on rhel5 , have various versions of compilers/binutils located on machine. such end defining environment variables point tools , update paths accordingly old tools shipped rhel5 out of picture.

is there simple method have cmake load corresponding environment variable?

for example in environment:

cmake_cxx_compiler=/some/other/compiler cmake_linker=/some/other/linker 

is there way have cmake grab these without passing them arguments via commandline?

the following didnt work me in cmakelists.txt

set(cmake_cxx_compiler, $env{cmake_cxx_compiler}) 

and not surprisingly following didnt work:

if($env{cmake_cxx_compiler})     set(cmake_cxx_compiler, $env{cmake_cxx_compiler})     message("cmake_cxx_compiler ${cmake_cxx_compiler}") endif() 

maybe syntax issue or not correct place update such cmake variable? work when pass via commandline (e.g. -dcmake_cxx_compiler=${cmake_cxx_compiler}), dont want way.

thanks

never mind. syntax error: set(cmake_cxx_compiler, $env{cmake_cxx_compiler}) shouldn't have had comma. correct syntax is:

set(cmake_cxx_compiler $env{cmake_cxx_compiler}) 

Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -