summaryrefslogtreecommitdiffstats
path: root/Tests/Properties/CMakeLists.txt
blob: 7b7bd2d7a2a011cccba0825c9a60f0979c5a80c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# a simple CXX only test case
project (Properties)

# these first three tests really test both properties and the management of 
# cmSourceFile objects by CMake. 

# test properties on a build tree file that is relative (yuck)
configure_file(properties.h.in "${Properties_BINARY_DIR}/properties.h")
set_source_files_properties(properties.h PROPERTIES TEST1 1)
get_source_file_property(RESULT1 properties.h TEST1)

# test properties on a headerfile in the source tree 
# accessed without an extenion (also yuck)
set_source_files_properties(properties2 PROPERTIES TEST2 1)
get_source_file_property(RESULT2 properties2 TEST2)

# test properties on a relative source that is not generated
set_source_files_properties(SubDir/properties3.cxx PROPERTIES TEST3 1)
get_source_file_property(RESULT3 SubDir/properties3.cxx TEST3)

include_directories("${Properties_SOURCE_DIR}" "${Properties_BINARY_DIR}")


# test generic property interfaces
define_property(GLOBALTEST GLOBAL "A test property" 
  "A long description of this test property" 0)
set_properties(GLOBAL PROPERTIES GLOBALTEST 1)
set_properties(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
  PROPERTIES DIRECTORYTEST 1)
set_properties(SOURCE_FILE SubDir/properties3.cxx PROPERTIES SOURCETEST 1)
get_property(GLOBALRESULT GLOBAL GLOBALTEST)
get_property(DIRECTORYRESULT DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" 
  DIRECTORYTEST)
get_property(SOURCE_FILERESULT SOURCE_FILE SubDir/properties3.cxx SOURCETEST)

if (RESULT1 AND RESULT2 AND RESULT3 AND GLOBALRESULT AND 
    DIRECTORYRESULT AND SOURCE_FILERESULT)
  add_executable (Properties SubDir/properties3.cxx properties)
else (RESULT1 AND RESULT2 AND RESULT3 AND GLOBALRESULT AND 
    DIRECTORYRESULT AND SOURCE_FILERESULT)
  message("Error: test results are RESULT1=${RESULT1} RESULT2=${RESULT2} "
    "RESULT3=${RESULT3} GLOBALRESULT=${GLOBALRESULT} "
    "DIRECTORYRESULT=${DIRECTORYRESULT} "
    "SOURCE_FILERESULT=${SOURCE_FILERESULT}")
endif (RESULT1 AND RESULT2 AND RESULT3 AND GLOBALRESULT AND 
  DIRECTORYRESULT AND SOURCE_FILERESULT)

# test the target property
set_properties(TARGET Properties PROPERTIES TARGETTEST 1)
get_property(TARGETRESULT TARGET Properties TARGETTEST)
if (NOT TARGETRESULT)
    message("Error: target result is TARGETRESULT=${TARGETRESULT}")
endif (NOT TARGETRESULT)

# test the target SOURCES property
get_property(Properties_SOURCES TARGET Properties SOURCES)
set_source_files_properties(${Properties_SOURCES} PROPERTIES TEST4 1)
get_source_file_property(RESULT4 properties.h TEST4)
if(NOT RESULT4)
  message("Error: target result is"
    " RESULT4=${RESULT4}"
    " Properties_SOURCES=[${Properties_SOURCES}]")
endif(NOT RESULT4)