Variables with angle brackets in CMake scripts

2019-06-28 06:04发布

问题:

I noticed that CMake can use variables not only in ${VAR_NAME} syntax, but also in <VAR_NAME> syntax. For example, following code:

IF(NOT CMAKE_CXX_LINK_EXECUTABLE)
  SET(CMAKE_CXX_LINK_EXECUTABLE
    "<CMAKE_CXX_COMPILER>  <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS>  -o <TARGET> <LINK_LIBRARIES>")
ENDIF(NOT CMAKE_CXX_LINK_EXECUTABLE)

was found in CMake modules folder in script named CMakeCXXInformation.cmake.

I didn't find any explanation about syntax using angle brackets in the documentation. Has someone used such syntax who can explain its meaning?

回答1:

This syntax is specific to defining rules for compiling and linking. It's used by internal CMake machinery and not intended to be used by CMake users.

These rules are come in play when adding support for new language in CMake, see share/cmake/Modules/CMakeAddNewLanguage.txt for more info on this.



标签: cmake