2007-05-31 18:29:13 +04:00
|
|
|
# a simple CXX only test case
|
2008-03-25 18:27:18 +03:00
|
|
|
cmake_minimum_required (VERSION 2.6)
|
2007-05-31 18:29:13 +04:00
|
|
|
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}")
|
|
|
|
|
2007-06-25 17:51:37 +04:00
|
|
|
|
|
|
|
# test generic property interfaces
|
2008-04-01 22:22:09 +04:00
|
|
|
get_property(GLOBALRESULT GLOBAL PROPERTY GLOBALTEST DEFINED)
|
|
|
|
if (GLOBALRESULT)
|
|
|
|
message(SEND_ERROR "Error: global prop defined when it should not be, "
|
|
|
|
"result is GLOBALRESULT=${GLOBALRESULT}")
|
|
|
|
endif (GLOBALRESULT)
|
|
|
|
|
2008-02-14 21:36:23 +03:00
|
|
|
define_property(GLOBAL PROPERTY GLOBALTEST
|
|
|
|
BRIEF_DOCS "A test property"
|
|
|
|
FULL_DOCS "A long description of this test property"
|
|
|
|
)
|
2008-04-01 22:22:09 +04:00
|
|
|
|
|
|
|
get_property(GLOBALRESULT GLOBAL PROPERTY GLOBALTEST DEFINED)
|
|
|
|
if (NOT GLOBALRESULT)
|
|
|
|
message(SEND_ERROR "Error: global prop not defined "
|
|
|
|
"result is GLOBALRESULT=${GLOBALRESULT}")
|
|
|
|
endif (NOT GLOBALRESULT)
|
|
|
|
|
2008-01-17 23:54:49 +03:00
|
|
|
set_property(GLOBAL PROPERTY GLOBALTEST 1)
|
|
|
|
set_property(DIRECTORY PROPERTY DIRECTORYTEST 1)
|
|
|
|
set_property(SOURCE SubDir/properties3.cxx PROPERTY SOURCETEST 1)
|
2008-01-18 01:19:13 +03:00
|
|
|
get_property(GLOBALRESULT GLOBAL PROPERTY GLOBALTEST)
|
|
|
|
get_property(DIRECTORYRESULT DIRECTORY PROPERTY DIRECTORYTEST)
|
|
|
|
get_property(SOURCERESULT
|
|
|
|
SOURCE SubDir/properties3.cxx
|
|
|
|
PROPERTY SOURCETEST
|
|
|
|
)
|
2007-06-25 17:51:37 +04:00
|
|
|
|
|
|
|
if (RESULT1 AND RESULT2 AND RESULT3 AND GLOBALRESULT AND
|
2008-01-18 01:19:13 +03:00
|
|
|
DIRECTORYRESULT AND SOURCERESULT)
|
2007-12-17 18:12:22 +03:00
|
|
|
add_executable (Properties SubDir/properties3.cxx properties)
|
2007-06-25 17:51:37 +04:00
|
|
|
else (RESULT1 AND RESULT2 AND RESULT3 AND GLOBALRESULT AND
|
2008-01-18 01:19:13 +03:00
|
|
|
DIRECTORYRESULT AND SOURCERESULT)
|
2008-04-01 22:22:09 +04:00
|
|
|
message(SEND_ERROR
|
|
|
|
"Error: test results are RESULT1=${RESULT1} RESULT2=${RESULT2} "
|
2007-06-25 17:51:37 +04:00
|
|
|
"RESULT3=${RESULT3} GLOBALRESULT=${GLOBALRESULT} "
|
|
|
|
"DIRECTORYRESULT=${DIRECTORYRESULT} "
|
2008-01-18 01:19:13 +03:00
|
|
|
"SOURCERESULT=${SOURCERESULT}")
|
2007-06-25 17:51:37 +04:00
|
|
|
endif (RESULT1 AND RESULT2 AND RESULT3 AND GLOBALRESULT AND
|
2008-01-18 01:19:13 +03:00
|
|
|
DIRECTORYRESULT AND SOURCERESULT)
|
2007-06-25 17:51:37 +04:00
|
|
|
|
|
|
|
# test the target property
|
2008-01-17 23:54:49 +03:00
|
|
|
set_property(TARGET Properties PROPERTY TARGETTEST 1)
|
2008-01-18 01:19:13 +03:00
|
|
|
get_property(TARGETRESULT TARGET Properties PROPERTY TARGETTEST)
|
2007-06-25 17:51:37 +04:00
|
|
|
if (NOT TARGETRESULT)
|
2008-04-01 22:22:09 +04:00
|
|
|
message(SEND_ERROR
|
|
|
|
"Error: target result is TARGETRESULT=${TARGETRESULT}")
|
|
|
|
endif (NOT TARGETRESULT)
|
|
|
|
|
|
|
|
# test get_property SET
|
|
|
|
get_property(TARGETRESULT TARGET Properties PROPERTY TARGETTEST SET)
|
|
|
|
if (NOT TARGETRESULT)
|
|
|
|
message(SEND_ERROR
|
|
|
|
"Error: target prop not set, result is TARGETRESULT=${TARGETRESULT}")
|
2007-06-25 17:51:37 +04:00
|
|
|
endif (NOT TARGETRESULT)
|
2007-12-17 18:12:22 +03:00
|
|
|
|
2008-04-01 22:22:09 +04:00
|
|
|
# test unsetting a property
|
|
|
|
set_property(TARGET Properties PROPERTY TARGETTEST)
|
|
|
|
get_property(TARGETRESULT TARGET Properties PROPERTY TARGETTEST SET)
|
|
|
|
if (TARGETRESULT)
|
|
|
|
message(SEND_ERROR "Error: target prop not unset, "
|
|
|
|
"result is TARGETRESULT=${TARGETRESULT}")
|
|
|
|
endif (TARGETRESULT)
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-12-17 18:12:22 +03:00
|
|
|
# test the target SOURCES property
|
2008-01-18 01:19:13 +03:00
|
|
|
get_property(Properties_SOURCES TARGET Properties PROPERTY SOURCES)
|
2007-12-17 18:12:22 +03:00
|
|
|
set_source_files_properties(${Properties_SOURCES} PROPERTIES TEST4 1)
|
|
|
|
get_source_file_property(RESULT4 properties.h TEST4)
|
|
|
|
if(NOT RESULT4)
|
2008-04-01 22:22:09 +04:00
|
|
|
message(SEND_ERROR "Error: target result is"
|
2007-12-17 18:12:22 +03:00
|
|
|
" RESULT4=${RESULT4}"
|
|
|
|
" Properties_SOURCES=[${Properties_SOURCES}]")
|
|
|
|
endif(NOT RESULT4)
|
2009-03-10 18:10:59 +03:00
|
|
|
|
|
|
|
# test CACHE properties
|
|
|
|
macro(check_cache_props)
|
|
|
|
foreach(prop VALUE TYPE HELPSTRING ADVANCED)
|
|
|
|
get_property(result CACHE SOME_ENTRY PROPERTY ${prop})
|
|
|
|
if(NOT "x${result}" STREQUAL "x${expect_${prop}}")
|
|
|
|
message(SEND_ERROR "CACHE property ${prop} is [${result}], not [${expect_${prop}}]")
|
|
|
|
endif()
|
|
|
|
endforeach(prop)
|
|
|
|
endmacro(check_cache_props)
|
|
|
|
set(expect_VALUE "ON")
|
|
|
|
set(expect_TYPE "BOOL")
|
|
|
|
set(expect_HELPSTRING "sample cache entry")
|
|
|
|
set(expect_ADVANCED 0)
|
|
|
|
set(SOME_ENTRY "${expect_VALUE}" CACHE ${expect_TYPE} "${expect_HELPSTRING}" FORCE)
|
|
|
|
mark_as_advanced(CLEAR SOME_ENTRY)
|
|
|
|
check_cache_props()
|
|
|
|
set(expect_VALUE "Some string")
|
|
|
|
set(expect_TYPE "STRING")
|
|
|
|
set(expect_HELPSTRING "sample cache entry help")
|
|
|
|
set(expect_ADVANCED 1)
|
|
|
|
set_property(CACHE SOME_ENTRY PROPERTY TYPE "${expect_TYPE}")
|
|
|
|
set_property(CACHE SOME_ENTRY PROPERTY HELPSTRING "${expect_HELPSTRING}")
|
|
|
|
set_property(CACHE SOME_ENTRY PROPERTY VALUE "${expect_VALUE}")
|
|
|
|
set_property(CACHE SOME_ENTRY PROPERTY ADVANCED "${expect_ADVANCED}")
|
|
|
|
check_cache_props()
|