CMakeLists.txt 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. cmake_minimum_required (VERSION 2.8.8)
  2. project(GeneratorExpression CXX)
  3. # This test is split into multiple parts as needed to avoid NMake command
  4. # length limits.
  5. add_custom_target(check-part1 ALL
  6. COMMAND ${CMAKE_COMMAND}
  7. -Dtest_0=$<0:nothing>
  8. -Dtest_0_with_comma=$<0:-Wl,--no-undefined>
  9. -Dtest_1=$<1:content>
  10. -Dtest_1_with_comma=$<1:-Wl,--no-undefined>
  11. -Dconfig=$<CONFIGURATION>
  12. -Dtest_and_0=$<AND:0>
  13. -Dtest_and_0_0=$<AND:0,0>
  14. -Dtest_and_0_1=$<AND:0,1>
  15. -Dtest_and_1=$<AND:1>
  16. -Dtest_and_1_0=$<AND:1,0>
  17. -Dtest_and_1_1=$<AND:1,1>
  18. # Ordinarily, the 'invalidcontent' would cause an error, but
  19. # the '0' makes the AND abort early.
  20. -Dtest_and_0_invalidcontent=$<AND:0,invalidcontent>
  21. -Dtest_config_0=$<CONFIG:$<CONFIGURATION>x>
  22. -Dtest_config_1=$<CONFIG:$<CONFIGURATION>>
  23. -Dtest_config_debug=$<CONFIG:Debug>$<CONFIG:DEBUG>$<CONFIG:DeBuG>
  24. -Dtest_config_release=$<CONFIG:Release>$<CONFIG:RELEASE>$<CONFIG:ReLeAsE>
  25. -Dtest_config_relwithdebinfo=$<CONFIG:RelWithDebInfo>$<CONFIG:RELWITHDEBINFO>$<CONFIG:relwithdebinfo>
  26. -Dtest_config_minsizerel=$<CONFIG:MinSizeRel>$<CONFIG:MINSIZEREL>$<CONFIG:minsizerel>
  27. -Dtest_not_0=$<NOT:0>
  28. -Dtest_not_1=$<NOT:1>
  29. -Dtest_or_0=$<OR:0>
  30. -Dtest_or_0_0=$<OR:0,0>
  31. -Dtest_or_0_1=$<OR:0,1>
  32. -Dtest_or_1=$<OR:1>
  33. -Dtest_or_1_0=$<OR:1,0>
  34. -Dtest_or_1_1=$<OR:1,1>
  35. -Dtest_or_1_invalidcontent=$<OR:1,invalidcontent>
  36. -Dtest_bool_notfound=$<BOOL:NOTFOUND>
  37. -Dtest_bool_foo_notfound=$<BOOL:Foo-NOTFOUND>
  38. -Dtest_bool_true=$<BOOL:True>
  39. -Dtest_bool_false=$<BOOL:False>
  40. -Dtest_bool_on=$<BOOL:On>
  41. -Dtest_bool_off=$<BOOL:Off>
  42. -Dtest_bool_no=$<BOOL:No>
  43. -Dtest_bool_n=$<BOOL:N>
  44. -Dtest_bool_empty=$<BOOL:>
  45. -Dtest_strequal_yes_yes=$<STREQUAL:Yes,Yes>
  46. -Dtest_strequal_yes_yes_cs=$<STREQUAL:Yes,yes>
  47. -Dtest_strequal_yes_no=$<STREQUAL:Yes,No>
  48. -Dtest_strequal_no_yes=$<STREQUAL:No,Yes>
  49. -Dtest_strequal_angle_r=$<STREQUAL:$<ANGLE-R>,$<ANGLE-R>>
  50. -Dtest_strequal_comma=$<STREQUAL:$<COMMA>,$<COMMA>>
  51. -Dtest_strequal_semicolon=$<STREQUAL:$<SEMICOLON>,$<SEMICOLON>>
  52. -Dtest_strequal_angle_r_comma=$<STREQUAL:$<ANGLE-R>,$<COMMA>>
  53. -Dtest_strequal_both_empty=$<STREQUAL:,>
  54. -Dtest_strequal_one_empty=$<STREQUAL:something,>
  55. -Dtest_angle_r=$<ANGLE-R>
  56. -Dtest_comma=$<COMMA>
  57. -Dtest_semicolon=$<SEMICOLON>
  58. -Dtest_colons_1=$<1::>
  59. -Dtest_colons_2=$<1:::>
  60. -Dtest_colons_3=$<1:Qt5::Core>
  61. -Dtest_colons_4=$<1:C:\\CMake>
  62. -Dtest_colons_5=$<1:C:/CMake>
  63. -P ${CMAKE_CURRENT_SOURCE_DIR}/check-part1.cmake
  64. COMMAND ${CMAKE_COMMAND} -E echo "check done (part 1 of 3)"
  65. VERBATIM
  66. )
  67. add_library(empty1 empty.cpp)
  68. target_include_directories(empty1 PUBLIC /empty1/public)
  69. target_include_directories(empty1 PRIVATE /empty1/private)
  70. add_library(empty2 empty.cpp)
  71. target_include_directories(empty2 PUBLIC /empty2/public)
  72. add_library(empty3 empty.cpp)
  73. target_include_directories(empty3 PUBLIC /empty3/public)
  74. target_include_directories(empty3 PRIVATE /empty3/private)
  75. add_library(empty4 empty.cpp)
  76. target_include_directories(empty4 PUBLIC /empty4/public)
  77. target_link_libraries(empty1 LINK_PUBLIC empty2)
  78. target_link_libraries(empty2 LINK_PUBLIC empty3 empty4)
  79. target_link_libraries(empty3 LINK_PUBLIC empty2 empty4)
  80. add_library(empty5 empty.cpp)
  81. target_include_directories(empty5 PRIVATE /empty5/private1 /empty5/private2)
  82. add_custom_target(check-part2 ALL
  83. COMMAND ${CMAKE_COMMAND}
  84. -Dtest_incomplete_1=$<
  85. -Dtest_incomplete_2=$<something
  86. -Dtest_incomplete_3=$<something:
  87. -Dtest_incomplete_4=$<something:,
  88. -Dtest_incomplete_5=$something:,>
  89. -Dtest_incomplete_6=<something:,>
  90. -Dtest_incomplete_7=$<something::
  91. -Dtest_incomplete_8=$<something:,
  92. -Dtest_incomplete_9=$<something:,,
  93. -Dtest_incomplete_10=$<something:,:
  94. -Dtest_incomplete_11=$<something,,
  95. -Dtest_incomplete_12=$<,,
  96. -Dtest_incomplete_13=$<some$<1:special>thing
  97. -Dtest_incomplete_14=$<$<ANGLE-R>
  98. -Dtest_incomplete_15=$<some$<thing
  99. -Dtest_incomplete_16=$<BOOL:something
  100. -Dtest_incomplete_17=$<1:some$thing>
  101. -Dtest_incomplete_18=$<1:some,thing
  102. -Dtest_incomplete_19=$<1:some,thing$<ANGLE-R>
  103. -Dtest_incomplete_20=$<CONFIGURATION$<ANGLE-R>
  104. -Dtest_incomplete_21=$<BOOL:something$<ANGLE-R>
  105. -Dtest_build_interface=$<BUILD_INTERFACE:build>
  106. -Dtest_install_interface=$<INSTALL_INTERFACE:install>
  107. -Dtest_target_name_1=$<TARGET_NAME:tgt,ok>
  108. -Dtest_target_name_2=$<TARGET_NAME:tgt:ok>
  109. -Dtest_target_includes1=$<TARGET_PROPERTY:empty1,INTERFACE_INCLUDE_DIRECTORIES>
  110. -Dtest_target_includes2=$<TARGET_PROPERTY:empty2,INTERFACE_INCLUDE_DIRECTORIES>
  111. -Dtest_target_includes3=$<TARGET_PROPERTY:empty3,INTERFACE_INCLUDE_DIRECTORIES>
  112. -Dtest_target_includes4=$<TARGET_PROPERTY:empty1,INCLUDE_DIRECTORIES>
  113. -Dtest_target_includes5=$<TARGET_PROPERTY:empty2,INCLUDE_DIRECTORIES>
  114. -Dtest_target_includes6=$<TARGET_PROPERTY:empty3,INCLUDE_DIRECTORIES>
  115. -Dtest_target_includes7=$<TARGET_PROPERTY:empty1,INTERFACE_INCLUDE_DIRECTORIES>
  116. -Dtest_target_includes8=$<TARGET_PROPERTY:empty5,INCLUDE_DIRECTORIES>
  117. -Dtest_arbitrary_content_comma_1=$<1:a,>
  118. -Dtest_arbitrary_content_comma_2=$<1:,a>
  119. -Dtest_arbitrary_content_comma_3=$<1:a,,>
  120. -Dtest_arbitrary_content_comma_4=$<1:,>
  121. -Dtest_arbitrary_content_comma_5=$<1:,,>
  122. -Dtest_arbitrary_content_comma_6=$<1:,,,>
  123. -Dtest_arbitrary_content_comma_7=$<1:,,a>
  124. -Dtest_arbitrary_content_comma_8=$<1:a,,b>
  125. -Dtest_arbitrary_content_comma_9=$<1:a,,b,,>
  126. -Dtest_arbitrary_content_comma_10=$<1:,,a,,b,,>
  127. -P ${CMAKE_CURRENT_SOURCE_DIR}/check-part2.cmake
  128. COMMAND ${CMAKE_COMMAND} -E echo "check done (part 2 of 3)"
  129. VERBATIM
  130. )
  131. add_library(imported1 SHARED IMPORTED)
  132. set_property(TARGET imported1 PROPERTY IMPORTED_LOCATION_RELEASE release_loc)
  133. set_property(TARGET imported1 PROPERTY IMPORTED_LOCATION_DEBUG debug_loc)
  134. set_property(TARGET imported1 PROPERTY IMPORTED_CONFIGURATIONS RELEASE DEBUG)
  135. set_property(TARGET imported1 PROPERTY INTERFACE_INCLUDE_DIRECTORIES /imported1/include)
  136. add_library(imported2 SHARED IMPORTED)
  137. set_property(TARGET imported2 PROPERTY IMPORTED_LOCATION_RELEASE release_loc)
  138. set_property(TARGET imported2 PROPERTY IMPORTED_LOCATION_DEBUG debug_loc)
  139. set_property(TARGET imported2 PROPERTY IMPORTED_CONFIGURATIONS RELEASE DEBUG)
  140. set_property(TARGET imported2 PROPERTY INTERFACE_INCLUDE_DIRECTORIES /imported2/include)
  141. add_library(imported3 SHARED IMPORTED)
  142. set_property(TARGET imported3 PROPERTY IMPORTED_LOCATION_RELEASE release_loc)
  143. set_property(TARGET imported3 PROPERTY IMPORTED_LOCATION_DEBUG debug_loc)
  144. # Both Debug and Release should not be true when this is evaluated.
  145. set_property(TARGET imported3 APPEND PROPERTY
  146. INTERFACE_INCLUDE_DIRECTORIES $<$<CONFIG:DEBUG>:$<TARGET_PROPERTY:imported1,INTERFACE_INCLUDE_DIRECTORIES>>)
  147. set_property(TARGET imported3 APPEND PROPERTY
  148. INTERFACE_INCLUDE_DIRECTORIES $<$<CONFIG:RELEASE>:$<TARGET_PROPERTY:imported2,INTERFACE_INCLUDE_DIRECTORIES>>)
  149. add_library(imported4 SHARED IMPORTED)
  150. set_property(TARGET imported4 APPEND PROPERTY
  151. INCLUDE_DIRECTORIES $<TARGET_PROPERTY:imported3,INTERFACE_INCLUDE_DIRECTORIES>)
  152. add_executable(someexe empty.cpp)
  153. add_executable(Alias::SomeExe ALIAS someexe)
  154. add_library(Alias::SomeLib ALIAS empty1)
  155. add_custom_target(check-part3 ALL
  156. COMMAND ${CMAKE_COMMAND}
  157. -Dtest_version_greater_1=$<VERSION_GREATER:1.0,1.1.1>
  158. -Dtest_version_greater_2=$<VERSION_GREATER:1.1.1,1.0>
  159. -Dtest_version_less_1=$<VERSION_LESS:1.1.1,1.0>
  160. -Dtest_version_less_2=$<VERSION_LESS:1.0,1.1.1>
  161. -Dtest_version_equal_1=$<VERSION_EQUAL:1.0.1,1.1>
  162. -Dtest_version_equal_2=$<VERSION_EQUAL:1.1,1.1>
  163. -Dconfig=$<CONFIGURATION>
  164. -Dtest_imported_debug=$<TARGET_PROPERTY:imported4,INCLUDE_DIRECTORIES>
  165. -Dtest_imported_release=$<TARGET_PROPERTY:imported4,INCLUDE_DIRECTORIES>
  166. -Dtest_imported_relwithdebinfo=$<TARGET_PROPERTY:imported4,INCLUDE_DIRECTORIES>
  167. -Dtest_imported_minsizerel=$<TARGET_PROPERTY:imported4,INCLUDE_DIRECTORIES>
  168. -Dtest_alias_file_exe=$<STREQUAL:$<TARGET_FILE:Alias::SomeExe>,$<TARGET_FILE:someexe>>
  169. -Dtest_alias_file_lib=$<STREQUAL:$<TARGET_FILE:Alias::SomeLib>,$<TARGET_FILE:empty1>>
  170. -Dtest_alias_target_name=$<STREQUAL:$<TARGET_PROPERTY:Alias::SomeLib,NAME>,$<TARGET_PROPERTY:empty1,NAME>>
  171. -P ${CMAKE_CURRENT_SOURCE_DIR}/check-part3.cmake
  172. COMMAND ${CMAKE_COMMAND} -E echo "check done (part 3 of 3)"
  173. VERBATIM
  174. )