Tests
CMakeCommands
target_sources
该测试用例用来检查项目中包含的源文件是否全都存在;
学习点:
CMake生成表达式
cmake_minimum_required ( VERSION 3.15 )
project( app )
add_custom_target ( print ${CMAKE_COMMAND} -E echo $<1:"Hello OneFLOW CFD!"> )
if (NOT "$<1:${subdir_fullpath}/subdir_empty_1.cpp>" IN_LIST target_sources_lib_property)
message(SEND_ERROR "target_sources_lib: Generator expression to absolute sub directory file not found")
endif()
if (NOT "$<1:${subdir_fullpath}/../empty_1.cpp>" IN_LIST target_sources_lib_property)
message(SEND_ERROR "target_sources_lib: Generator expression to absolute main directory file not found")
endif()
if (NOT "${subdir_fullpath}/subdir_empty_2.cpp" IN_LIST target_sources_lib_property)
message(SEND_ERROR "target_sources_lib: Relative sub directory file not converted to absolute")
endif()
if (NOT "$<1:empty_2.cpp>" IN_LIST target_sources_lib_property)
message(SEND_ERROR "target_sources_lib: Generator expression to relative main directory file not found")
endif()
if (NOT "${subdir_fullpath}/../empty_3.cpp" IN_LIST target_sources_lib_property)
message(SEND_ERROR "target_sources_lib: Relative main directory file not converted to absolute")
endif()