在我的 CMake 脚本中,我想查看我的系统上是否有文件,如果有的话,用它做一些事情,否则用一个默认文件做一些事情。这是代码:
find_file(
${project_name}_${customer}_config
${ROOT}/configuration/${customer}/configuration.${project_name}.xml
)
if(NOT ${${project_name}_${customer}_config} STREQUAL
${project_name}_${customer}_config-NOTFOUND )
configure_file(${ROOT}/configuration/${customer}/configuration.${project_name}.xml
${CMAKE_CURRENT_BINARY_DIR}/conf/configuration.xml)
else()
configure_file(${FAPP_ROOT}/configuration/Default/configuration.${project_name}.xml
${CMAKE_CURRENT_BINARY_DIR}/conf/configuration.xml)
endif()
但似乎,这行不通。
检查CMake中是否存在文件的正确方法是什么?