我该如何在CMakeLists.txt中比较环境变量的值?
echo $CXX
/usr/local/bin/clang++
所以,在我的 /etc/profile 中正确定义了 CXX。然后,在CMakeLists.txt中,我放置了以下内容:
message(status "CXX is " ENV{CXX})
if(DEFINED ENV{CXX})
message(status "CXX is defined and it is " ENV{CXX})
if(ENV{CXX} STREQUAL "/usr/local/bin/clang++")
message(status "which = /usr/local/bin/clang++")
endif()
else()
message(status "CXX is undefined")
endif()
同时,它还会输出以下内容:
CXX is ENV{CXX}
CXX is defined and it ENV{CXX}
我希望你能修改它以输出相关内容。
CXX is /usr/local/bin/clang++
CXX is defined and it is /usr/local/bin/clang++
which = /usr/local/bin/clang++
...还有,我需要测试它是否被定义,或者我可以直接跳到STREQUAL吗?
...EQUAL和STREQUAL之间有什么区别?