在我的CMake腳本中,我想查看我的系統上是否有文件,如果有,請用它做一些事情,否則用默認文件做一些事情。這裏是代碼: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中是否存在文件的正確方法是什麼?
[文檔在這裏](https://cmake.org/cmake/help/v3.5/command/if.html?highlight=EXISTS) – teivaz