Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Kitware
GitHub Repository: Kitware/CMake
Path: blob/master/Tests/CMakeCommands/target_sources/CMakeLists.txt
3154 views
1
2
cmake_minimum_required(VERSION 3.12)
3
cmake_policy(SET CMP0076 NEW)
4
5
project(target_sources)
6
7
add_library(target_sources_lib)
8
target_compile_definitions(target_sources_lib PRIVATE "-DIS_LIB")
9
add_subdirectory(subdir)
10
11
set(subdir_fullpath "${CMAKE_CURRENT_LIST_DIR}/subdir")
12
13
get_property(target_sources_lib_property TARGET target_sources_lib PROPERTY SOURCES)
14
if (NOT "$<1:${subdir_fullpath}/subdir_empty_1.cpp>" IN_LIST target_sources_lib_property)
15
message(SEND_ERROR "target_sources_lib: Generator expression to absolute sub directory file not found")
16
endif()
17
if (NOT "$<1:${subdir_fullpath}/../empty_1.cpp>" IN_LIST target_sources_lib_property)
18
message(SEND_ERROR "target_sources_lib: Generator expression to absolute main directory file not found")
19
endif()
20
if (NOT "${subdir_fullpath}/subdir_empty_2.cpp" IN_LIST target_sources_lib_property)
21
message(SEND_ERROR "target_sources_lib: Relative sub directory file not converted to absolute")
22
endif()
23
if (NOT "$<1:empty_2.cpp>" IN_LIST target_sources_lib_property)
24
message(SEND_ERROR "target_sources_lib: Generator expression to relative main directory file not found")
25
endif()
26
if (NOT "${subdir_fullpath}/../empty_3.cpp" IN_LIST target_sources_lib_property)
27
message(SEND_ERROR "target_sources_lib: Relative main directory file not converted to absolute")
28
endif()
29
30
add_executable(target_sources main.cpp)
31
target_link_libraries(target_sources target_sources_lib)
32
33
get_property(target_sources_property TARGET target_sources PROPERTY SOURCES)
34
if (NOT "main.cpp" IN_LIST target_sources_property)
35
message(SEND_ERROR "target_sources: Relative main directory file converted to absolute")
36
endif()
37
38