cmake_minimum_required (VERSION 2.8.8) project(GeneratorExpression) include(CTest) # This test is split into multiple parts as needed to avoid NMake command # length limits. add_custom_target(check-part1 ALL COMMAND ${CMAKE_COMMAND} -Dtest_0=$<0:nothing> -Dtest_0_with_comma=$<0:-Wl,--no-undefined> -Dtest_1=$<1:content> -Dtest_1_with_comma=$<1:-Wl,--no-undefined> -Dconfig=$ -Dshort_config=$ -Dtest_and_0=$ -Dtest_and_0_0=$ -Dtest_and_0_1=$ -Dtest_and_1=$ -Dtest_and_1_0=$ -Dtest_and_1_1=$ # Ordinarily, the 'invalidcontent' would cause an error, but # the '0' makes the AND abort early. -Dtest_and_0_invalidcontent=$ -Dtest_config_0=$x> -Dtest_config_1=$> -Dtest_config_debug=$$$ -Dtest_config_release=$$$ -Dtest_config_relwithdebinfo=$$$ -Dtest_config_minsizerel=$$$ -Dtest_not_0=$ -Dtest_not_1=$ -Dtest_or_0=$ -Dtest_or_0_0=$ -Dtest_or_0_1=$ -Dtest_or_1=$ -Dtest_or_1_0=$ -Dtest_or_1_1=$ -Dtest_or_1_invalidcontent=$ -Dtest_bool_notfound=$ -Dtest_bool_foo_notfound=$ -Dtest_bool_true=$ -Dtest_bool_false=$ -Dtest_bool_on=$ -Dtest_bool_off=$ -Dtest_bool_no=$ -Dtest_bool_n=$ -Dtest_bool_empty=$ -Dtest_strequal_yes_yes=$ -Dtest_strequal_yes_yes_cs=$ -Dtest_strequal_yes_no=$ -Dtest_strequal_no_yes=$ -Dtest_strequal_angle_r=$,$> -Dtest_strequal_comma=$,$> -Dtest_strequal_semicolon=$,$> -Dtest_strequal_angle_r_comma=$,$> -Dtest_strequal_both_empty=$ -Dtest_strequal_one_empty=$ -Dtest_angle_r=$ -Dtest_comma=$ -Dtest_semicolon=$ -Dtest_colons_1=$<1::> -Dtest_colons_2=$<1:::> -Dtest_colons_3=$<1:Qt5::Core> -Dtest_colons_4=$<1:C:\\CMake> -Dtest_colons_5=$<1:C:/CMake> -P ${CMAKE_CURRENT_SOURCE_DIR}/check-part1.cmake COMMAND ${CMAKE_COMMAND} -E echo "check done (part 1 of 4)" VERBATIM ) add_library(empty1 empty.cpp) target_include_directories(empty1 PUBLIC /empty1/public) target_include_directories(empty1 PRIVATE /empty1/private) add_library(empty2 empty.cpp) target_include_directories(empty2 PUBLIC /empty2/public) add_library(empty3 empty.cpp) target_include_directories(empty3 PUBLIC /empty3/public) target_include_directories(empty3 PRIVATE /empty3/private) add_library(empty4 empty.cpp) target_include_directories(empty4 PUBLIC /empty4/public) target_link_libraries(empty1 LINK_PUBLIC empty2) target_link_libraries(empty2 LINK_PUBLIC empty3 empty4) target_link_libraries(empty3 LINK_PUBLIC empty2 empty4) add_library(empty5 empty.cpp) target_include_directories(empty5 PRIVATE /empty5/private1 /empty5/private2) add_custom_target(check-part2 ALL COMMAND ${CMAKE_COMMAND} -Dtest_incomplete_1=$< -Dtest_incomplete_2=$ -Dtest_incomplete_6= -Dtest_incomplete_7=$thing -Dtest_incomplete_14=$<$ -Dtest_incomplete_15=$ -Dtest_incomplete_18=$<1:some,thing -Dtest_incomplete_19=$<1:some,thing$ -Dtest_incomplete_20=$ -Dtest_incomplete_21=$ -Dtest_build_interface=$ -Dtest_install_interface=$ -Dtest_target_name_1=$ -Dtest_target_name_2=$ -Dtest_target_includes1=$ -Dtest_target_includes2=$ -Dtest_target_includes3=$ -Dtest_target_includes4=$ -Dtest_target_includes5=$ -Dtest_target_includes6=$ -Dtest_target_includes7=$ -Dtest_target_includes8=$ -Dtest_arbitrary_content_comma_1=$<1:a,> -Dtest_arbitrary_content_comma_2=$<1:,a> -Dtest_arbitrary_content_comma_3=$<1:a,,> -Dtest_arbitrary_content_comma_4=$<1:,> -Dtest_arbitrary_content_comma_5=$<1:,,> -Dtest_arbitrary_content_comma_6=$<1:,,,> -Dtest_arbitrary_content_comma_7=$<1:,,a> -Dtest_arbitrary_content_comma_8=$<1:a,,b> -Dtest_arbitrary_content_comma_9=$<1:a,,b,,> -Dtest_arbitrary_content_comma_10=$<1:,,a,,b,,> -P ${CMAKE_CURRENT_SOURCE_DIR}/check-part2.cmake COMMAND ${CMAKE_COMMAND} -E echo "check done (part 2 of 4)" VERBATIM ) add_library(imported1 SHARED IMPORTED) set_property(TARGET imported1 PROPERTY IMPORTED_LOCATION_RELEASE release_loc) set_property(TARGET imported1 PROPERTY IMPORTED_LOCATION_DEBUG debug_loc) set_property(TARGET imported1 PROPERTY IMPORTED_CONFIGURATIONS RELEASE DEBUG) set_property(TARGET imported1 PROPERTY INTERFACE_INCLUDE_DIRECTORIES /imported1/include) add_library(imported2 SHARED IMPORTED) set_property(TARGET imported2 PROPERTY IMPORTED_LOCATION_RELEASE release_loc) set_property(TARGET imported2 PROPERTY IMPORTED_LOCATION_DEBUG debug_loc) set_property(TARGET imported2 PROPERTY IMPORTED_CONFIGURATIONS RELEASE DEBUG) set_property(TARGET imported2 PROPERTY INTERFACE_INCLUDE_DIRECTORIES /imported2/include) add_library(imported3 SHARED IMPORTED) set_property(TARGET imported3 PROPERTY IMPORTED_LOCATION_RELEASE release_loc) set_property(TARGET imported3 PROPERTY IMPORTED_LOCATION_DEBUG debug_loc) # Both Debug and Release should not be true when this is evaluated. set_property(TARGET imported3 APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES $<$:$>) set_property(TARGET imported3 APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES $<$:$>) add_library(imported4 SHARED IMPORTED) set_property(TARGET imported4 APPEND PROPERTY INCLUDE_DIRECTORIES $) add_executable(someexe $<1:empty.cpp> $<0:does_not_exist>) add_executable(Alias::SomeExe ALIAS someexe) add_library(Alias::SomeLib ALIAS empty1) add_custom_target(check-part3 ALL COMMAND ${CMAKE_COMMAND} -Dtest_version_greater_1=$ -Dtest_version_greater_2=$ -Dtest_version_less_1=$ -Dtest_version_less_2=$ -Dtest_version_equal_1=$ -Dtest_version_equal_2=$ -Dconfig=$ -Dtest_imported_debug=$ -Dtest_imported_release=$ -Dtest_imported_relwithdebinfo=$ -Dtest_imported_minsizerel=$ -Dtest_alias_file_exe=$,$> -Dtest_alias_file_lib=$,$> -Dtest_alias_target_name=$,$> -Dtest_early_termination_1=$<$<1:>: -Dtest_early_termination_2=$<$<1:>:, -Dsystem_name=${CMAKE_HOST_SYSTEM_NAME} -Dtest_platform_id=$ -Dtest_platform_id_Linux=$ -Dtest_platform_id_Windows=$ -Dtest_platform_id_Darwin=$ -Dlower_case=$ -Dupper_case=$ -Dmake_c_identifier=$ -Dequal1=$ -Dequal2=$ -Dequal3=$ -Dequal4=$ -Dequal5=$ -Dequal6=$ -Dequal7=$ -Dequal8=$ -Dequal9=$ -Dequal10=$ -Dequal11=$ -Dequal12=$ -Dequal13=$ -Dequal14=$ -Dequal15=$ -Dequal16=$ -Dequal17=$ -Dequal18=$ -Dequal19=$ -Dequal20=$ -Dequal21=$ -Dequal22=$ -Dequal23=$ -P ${CMAKE_CURRENT_SOURCE_DIR}/check-part3.cmake COMMAND ${CMAKE_COMMAND} -E echo "check done (part 3 of 4)" VERBATIM ) if(WIN32) set(test_shell_path c:/shell/path) else() set(test_shell_path /shell/path) endif() set(path_prefix BYPASS_FURTHER_CONVERSION) add_custom_target(check-part4 ALL COMMAND ${CMAKE_COMMAND} # Prefix path to bypass its further conversion when being processed by # CMake as command-line argument -Dtest_shell_path=${path_prefix}$ -Dpath_prefix=${path_prefix} -DWIN32=${WIN32} -DCMAKE_GENERATOR=${CMAKE_GENERATOR} -P ${CMAKE_CURRENT_SOURCE_DIR}/check-part4.cmake COMMAND ${CMAKE_COMMAND} -E echo "check done (part 4 of 4)" VERBATIM ) #----------------------------------------------------------------------------- # Cover test properties with generator expressions. add_executable(echo echo.c) add_executable(pwd pwd.c) add_test(NAME echo-configuration COMMAND echo $) set_property(TEST echo-configuration PROPERTY PASS_REGULAR_EXPRESSION "^$\n$") add_test(NAME echo-target-file COMMAND echo $) set_property(TEST echo-target-file PROPERTY PASS_REGULAR_EXPRESSION "/echo${CMAKE_EXECUTABLE_SUFFIX}\n$") set_property(TEST echo-target-file PROPERTY REQUIRED_FILES "$") add_test(NAME working-dir-arg WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/WorkingDirectory/$" COMMAND pwd) set_property(TEST working-dir-arg PROPERTY PASS_REGULAR_EXPRESSION "WorkingDirectory/$\n$") foreach(c ${CMAKE_CONFIGURATION_TYPES} ${CMAKE_BUILD_TYPE}) file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/WorkingDirectory/${c}") endforeach() add_test(echo-old-style echo "\$") set_property(TEST echo-old-style PROPERTY PASS_REGULAR_EXPRESSION "^\\$\n$") add_subdirectory(CMP0044 ${CMAKE_BINARY_DIR}/CMP0044-WARN) set(CMP0044_TYPE NEW) add_subdirectory(CMP0044 ${CMAKE_BINARY_DIR}/CMP0044-NEW) set(CMP0044_TYPE OLD) add_subdirectory(CMP0044 ${CMAKE_BINARY_DIR}/CMP0044-OLD)