Path: blob/master/Tests/CMakeCommands/target_sources/CMakeLists.txt
3154 views
1cmake_minimum_required(VERSION 3.12)2cmake_policy(SET CMP0076 NEW)34project(target_sources)56add_library(target_sources_lib)7target_compile_definitions(target_sources_lib PRIVATE "-DIS_LIB")8add_subdirectory(subdir)910set(subdir_fullpath "${CMAKE_CURRENT_LIST_DIR}/subdir")1112get_property(target_sources_lib_property TARGET target_sources_lib PROPERTY SOURCES)13if (NOT "$<1:${subdir_fullpath}/subdir_empty_1.cpp>" IN_LIST target_sources_lib_property)14message(SEND_ERROR "target_sources_lib: Generator expression to absolute sub directory file not found")15endif()16if (NOT "$<1:${subdir_fullpath}/../empty_1.cpp>" IN_LIST target_sources_lib_property)17message(SEND_ERROR "target_sources_lib: Generator expression to absolute main directory file not found")18endif()19if (NOT "${subdir_fullpath}/subdir_empty_2.cpp" IN_LIST target_sources_lib_property)20message(SEND_ERROR "target_sources_lib: Relative sub directory file not converted to absolute")21endif()22if (NOT "$<1:empty_2.cpp>" IN_LIST target_sources_lib_property)23message(SEND_ERROR "target_sources_lib: Generator expression to relative main directory file not found")24endif()25if (NOT "${subdir_fullpath}/../empty_3.cpp" IN_LIST target_sources_lib_property)26message(SEND_ERROR "target_sources_lib: Relative main directory file not converted to absolute")27endif()2829add_executable(target_sources main.cpp)30target_link_libraries(target_sources target_sources_lib)3132get_property(target_sources_property TARGET target_sources PROPERTY SOURCES)33if (NOT "main.cpp" IN_LIST target_sources_property)34message(SEND_ERROR "target_sources: Relative main directory file converted to absolute")35endif()363738