CMakeLists.txt 107 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739
  1. # a macro for tests that have a simple format where the name matches the
  2. # directory and project
  3. macro(ADD_TEST_MACRO NAME COMMAND)
  4. string(REPLACE "." "/" dir "${NAME}")
  5. string(REGEX REPLACE "[^.]*\\." "" proj "${NAME}")
  6. add_test(${NAME} ${CMAKE_CTEST_COMMAND}
  7. --build-and-test
  8. "${CMake_SOURCE_DIR}/Tests/${dir}"
  9. "${CMake_BINARY_DIR}/Tests/${dir}"
  10. --build-two-config
  11. ${build_generator_args}
  12. --build-project ${proj}
  13. ${${NAME}_CTEST_OPTIONS}
  14. --build-options ${build_options}
  15. ${${NAME}_BUILD_OPTIONS}
  16. --test-command ${COMMAND} ${ARGN})
  17. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${dir}")
  18. endmacro()
  19. include(${CMAKE_CURRENT_SOURCE_DIR}/RegexEscapeString.cmake)
  20. include(${CMAKE_CURRENT_SOURCE_DIR}/CheckFortran.cmake)
  21. # Fake a user home directory to avoid polluting the real one.
  22. if(DEFINED ENV{HOME} AND NOT CTEST_NO_TEST_HOME)
  23. set(TEST_HOME "${CMake_BINARY_DIR}/Tests/CMakeFiles/TestHome")
  24. file(MAKE_DIRECTORY "${TEST_HOME}")
  25. file(WRITE "${TEST_HOME}/.cvspass" ":pserver:[email protected]:/cvsroot/KWSys A\n")
  26. set(TEST_HOME_ENV_CODE "# Fake a user home directory to avoid polluting the real one.
  27. # But provide original ENV{HOME} value in ENV{CTEST_REAL_HOME} for tests that
  28. # need access to the real HOME directory.
  29. set(ENV{CTEST_REAL_HOME} \"\$ENV{HOME}\")
  30. set(ENV{HOME} \"${TEST_HOME}\")
  31. ")
  32. endif()
  33. # Choose a default configuration for CTest tests.
  34. set(CTestTest_CONFIG Debug)
  35. if(NOT CMAKE_CONFIGURATION_TYPES AND CMAKE_BUILD_TYPE)
  36. set(CTestTest_CONFIG ${CMAKE_BUILD_TYPE})
  37. endif()
  38. configure_file(${CMake_SOURCE_DIR}/Tests/EnforceConfig.cmake.in
  39. ${CMake_BINARY_DIR}/Tests/EnforceConfig.cmake @ONLY)
  40. # Testing
  41. if(BUILD_TESTING)
  42. set(CMAKE_TEST_DEVENV "")
  43. if(NOT CMAKE_TEST_DIFFERENT_GENERATOR)
  44. if(CMAKE_TEST_GENERATOR MATCHES "Visual Studio")
  45. set(CMAKE_TEST_MAKEPROGRAM "")
  46. else()
  47. set(CMAKE_TEST_MAKEPROGRAM "${CMAKE_MAKE_PROGRAM}")
  48. endif()
  49. if(CMAKE_TEST_GENERATOR MATCHES "Visual Studio [7-9] " AND
  50. NOT CMAKE_MAKE_PROGRAM MATCHES "[mM][sS][bB][uU][iI][lL][dD]\\.[eE][xX][eE]")
  51. set(CMAKE_TEST_DEVENV "${CMAKE_MAKE_PROGRAM}")
  52. endif()
  53. endif()
  54. if("${CMAKE_TEST_GENERATOR}" MATCHES "Unix Makefiles" OR ("${CMAKE_TEST_GENERATOR}" MATCHES Ninja AND NOT WIN32))
  55. set(TEST_CompileCommandOutput 1)
  56. endif()
  57. set(MAKE_IS_GNU )
  58. if(CMAKE_TEST_MAKEPROGRAM MATCHES make)
  59. execute_process(COMMAND ${CMAKE_TEST_MAKEPROGRAM} no_such_target --version
  60. RESULT_VARIABLE res OUTPUT_VARIABLE out ERROR_VARIABLE out)
  61. if("${res}" STREQUAL "0")
  62. if("${out}" MATCHES "GNU")
  63. set(MAKE_IS_GNU 1)
  64. endif()
  65. endif()
  66. endif()
  67. # some old versions of make simply cannot handle spaces in paths
  68. if (MAKE_IS_GNU OR
  69. CMAKE_TEST_MAKEPROGRAM MATCHES "nmake|gmake|wmake" OR
  70. CMAKE_TEST_GENERATOR MATCHES "Visual Studio|XCode|Borland")
  71. set(MAKE_SUPPORTS_SPACES 1)
  72. else()
  73. set(MAKE_SUPPORTS_SPACES 0)
  74. endif()
  75. set(build_generator_args
  76. --build-generator ${CMAKE_TEST_GENERATOR}
  77. )
  78. if(CMAKE_TEST_GENERATOR_TOOLSET)
  79. list(APPEND build_generator_args
  80. --build-generator-toolset ${CMAKE_TEST_GENERATOR_TOOLSET}
  81. )
  82. endif()
  83. set(build_options)
  84. if(CMAKE_TEST_MAKEPROGRAM)
  85. list(APPEND build_options -DCMAKE_MAKE_PROGRAM:FILEPATH=${CMAKE_TEST_MAKEPROGRAM})
  86. endif()
  87. add_subdirectory(CMakeLib)
  88. add_subdirectory(CMakeOnly)
  89. add_subdirectory(RunCMake)
  90. add_subdirectory(FindPackageModeMakefileTest)
  91. add_subdirectory(CTestTestMemcheck)
  92. # Collect a list of all test build directories.
  93. set(TEST_BUILD_DIRS)
  94. # Should the long tests be run?
  95. option(CMAKE_RUN_LONG_TESTS
  96. "Should the long tests be run (such as Bootstrap)." ON)
  97. mark_as_advanced(CMAKE_RUN_LONG_TESTS)
  98. if (CMAKE_RUN_LONG_TESTS)
  99. option(CTEST_TEST_CTEST
  100. "Should the tests that run a full sub ctest process be run?"
  101. OFF)
  102. mark_as_advanced(CTEST_TEST_CTEST)
  103. endif ()
  104. # Should tests that use CVS be run?
  105. #
  106. set(do_cvs_tests 0)
  107. if(EXISTS ${CMAKE_ROOT}/Modules/FindCVS.cmake)
  108. find_package(CVS QUIET)
  109. else()
  110. find_program(CVS_EXECUTABLE NAMES cvs)
  111. endif()
  112. if(CVS_EXECUTABLE)
  113. set(do_cvs_tests 1)
  114. endif()
  115. if(do_cvs_tests AND NOT UNIX)
  116. if("${CVS_EXECUTABLE}" MATCHES "cygwin")
  117. set(do_cvs_tests 0)
  118. endif()
  119. endif()
  120. # Should CPack tests be run? By default, yes, but...
  121. #
  122. # Disable packaging test on Apple 10.3 and below. PackageMaker starts
  123. # DiskManagementTool as root and disowns it
  124. # (http://lists.apple.com/archives/installer-dev/2005/Jul/msg00005.html).
  125. # It is left holding open pipe handles and preventing ProcessUNIX from
  126. # detecting end-of-data even after its immediate child exits. Then
  127. # the test hangs until it times out and is killed. This is a
  128. # well-known bug in kwsys process execution that I would love to get
  129. # time to fix.
  130. #
  131. option(CTEST_TEST_CPACK
  132. "Should the tests that use '--build-target package' be run?"
  133. ON)
  134. mark_as_advanced(CTEST_TEST_CPACK)
  135. set(CTEST_TEST_OSX_ARCH 0)
  136. if(APPLE)
  137. execute_process(
  138. COMMAND sw_vers -productVersion
  139. OUTPUT_VARIABLE OSX_VERSION
  140. OUTPUT_STRIP_TRAILING_WHITESPACE
  141. )
  142. if(OSX_VERSION MATCHES "^10\\.[0123]" OR OSX_VERSION MATCHES "ProductVersion:\t10\\.[0123]")
  143. message(STATUS "Forcing CTEST_TEST_CPACK=OFF on OSX < 10.4")
  144. message(STATUS "OSX_VERSION='${OSX_VERSION}'")
  145. set(CTEST_TEST_CPACK OFF)
  146. else()
  147. set(CTEST_TEST_OSX_ARCH 1)
  148. endif()
  149. endif()
  150. # Use 1500 or CTEST_TEST_TIMEOUT for long test timeout value,
  151. # whichever is greater.
  152. set(CMAKE_LONG_TEST_TIMEOUT 1500)
  153. if(CTEST_TEST_TIMEOUT)
  154. set(CMAKE_LONG_TEST_TIMEOUT ${CTEST_TEST_TIMEOUT})
  155. endif()
  156. if(CMAKE_LONG_TEST_TIMEOUT LESS 1500)
  157. set(CMAKE_LONG_TEST_TIMEOUT 1500)
  158. endif()
  159. add_test(NAME CMake.Copyright
  160. COMMAND cmake -P ${CMAKE_CURRENT_SOURCE_DIR}/CMakeCopyright.cmake)
  161. # add a bunch of standard build-and-test style tests
  162. ADD_TEST_MACRO(CommandLineTest CommandLineTest)
  163. ADD_TEST_MACRO(FindPackageTest FindPackageTest)
  164. ADD_TEST_MACRO(FindModulesExecuteAll FindModulesExecuteAll)
  165. ADD_TEST_MACRO(StringFileTest StringFileTest)
  166. ADD_TEST_MACRO(TryCompile TryCompile)
  167. ADD_TEST_MACRO(TarTest TarTest)
  168. ADD_TEST_MACRO(SystemInformation SystemInformation)
  169. ADD_TEST_MACRO(MathTest MathTest)
  170. # assume no resources building to test
  171. set(TEST_RESOURCES FALSE)
  172. # for windows and cygwin assume we have resources
  173. if(WIN32 OR CYGWIN)
  174. set(TEST_RESOURCES TRUE)
  175. endif()
  176. # for borland and watcom there is no resource support
  177. if("${CMAKE_TEST_GENERATOR}" MATCHES "WMake" OR
  178. "${CMAKE_TEST_GENERATOR}" MATCHES "Borland")
  179. set(TEST_RESOURCES FALSE)
  180. endif()
  181. if(TEST_RESOURCES)
  182. ADD_TEST_MACRO(VSResource VSResource)
  183. endif()
  184. ADD_TEST_MACRO(Simple Simple)
  185. ADD_TEST_MACRO(PreOrder PreOrder)
  186. ADD_TEST_MACRO(MissingSourceFile MissingSourceFile)
  187. set_tests_properties(MissingSourceFile PROPERTIES
  188. PASS_REGULAR_EXPRESSION "CMake Error at CMakeLists.txt:3 \\(add_executable\\):[ \r\n]*Cannot find source file:[ \r\n]*DoesNotExist/MissingSourceFile.c")
  189. if(CMAKE_Fortran_COMPILER)
  190. ADD_TEST_MACRO(FortranOnly FortranOnly)
  191. endif()
  192. # test Visual Studio GNU Fortran mixing with cmake_add_fortran_subdirectory
  193. # run this project if we have a working fortran compiler or
  194. # the test is enabled with CMAKE_TEST_CMAKE_ADD_FORTRAN cache variable.
  195. # If you enable the test, CMake should find the MinGW fortran install,
  196. # or in some cases you might need to set the PATH so that cmake can find
  197. # the gfortran from mingw.
  198. if(CMAKE_Fortran_COMPILER OR CMAKE_TEST_CMAKE_ADD_FORTRAN)
  199. set(CMAKE_SKIP_VSGNUFortran FALSE)
  200. # disable test for apple builds using ifort if they are building
  201. # more than one architecture, as ifort does not support that.
  202. if(APPLE AND (CMAKE_Fortran_COMPILER MATCHES ifort))
  203. list(LENGTH CMAKE_OSX_ARCHITECTURES len)
  204. if("${len}" GREATER 1)
  205. message(STATUS "Skip VSGNUFortran for ifort dual cpu mac build")
  206. set(CMAKE_SKIP_VSGNUFortran TRUE)
  207. endif()
  208. endif()
  209. if((CMAKE_C_COMPILER MATCHES lsb)
  210. AND (CMAKE_Fortran_COMPILER MATCHES ifort))
  211. message(STATUS "Skip VSGNUFortran for ifort and lsb compilers")
  212. set(CMAKE_SKIP_VSGNUFortran TRUE)
  213. endif()
  214. if(NOT CMAKE_SKIP_VSGNUFortran)
  215. ADD_TEST_MACRO(VSGNUFortran ${CMAKE_COMMAND} -P runtest.cmake)
  216. endif()
  217. endif()
  218. ADD_TEST_MACRO(COnly COnly)
  219. ADD_TEST_MACRO(CxxOnly CxxOnly)
  220. ADD_TEST_MACRO(IPO COnly/COnly)
  221. ADD_TEST_MACRO(OutDir runtime/OutDir)
  222. ADD_TEST_MACRO(ObjectLibrary UseCshared)
  223. ADD_TEST_MACRO(NewlineArgs NewlineArgs)
  224. ADD_TEST_MACRO(SetLang SetLang)
  225. ADD_TEST_MACRO(EmptyProperty EmptyProperty)
  226. ADD_TEST_MACRO(ExternalOBJ ExternalOBJ)
  227. ADD_TEST_MACRO(LoadCommand LoadedCommand)
  228. ADD_TEST_MACRO(LinkDirectory bin/LinkDirectory)
  229. ADD_TEST_MACRO(LinkLanguage LinkLanguage)
  230. ADD_TEST_MACRO(LinkLine LinkLine)
  231. ADD_TEST_MACRO(MacroTest miniMacroTest)
  232. ADD_TEST_MACRO(FunctionTest miniFunctionTest)
  233. ADD_TEST_MACRO(ReturnTest ReturnTest)
  234. ADD_TEST_MACRO(Properties Properties)
  235. ADD_TEST_MACRO(Assembler HelloAsm)
  236. ADD_TEST_MACRO(SourceGroups SourceGroups)
  237. ADD_TEST_MACRO(Preprocess Preprocess)
  238. set(ExportImport_BUILD_OPTIONS -DCMAKE_TEST_MAKEPROGRAM:FILEPATH=${CMAKE_TEST_MAKEPROGRAM})
  239. ADD_TEST_MACRO(ExportImport ExportImport)
  240. ADD_TEST_MACRO(Unset Unset)
  241. ADD_TEST_MACRO(PolicyScope PolicyScope)
  242. ADD_TEST_MACRO(EmptyLibrary EmptyLibrary)
  243. ADD_TEST_MACRO(CompileDefinitions CompileDefinitions)
  244. ADD_TEST_MACRO(CompileOptions CompileOptions)
  245. ADD_TEST_MACRO(CompatibleInterface CompatibleInterface)
  246. ADD_TEST_MACRO(AliasTarget AliasTarget)
  247. ADD_TEST_MACRO(StagingPrefix StagingPrefix)
  248. ADD_TEST_MACRO(InterfaceLibrary InterfaceLibrary)
  249. set_tests_properties(EmptyLibrary PROPERTIES
  250. PASS_REGULAR_EXPRESSION "CMake Error: CMake can not determine linker language for target: test")
  251. ADD_TEST_MACRO(CrossCompile CrossCompile)
  252. set_tests_properties(CrossCompile PROPERTIES
  253. PASS_REGULAR_EXPRESSION "TRY_RUN.. invoked in cross-compiling mode")
  254. if("${CMAKE_TEST_GENERATOR}" MATCHES "Make")
  255. ADD_TEST_MACRO(Policy0002 Policy0002)
  256. endif()
  257. if(CTEST_TEST_OSX_ARCH)
  258. ADD_TEST_MACRO(Architecture Architecture)
  259. set_tests_properties(Architecture PROPERTIES
  260. PASS_REGULAR_EXPRESSION "(file is not of required architecture|does not match cputype|not the architecture being linked)")
  261. endif()
  262. list(APPEND TEST_BUILD_DIRS ${CMake_TEST_INSTALL_PREFIX})
  263. if(NOT QT4_FOUND)
  264. find_package(Qt4 QUIET)
  265. endif()
  266. if(QT4_FOUND)
  267. # test whether the Qt4 which has been found works, on some machines
  268. # which run nightly builds there were errors like "wrong file format"
  269. # for libQtCore.so. So first check it works, and only if it does add
  270. # the automoc test.
  271. include(CheckCXXSourceCompiles)
  272. set(_save_CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES}")
  273. set(_save_CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}")
  274. set(CMAKE_REQUIRED_INCLUDES ${QT_INCLUDES})
  275. set(CMAKE_REQUIRED_LIBRARIES ${QT_QTCORE_LIBRARIES})
  276. CHECK_CXX_SOURCE_COMPILES("#include <QCoreApplication>\n int main() {return (qApp == 0 ? 0 : 1); }\n"
  277. QT4_WORKS)
  278. set(CMAKE_REQUIRED_INCLUDES "${_save_CMAKE_REQUIRED_INCLUDES}")
  279. set(CMAKE_REQUIRED_LIBRARIES "${_save_CMAKE_REQUIRED_LIBRARIES}")
  280. endif()
  281. # run test for BundleUtilities on supported platforms/compilers
  282. if(MSVC OR
  283. MINGW OR
  284. CMAKE_SYSTEM_NAME MATCHES "Linux" OR
  285. CMAKE_SYSTEM_NAME MATCHES "Darwin")
  286. if(NOT "${CMAKE_TEST_GENERATOR}" STREQUAL "Watcom WMake")
  287. add_test(BundleUtilities ${CMAKE_CTEST_COMMAND}
  288. --build-and-test
  289. "${CMake_SOURCE_DIR}/Tests/BundleUtilities"
  290. "${CMake_BINARY_DIR}/Tests/BundleUtilities"
  291. ${build_generator_args}
  292. --build-project BundleUtilities
  293. --build-options ${build_options}
  294. )
  295. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/BundleUtilities")
  296. # run test for DeployQt4 on supported platforms/compilers (which depends on BundleUtilities)
  297. # this test also depends on the existence of the standard qtiff plugin
  298. if(QT4_WORKS AND QT_QTSQL_FOUND)
  299. add_test(Qt4Deploy ${CMAKE_CTEST_COMMAND}
  300. --build-and-test
  301. "${CMake_SOURCE_DIR}/Tests/Qt4Deploy"
  302. "${CMake_BINARY_DIR}/Tests/Qt4Deploy"
  303. ${build_generator_args}
  304. --build-project Qt4Deploy
  305. --build-options ${build_options}
  306. -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
  307. -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}
  308. )
  309. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt4Deploy")
  310. endif()
  311. endif()
  312. endif()
  313. set(CMAKE_BUILD_TEST_SOURCE_DIR "${CMake_SOURCE_DIR}/Tests/COnly")
  314. set(CMAKE_BUILD_TEST_BINARY_DIR "${CMake_BINARY_DIR}/Tests/CMakeBuildCOnly")
  315. set(CMAKE_BUILD_TEST_EXE COnly)
  316. configure_file("${CMake_SOURCE_DIR}/Tests/CMakeBuildTest.cmake.in"
  317. "${CMake_BINARY_DIR}/Tests/CMakeBuildTest.cmake" @ONLY)
  318. add_test(CMakeBuildTest ${CMAKE_CMAKE_COMMAND} -P
  319. "${CMake_BINARY_DIR}/Tests/CMakeBuildTest.cmake")
  320. list(APPEND TEST_BUILD_DIRS ${CMAKE_BUILD_TEST_BINARY_DIR})
  321. # now do it again for a project that has two project commands
  322. set(CMAKE_BUILD_TEST_SOURCE_DIR "${CMake_SOURCE_DIR}/Tests/DoubleProject")
  323. set(CMAKE_BUILD_TEST_BINARY_DIR "${CMake_BINARY_DIR}/Tests/DoubleProject")
  324. set(CMAKE_BUILD_TEST_EXE just_silly)
  325. configure_file("${CMake_SOURCE_DIR}/Tests/CMakeBuildTest.cmake.in"
  326. "${CMake_BINARY_DIR}/Tests/CMakeBuildDoubleProjectTest.cmake" @ONLY)
  327. add_test(CMakeDoubleProject ${CMAKE_CMAKE_COMMAND} -P
  328. "${CMake_BINARY_DIR}/Tests/CMakeBuildDoubleProjectTest.cmake")
  329. list(APPEND TEST_BUILD_DIRS ${CMAKE_BUILD_TEST_BINARY_DIR})
  330. ADD_TEST_MACRO(Module.CheckTypeSize CheckTypeSize)
  331. add_test(Module.ExternalData ${CMAKE_CTEST_COMMAND}
  332. --build-and-test
  333. "${CMake_SOURCE_DIR}/Tests/Module/ExternalData"
  334. "${CMake_BINARY_DIR}/Tests/Module/ExternalData"
  335. ${build_generator_args}
  336. --build-project ExternalDataTest
  337. --build-noclean
  338. --force-new-ctest-process
  339. --build-options ${build_options}
  340. -DMAKE_SUPPORTS_SPACES=${MAKE_SUPPORTS_SPACES}
  341. --test-command ${CMAKE_CTEST_COMMAND} -C \${CTEST_CONFIGURATION_TYPE} -V
  342. )
  343. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Module/ExternalData")
  344. ADD_TEST_MACRO(Module.GenerateExportHeader GenerateExportHeader)
  345. if (APPLE OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")
  346. include(CheckCXXCompilerFlag)
  347. check_cxx_compiler_flag(-fPIE run_pic_test)
  348. else()
  349. if (CMAKE_CXX_COMPILER_ID MATCHES "PGI"
  350. OR CMAKE_CXX_COMPILER_ID MATCHES "PathScale"
  351. OR CMAKE_SYSTEM_NAME MATCHES "IRIX64"
  352. OR CMAKE_CXX_COMPILER_ID MATCHES "Intel")
  353. set(run_pic_test 0)
  354. else()
  355. set(run_pic_test 1)
  356. endif()
  357. endif()
  358. if (run_pic_test)
  359. ADD_TEST_MACRO(PositionIndependentTargets PositionIndependentTargets)
  360. endif()
  361. add_test(LinkFlags-prepare
  362. ${CMAKE_CTEST_COMMAND} -C \${CTEST_CONFIGURATION_TYPE}
  363. --build-and-test
  364. "${CMake_SOURCE_DIR}/Tests/LinkFlags"
  365. "${CMake_BINARY_DIR}/Tests/LinkFlags"
  366. ${build_generator_args}
  367. --build-project LinkFlags
  368. --build-target LinkFlags
  369. --build-options ${build_options}
  370. -DTEST_CONFIG=\${CTEST_CONFIGURATION_TYPE}
  371. )
  372. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/LinkFlags")
  373. macro(ADD_LINK_FLAGS_TEST name depends)
  374. add_test(LinkFlags-${name}
  375. ${CMAKE_CMAKE_COMMAND} --build "${CMake_BINARY_DIR}/Tests/LinkFlags"
  376. --target LinkFlags_${name} --config \${CTEST_CONFIGURATION_TYPE}
  377. )
  378. set_tests_properties(LinkFlags-${name} PROPERTIES
  379. PASS_REGULAR_EXPRESSION "BADFLAG" DEPENDS LinkFlags-${depends})
  380. endmacro()
  381. ADD_LINK_FLAGS_TEST(lib prepare)
  382. ADD_LINK_FLAGS_TEST(dll lib)
  383. ADD_LINK_FLAGS_TEST(mod dll)
  384. ADD_LINK_FLAGS_TEST(exe mod)
  385. ADD_LINK_FLAGS_TEST(lib_config exe)
  386. ADD_LINK_FLAGS_TEST(dll_config lib_config)
  387. ADD_LINK_FLAGS_TEST(mod_config dll_config)
  388. ADD_LINK_FLAGS_TEST(exe_config mod_config)
  389. ADD_LINK_FLAGS_TEST(lib_flags exe_config)
  390. ADD_LINK_FLAGS_TEST(dll_flags lib_flags)
  391. ADD_LINK_FLAGS_TEST(mod_flags dll_flags)
  392. ADD_LINK_FLAGS_TEST(exe_flags mod_flags)
  393. ADD_LINK_FLAGS_TEST(lib_flags_config exe_flags)
  394. ADD_LINK_FLAGS_TEST(dll_flags_config lib_flags_config)
  395. ADD_LINK_FLAGS_TEST(mod_flags_config dll_flags_config)
  396. ADD_LINK_FLAGS_TEST(exe_flags_config mod_flags_config)
  397. # If we are running right now with a UnixMakefiles based generator,
  398. # build the "Simple" test with the ExtraGenerators, if available
  399. # This doesn't test whether the generated project files work (unfortunately),
  400. # mainly it tests that cmake doesn't crash when generating these project files.
  401. if(${CMAKE_TEST_GENERATOR} MATCHES "Unix Makefiles" OR ${CMAKE_TEST_GENERATOR} MATCHES "KDevelop")
  402. # check which generators we have
  403. execute_process(COMMAND ${CMAKE_CMAKE_COMMAND} --help
  404. OUTPUT_VARIABLE cmakeOutput ERROR_VARIABLE cmakeOutput)
  405. # check for the Eclipse generator
  406. if ("${cmakeOutput}" MATCHES Eclipse)
  407. add_test(Simple_EclipseGenerator ${CMAKE_CTEST_COMMAND}
  408. --build-and-test
  409. "${CMake_SOURCE_DIR}/Tests/Simple"
  410. "${CMake_BINARY_DIR}/Tests/Simple_EclipseGenerator"
  411. --build-two-config
  412. --build-generator "Eclipse CDT4 - Unix Makefiles"
  413. --build-generator-toolset "${CMAKE_TEST_GENERATOR_TOOLSET}"
  414. --build-project Simple
  415. --build-options ${build_options}
  416. --test-command Simple)
  417. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Simple_EclipseGenerator")
  418. endif ()
  419. # check for the CodeBlocks generator
  420. if ("${cmakeOutput}" MATCHES CodeBlocks)
  421. add_test(Simple_CodeBlocksGenerator ${CMAKE_CTEST_COMMAND}
  422. --build-and-test
  423. "${CMake_SOURCE_DIR}/Tests/Simple"
  424. "${CMake_BINARY_DIR}/Tests/Simple_CodeBlocksGenerator"
  425. --build-two-config
  426. --build-generator "CodeBlocks - Unix Makefiles"
  427. --build-generator-toolset "${CMAKE_TEST_GENERATOR_TOOLSET}"
  428. --build-project Simple
  429. --build-options ${build_options}
  430. --test-command Simple)
  431. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Simple_CodeBlocksGenerator")
  432. endif ()
  433. # check for the KDevelop3 generator
  434. if ("${cmakeOutput}" MATCHES KDevelop3)
  435. add_test(Simple_KDevelop3Generator ${CMAKE_CTEST_COMMAND}
  436. --build-and-test
  437. "${CMake_SOURCE_DIR}/Tests/Simple"
  438. "${CMake_BINARY_DIR}/Tests/Simple_KDevelop3Generator"
  439. --build-two-config
  440. --build-generator "KDevelop3 - Unix Makefiles"
  441. --build-generator-toolset "${CMAKE_TEST_GENERATOR_TOOLSET}"
  442. --build-project Simple
  443. --build-options ${build_options}
  444. --test-command Simple)
  445. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Simple_KDevelop3Generator")
  446. endif ()
  447. endif()
  448. # test for correct sub-project generation
  449. # not implemented in VS 6, VS 7.0, Xcode, or Ninja
  450. if(NOT CMAKE_TEST_GENERATOR MATCHES "Visual Studio [67]$|Xcode|Ninja")
  451. # run cmake and configure all of SubProject
  452. # but only build the independent executable car
  453. add_test(SubProject ${CMAKE_CTEST_COMMAND}
  454. --build-and-test
  455. "${CMake_SOURCE_DIR}/Tests/SubProject"
  456. "${CMake_BINARY_DIR}/Tests/SubProject"
  457. --build-project SubProject
  458. ${build_generator_args}
  459. --build-target car
  460. --build-options ${build_options}
  461. --test-command car
  462. )
  463. # For stage 2, do not run cmake again.
  464. # Then build the foo sub project which should build
  465. # the bar library which should be referenced because
  466. # foo links to the static library bar, but bar is not
  467. # directly in the foo sub project
  468. if(CMAKE_TEST_MAKEPROGRAM)
  469. set(SubProject-Stage2_BUILD_MAKEPROGRAM
  470. --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM}
  471. )
  472. endif()
  473. add_test(SubProject-Stage2 ${CMAKE_CTEST_COMMAND}
  474. --build-and-test
  475. "${CMake_SOURCE_DIR}/Tests/SubProject/foo"
  476. "${CMake_BINARY_DIR}/Tests/SubProject/foo"
  477. --build-generator ${CMAKE_TEST_GENERATOR}
  478. --build-generator-toolset "${CMAKE_TEST_GENERATOR_TOOLSET}"
  479. ${SubProject-Stage2_BUILD_MAKEPROGRAM}
  480. --build-nocmake
  481. --build-project foo
  482. --build-target foo
  483. --build-exe-dir "${CMake_BINARY_DIR}/Tests/SubProject/foo"
  484. --build-options ${build_options}
  485. --test-command foo
  486. )
  487. set_tests_properties ( SubProject-Stage2 PROPERTIES DEPENDS SubProject)
  488. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/SubProject")
  489. endif()
  490. # macro to add a test that will build a nightly release
  491. # of CMake for given platform using the release scripts
  492. macro(ADD_NIGHTLY_BUILD_TEST name script)
  493. set(_TEST_DIR "${CMake_BINARY_DIR}/Tests/${name}")
  494. file(MAKE_DIRECTORY "${_TEST_DIR}")
  495. file(WRITE "${_TEST_DIR}/nightly-cmake.sh"
  496. "cd ${_TEST_DIR}
  497. ${CMake_BINARY_DIR}/bin/cmake -DCMAKE_CREATE_VERSION=nightly -P ${CMake_SOURCE_DIR}/Utilities/Release/${script}
  498. ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/Release/upload_release.cmake
  499. ")
  500. add_test(${name} /bin/sh ${_TEST_DIR}/nightly-cmake.sh)
  501. if(COMMAND SET_TESTS_PROPERTIES AND COMMAND GET_TEST_PROPERTY)
  502. set_tests_properties (${name} PROPERTIES TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT})
  503. endif()
  504. endmacro()
  505. if(CMAKE_BUILD_NIGHTLY_RELEASES)
  506. ADD_NIGHTLY_BUILD_TEST(CMakeNightlyWindows
  507. dash2win64_release.cmake)
  508. ADD_NIGHTLY_BUILD_TEST(CMakeNightlyMac
  509. dashmacmini2_release.cmake)
  510. ADD_NIGHTLY_BUILD_TEST(CMakeNightlyMac64
  511. dashmacmini5_release.cmake)
  512. ADD_NIGHTLY_BUILD_TEST(CMakeNightlyLinux
  513. magrathea_release.cmake)
  514. endif()
  515. # add tests with more complex invocations
  516. add_test(Framework ${CMAKE_CTEST_COMMAND}
  517. --build-and-test
  518. "${CMake_SOURCE_DIR}/Tests/Framework"
  519. "${CMake_BINARY_DIR}/Tests/Framework"
  520. --build-two-config
  521. ${build_generator_args}
  522. --build-project Framework
  523. --build-options ${build_options}
  524. "-DCMAKE_INSTALL_PREFIX:PATH=${CMake_BINARY_DIR}/Tests/Framework/Install"
  525. --test-command bar)
  526. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Framework")
  527. add_test(TargetName ${CMAKE_CTEST_COMMAND}
  528. --build-and-test
  529. "${CMake_SOURCE_DIR}/Tests/TargetName"
  530. "${CMake_BINARY_DIR}/Tests/TargetName"
  531. --build-two-config
  532. ${build_generator_args}
  533. --build-project TargetName
  534. --build-options ${build_options}
  535. --test-command ${CMAKE_CMAKE_COMMAND} -E compare_files
  536. ${CMake_SOURCE_DIR}/Tests/TargetName/scripts/hello_world
  537. ${CMake_BINARY_DIR}/Tests/TargetName/scripts/hello_world)
  538. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/TargetName")
  539. add_test(LibName ${CMAKE_CTEST_COMMAND}
  540. --build-and-test
  541. "${CMake_SOURCE_DIR}/Tests/LibName"
  542. "${CMake_BINARY_DIR}/Tests/LibName"
  543. --build-two-config
  544. ${build_generator_args}
  545. --build-project LibName
  546. --build-exe-dir "${CMake_BINARY_DIR}/Tests/LibName/lib"
  547. --build-options ${build_options}
  548. --test-command foobar
  549. )
  550. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/LibName")
  551. add_test(CustComDepend ${CMAKE_CTEST_COMMAND}
  552. --build-and-test
  553. "${CMake_SOURCE_DIR}/Tests/CustComDepend"
  554. "${CMake_BINARY_DIR}/Tests/CustComDepend"
  555. --build-two-config
  556. ${build_generator_args}
  557. --build-project CustComDepend
  558. --build-exe-dir "${CMake_BINARY_DIR}/Tests/CustComDepend/bin"
  559. --build-options ${build_options}
  560. --test-command foo bar.c
  561. )
  562. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CustComDepend")
  563. add_test(ArgumentExpansion ${CMAKE_CTEST_COMMAND}
  564. --build-and-test
  565. "${CMake_SOURCE_DIR}/Tests/ArgumentExpansion"
  566. "${CMake_BINARY_DIR}/Tests/ArgumentExpansion"
  567. ${build_generator_args}
  568. --build-project ArgumentExpansion
  569. --build-exe-dir "${CMake_BINARY_DIR}/Tests/ArgumentExpansion/bin"
  570. --build-options ${build_options}
  571. )
  572. set_tests_properties(ArgumentExpansion PROPERTIES
  573. FAIL_REGULAR_EXPRESSION "Unexpected: ")
  574. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/ArgumentExpansion")
  575. add_test(GeneratorExpression ${CMAKE_CTEST_COMMAND}
  576. --build-and-test
  577. "${CMake_SOURCE_DIR}/Tests/GeneratorExpression"
  578. "${CMake_BINARY_DIR}/Tests/GeneratorExpression"
  579. ${build_generator_args}
  580. --build-project GeneratorExpression
  581. --build-options ${build_options}
  582. -DCMAKE_BUILD_TYPE=\${CTEST_CONFIGURATION_TYPE}
  583. --test-command ${CMAKE_CTEST_COMMAND} -C \${CTEST_CONFIGURATION_TYPE} -V
  584. )
  585. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/GeneratorExpression")
  586. add_test(CustomCommand ${CMAKE_CTEST_COMMAND}
  587. --build-and-test
  588. "${CMake_SOURCE_DIR}/Tests/CustomCommand"
  589. "${CMake_BINARY_DIR}/Tests/CustomCommand"
  590. --build-two-config
  591. ${build_generator_args}
  592. --build-project CustomCommand
  593. --build-exe-dir "${CMake_BINARY_DIR}/Tests/CustomCommand/bin"
  594. --build-options ${build_options}
  595. --test-command CustomCommand
  596. )
  597. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CustomCommand")
  598. ADD_TEST_MACRO(EmptyDepends ${CMAKE_CTEST_COMMAND})
  599. add_test(CustomCommandWorkingDirectory ${CMAKE_CTEST_COMMAND}
  600. --build-and-test
  601. "${CMake_SOURCE_DIR}/Tests/CustomCommandWorkingDirectory"
  602. "${CMake_BINARY_DIR}/Tests/CustomCommandWorkingDirectory"
  603. --build-two-config
  604. ${build_generator_args}
  605. --build-project TestWorkingDir
  606. --build-options ${build_options}
  607. --test-command working
  608. )
  609. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CustomCommandWorkingDirectory")
  610. #add_test(SimpleExclude ${CMAKE_CTEST_COMMAND}
  611. # --build-and-test
  612. # "${CMake_SOURCE_DIR}/Tests/SimpleExclude"
  613. # "${CMake_BINARY_DIR}/Tests/SimpleExclude"
  614. # ${build_generator_args}
  615. # --build-project SimpleExclude
  616. # --build-two-config
  617. # --build-options ${build_options}
  618. # --test-command t4
  619. #--test-command "${CMAKE_COMMAND}"
  620. #"-DCONFIGURATION=\${CTEST_CONFIGURATION_TYPE}"
  621. #-P "${CMake_BINARY_DIR}/Tests/SimpleExclude/run.cmake"
  622. #)
  623. # add_test(SameName ${CMAKE_CTEST_COMMAND}
  624. # --build-and-test
  625. # "${CMake_SOURCE_DIR}/Tests/SameName"
  626. # "${CMake_BINARY_DIR}/Tests/SameName"
  627. # ${build_generator_args}
  628. # --build-project SameName
  629. # --build-two-config
  630. # --build-options ${build_options}
  631. # --test-command
  632. # "${CMake_BINARY_DIR}/Tests/SameName/Exe1/mytest2")
  633. add_test(OutOfSource ${CMAKE_CTEST_COMMAND}
  634. --build-and-test
  635. "${CMake_SOURCE_DIR}/Tests/OutOfSource"
  636. "${CMake_BINARY_DIR}/Tests/OutOfSource"
  637. ${build_generator_args}
  638. --build-project OutOfSource
  639. --build-two-config
  640. --build-options ${build_options}
  641. --test-command
  642. "${CMake_BINARY_DIR}/Tests/OutOfSource/SubDir/OutOfSourceSubdir/simple")
  643. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/OutOfSource")
  644. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/OutOfSourceDeep")
  645. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/OutOfBinary")
  646. add_test(BuildDepends ${CMAKE_CTEST_COMMAND}
  647. --build-and-test
  648. "${CMake_SOURCE_DIR}/Tests/BuildDepends"
  649. "${CMake_BINARY_DIR}/Tests/BuildDepends"
  650. ${build_generator_args}
  651. --build-project BuildDepends
  652. --build-options ${build_options}
  653. )
  654. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/BuildDepends")
  655. set(SimpleInstallInstallDir
  656. "${CMake_BINARY_DIR}/Tests/SimpleInstall/InstallDirectory")
  657. add_test(SimpleInstall ${CMAKE_CTEST_COMMAND}
  658. --build-and-test
  659. "${CMake_SOURCE_DIR}/Tests/SimpleInstall"
  660. "${CMake_BINARY_DIR}/Tests/SimpleInstall"
  661. ${build_generator_args}
  662. --build-project TestSimpleInstall
  663. --build-two-config
  664. --build-options ${build_options}
  665. "-DCMAKE_INSTALL_PREFIX:PATH=${SimpleInstallInstallDir}"
  666. "-DCTEST_TEST_CPACK:BOOL=${CTEST_TEST_CPACK}"
  667. --test-command ${SimpleInstallInstallDir}/MyTest/bin/SimpleInstExe)
  668. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/SimpleInstall")
  669. add_test(SimpleInstall-Stage2 ${CMAKE_CTEST_COMMAND}
  670. --build-and-test
  671. "${CMake_SOURCE_DIR}/Tests/SimpleInstallS2"
  672. "${CMake_BINARY_DIR}/Tests/SimpleInstallS2"
  673. ${build_generator_args}
  674. --build-project TestSimpleInstall
  675. --build-two-config
  676. --build-options ${build_options}
  677. "-DCMAKE_INSTALL_PREFIX:PATH=${SimpleInstallInstallDir}"
  678. "-DSTAGE2:BOOL=1"
  679. --test-command ${SimpleInstallInstallDir}/MyTest/bin/SimpleInstExeS2)
  680. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/SimpleInstallS2")
  681. # By default, run the CPackComponents test if the CTEST_TEST_CPACK
  682. # option is ON:
  683. #
  684. set(CTEST_RUN_CPackComponents ${CTEST_TEST_CPACK})
  685. set(CTEST_package_X11_TEST ${CTEST_TEST_CPACK})
  686. set(CTEST_RUN_CPackComponentsForAll ${CTEST_TEST_CPACK})
  687. if (CMAKE_SYSTEM_NAME MATCHES "Linux" AND NOT CMAKE_CURRENT_BINARY_DIR MATCHES ".* .*")
  688. find_program(RPMBUILD NAMES rpmbuild)
  689. endif()
  690. # Do not try to build RPM
  691. if (NOT RPMBUILD)
  692. set(CPACK_BINARY_RPM OFF)
  693. endif()
  694. find_program(NSIS_MAKENSIS_EXECUTABLE NAMES makensis
  695. PATHS [HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS]
  696. DOC "makensis program location"
  697. )
  698. # But on Windows, only run the CPackComponents test if the NSIS
  699. # installer builder is available:
  700. #
  701. if(WIN32)
  702. if(NSIS_MAKENSIS_EXECUTABLE)
  703. set(CTEST_RUN_CPackComponents ON)
  704. else()
  705. set(CTEST_RUN_CPackComponents OFF)
  706. set(CTEST_package_X11_TEST OFF)
  707. endif()
  708. endif()
  709. # On Windows run the CPackWiXGenerator test
  710. # if the WiX Toolset seems to be available
  711. if(WIN32)
  712. file(TO_CMAKE_PATH "$ENV{WIX}" WIX_ROOT)
  713. find_program(WIX_LIGHT_EXECUTABLE light
  714. PATHS "${WIX_ROOT}/bin"
  715. DOC "WiX Toolset light.exe location")
  716. if(WIX_LIGHT_EXECUTABLE)
  717. add_test(CPackWiXGenerator ${CMAKE_CTEST_COMMAND}
  718. --build-and-test
  719. "${CMake_SOURCE_DIR}/Tests/CPackWiXGenerator"
  720. "${CMake_BINARY_DIR}/Tests/CPackWiXGenerator"
  721. ${build_generator_args}
  722. --build-project CPackWiXGenerator
  723. --build-options ${build_options}
  724. --test-command ${CMAKE_CMAKE_COMMAND}
  725. "-DCPackWiXGenerator_BINARY_DIR:PATH=${CMake_BINARY_DIR}/Tests/CPackWiXGenerator"
  726. -P "${CMake_SOURCE_DIR}/Tests/CPackWiXGenerator/RunCPackVerifyResult.cmake")
  727. endif()
  728. endif()
  729. if(CTEST_RUN_CPackComponents)
  730. set(CPackComponents_BUILD_OPTIONS)
  731. if(APPLE)
  732. set(CPackComponents_BUILD_OPTIONS -DCPACK_BINARY_DRAGNDROP:BOOL=ON)
  733. endif()
  734. if(NSIS_MAKENSIS_EXECUTABLE)
  735. set(CPackComponents_BUILD_OPTIONS ${CPackComponents_BUILD_OPTIONS}
  736. -DCPACK_BINARY_NSIS:BOOL=ON)
  737. endif()
  738. add_test(CPackComponents ${CMAKE_CTEST_COMMAND}
  739. --build-and-test
  740. "${CMake_SOURCE_DIR}/Tests/CPackComponents"
  741. "${CMake_BINARY_DIR}/Tests/CPackComponents"
  742. ${build_generator_args}
  743. --build-project CPackComponents
  744. --build-two-config
  745. --build-target package
  746. --build-options ${build_options}
  747. -DCPACK_BINARY_DEB:BOOL=${CPACK_BINARY_DEB}
  748. -DCPACK_BINARY_RPM:BOOL=${CPACK_BINARY_RPM}
  749. ${CPackComponents_BUILD_OPTIONS}
  750. --graphviz=CPackComponents.dot
  751. --test-command ${CMAKE_CMAKE_COMMAND}
  752. "-DCPackComponents_BINARY_DIR:PATH=${CMake_BINARY_DIR}/Tests/CPackComponents"
  753. -P "${CMake_SOURCE_DIR}/Tests/CPackComponents/VerifyResult.cmake")
  754. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CPackComponents")
  755. endif()
  756. if(CTEST_RUN_CPackComponentsForAll)
  757. # Check whether if rpmbuild command is found
  758. # before adding RPM tests
  759. find_program(RPMBUILD_EXECUTABLE NAMES rpmbuild)
  760. if(RPMBUILD_EXECUTABLE)
  761. list(APPEND ACTIVE_CPACK_GENERATORS RPM)
  762. endif()
  763. # Check whether if dpkg command is found
  764. # before adding DEB tests
  765. find_program(DPKG_EXECUTABLE NAMES dpkg)
  766. if(DPKG_EXECUTABLE)
  767. list(APPEND ACTIVE_CPACK_GENERATORS DEB)
  768. endif()
  769. # ACTIVE_CPACK_GENERATORS variable
  770. # now contains the list of 'active generators'
  771. set(CPackComponentsForAll_BUILD_OPTIONS)
  772. # set up list of CPack generators
  773. list(APPEND GENLST "ZIP")
  774. if(APPLE)
  775. list(APPEND GENLST "DragNDrop")
  776. endif()
  777. if (NOT CMAKE_CURRENT_BINARY_DIR MATCHES ".* .*")
  778. list(FIND ACTIVE_CPACK_GENERATORS "RPM" RPM_ACTIVE)
  779. if (NOT ${RPM_ACTIVE} EQUAL -1)
  780. list(APPEND GENLST "RPM")
  781. endif()
  782. endif()
  783. list(FIND ACTIVE_CPACK_GENERATORS "DEB" DEB_ACTIVE)
  784. if (NOT ${DEB_ACTIVE} EQUAL -1)
  785. list(APPEND GENLST "DEB")
  786. endif()
  787. # set up list of component packaging ways
  788. list(APPEND CWAYLST "default")
  789. list(APPEND CWAYLST "OnePackPerGroup")
  790. list(APPEND CWAYLST "IgnoreGroup")
  791. list(APPEND CWAYLST "AllInOne")
  792. foreach(CPackGen ${GENLST})
  793. set(CPackRun_CPackGen "-DCPackGen=${CPackGen}")
  794. foreach(CPackComponentWay ${CWAYLST})
  795. set(CPackRun_CPackComponentWay "-DCPackComponentWay=${CPackComponentWay}")
  796. add_test(CPackComponentsForAll-${CPackGen}-${CPackComponentWay} ${CMAKE_CTEST_COMMAND}
  797. --build-and-test
  798. "${CMake_SOURCE_DIR}/Tests/CPackComponentsForAll"
  799. "${CMake_BINARY_DIR}/Tests/CPackComponentsForAll/build${CPackGen}-${CPackComponentWay}"
  800. ${build_generator_args}
  801. --build-project CPackComponentsForAll
  802. --build-options ${build_options}
  803. -DCPACK_BINARY_${CPackGen}:BOOL=ON
  804. ${CPackRun_CPackComponentWay}
  805. ${CPackComponentsForAll_BUILD_OPTIONS}
  806. --graphviz=CPackComponentsForAll.dot
  807. --test-command ${CMAKE_CMAKE_COMMAND}
  808. "-DCPackComponentsForAll_BINARY_DIR:PATH=${CMake_BINARY_DIR}/Tests/CPackComponentsForAll/build${CPackGen}-${CPackComponentWay}"
  809. "${CPackRun_CPackGen}"
  810. "${CPackRun_CPackComponentWay}"
  811. -P "${CMake_SOURCE_DIR}/Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake")
  812. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CPackComponentsForAll/build${CPackGen}-${CPackComponentWay}")
  813. endforeach()
  814. endforeach()
  815. endif()
  816. # By default, turn this test off (because it takes a long time...)
  817. #
  818. if(NOT DEFINED CTEST_RUN_CPackTestAllGenerators)
  819. set(CTEST_RUN_CPackTestAllGenerators OFF)
  820. # ...but: if it appears to be a coverage dashboard, or long tests are
  821. # on, then set it to the generic CTEST_TEST_CPACK setting.
  822. #
  823. if(CMAKE_CXX_FLAGS MATCHES "-ftest-coverage" OR
  824. NOT "$ENV{COVFILE}" STREQUAL "" OR
  825. CMAKE_RUN_LONG_TESTS)
  826. set(CTEST_RUN_CPackTestAllGenerators ${CTEST_TEST_CPACK})
  827. endif()
  828. endif()
  829. if(CTEST_RUN_CPackTestAllGenerators)
  830. add_test(CPackTestAllGenerators ${CMAKE_CTEST_COMMAND}
  831. --build-and-test
  832. "${CMake_SOURCE_DIR}/Tests/CPackTestAllGenerators"
  833. "${CMake_BINARY_DIR}/Tests/CPackTestAllGenerators"
  834. ${build_generator_args}
  835. --build-project CPackTestAllGenerators
  836. --build-options ${build_options}
  837. --test-command
  838. ${CMAKE_CMAKE_COMMAND}
  839. -D dir=${CMake_BINARY_DIR}/Tests/CPackTestAllGenerators
  840. -P ${CMake_SOURCE_DIR}/Tests/CPackTestAllGenerators/RunCPack.cmake
  841. )
  842. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CPackTestAllGenerators")
  843. endif()
  844. if(CTEST_package_X11_TEST)
  845. set(X11_build_target_arg --build-target package)
  846. else()
  847. set(X11_build_target_arg)
  848. endif()
  849. add_test(X11 ${CMAKE_CTEST_COMMAND}
  850. --build-and-test
  851. "${CMake_SOURCE_DIR}/Tests/X11"
  852. "${CMake_BINARY_DIR}/Tests/X11"
  853. ${build_generator_args}
  854. --build-project UseX11
  855. --build-two-config
  856. ${X11_build_target_arg}
  857. --build-options ${build_options}
  858. --test-command UseX11)
  859. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/X11")
  860. if(NOT DEFINED CTEST_RUN_CMakeTestAllGenerators)
  861. set(CTEST_RUN_CMakeTestAllGenerators ON)
  862. endif()
  863. if(CTEST_RUN_CMakeTestAllGenerators)
  864. add_test(CMakeTestAllGenerators ${CMAKE_CMAKE_COMMAND}
  865. -D dir=${CMake_BINARY_DIR}/Tests/CMakeTestAllGenerators
  866. -D CMake_SOURCE_DIR=${CMake_SOURCE_DIR}
  867. -P ${CMake_SOURCE_DIR}/Tests/CMakeTestAllGenerators/RunCMake.cmake
  868. )
  869. list(APPEND TEST_BUILD_DIRS
  870. "${CMake_BINARY_DIR}/Tests/CMakeTestAllGenerators")
  871. endif()
  872. if(NOT DEFINED CTEST_RUN_CMakeTestBadCommandLines)
  873. set(CTEST_RUN_CMakeTestBadCommandLines ON)
  874. endif()
  875. if(CTEST_RUN_CMakeTestBadCommandLines)
  876. add_test(CMakeTestBadCommandLines ${CMAKE_CMAKE_COMMAND}
  877. -D dir=${CMake_BINARY_DIR}/Tests/CMakeTestBadCommandLines
  878. -D gen=${CMAKE_TEST_GENERATOR}
  879. -D CMake_SOURCE_DIR=${CMake_SOURCE_DIR}
  880. -P ${CMake_SOURCE_DIR}/Tests/CMakeTestBadCommandLines/RunCMake.cmake
  881. )
  882. list(APPEND TEST_BUILD_DIRS
  883. "${CMake_BINARY_DIR}/Tests/CMakeTestBadCommandLines")
  884. endif()
  885. if(NOT DEFINED CTEST_RUN_CMakeTestMultipleConfigures)
  886. set(CTEST_RUN_CMakeTestMultipleConfigures ON)
  887. endif()
  888. if(CTEST_RUN_CMakeTestMultipleConfigures)
  889. add_test(CMakeTestMultipleConfigures ${CMAKE_CMAKE_COMMAND}
  890. -D dir=${CMake_BINARY_DIR}/Tests/CMakeTestMultipleConfigures
  891. -D gen=${CMAKE_TEST_GENERATOR}
  892. -D CMake_SOURCE_DIR=${CMake_SOURCE_DIR}
  893. -P ${CMake_SOURCE_DIR}/Tests/CMakeTestMultipleConfigures/RunCMake.cmake
  894. )
  895. list(APPEND TEST_BUILD_DIRS
  896. "${CMake_BINARY_DIR}/Tests/CMakeTestMultipleConfigures")
  897. endif()
  898. add_test(LoadedCommandOneConfig ${CMAKE_CTEST_COMMAND}
  899. --build-and-test
  900. "${CMake_SOURCE_DIR}/Tests/LoadCommandOneConfig"
  901. "${CMake_BINARY_DIR}/Tests/LoadCommandOneConfig"
  902. ${build_generator_args}
  903. --build-project LoadCommand
  904. --build-options ${build_options}
  905. --test-command LoadedCommand
  906. )
  907. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/LoadCommandOneConfig")
  908. add_test(complex ${CMAKE_CTEST_COMMAND}
  909. --build-and-test
  910. "${CMake_SOURCE_DIR}/Tests/Complex"
  911. "${CMake_BINARY_DIR}/Tests/Complex"
  912. --build-two-config
  913. --build-config-sample "${CMAKE_CTEST_COMMAND}"
  914. ${build_generator_args}
  915. --build-project Complex
  916. --build-exe-dir "${CMake_BINARY_DIR}/Tests/Complex/bin"
  917. --build-options ${build_options}
  918. -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
  919. --test-command complex
  920. )
  921. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Complex")
  922. add_test(complexOneConfig ${CMAKE_CTEST_COMMAND}
  923. --build-and-test
  924. "${CMake_SOURCE_DIR}/Tests/ComplexOneConfig"
  925. "${CMake_BINARY_DIR}/Tests/ComplexOneConfig"
  926. ${build_generator_args}
  927. --build-project Complex
  928. --build-exe-dir "${CMake_BINARY_DIR}/Tests/ComplexOneConfig/bin"
  929. --build-options ${build_options}
  930. -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
  931. --test-command complex)
  932. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/ComplexOneConfig")
  933. # because of the registry write these tests depend on each other
  934. set_tests_properties ( complex PROPERTIES DEPENDS complexOneConfig)
  935. add_test(Example ${CMAKE_CTEST_COMMAND}
  936. --build-and-test
  937. "${CMake_SOURCE_DIR}/Example"
  938. "${CMake_BINARY_DIR}/Example"
  939. ${build_generator_args}
  940. --build-project HELLO
  941. --build-exe-dir "${CMake_BINARY_DIR}/Example/Demo"
  942. --build-options ${build_options}
  943. --test-command helloDemo
  944. )
  945. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Example")
  946. add_test(Environment ${CMAKE_CTEST_COMMAND}
  947. --build-and-test
  948. "${CMake_SOURCE_DIR}/Tests/Environment"
  949. "${CMake_BINARY_DIR}/Tests/Environment"
  950. ${build_generator_args}
  951. --build-project EnvironmentProj
  952. --build-exe-dir "${CMake_BINARY_DIR}/Tests/Environment"
  953. --force-new-ctest-process
  954. --build-options ${build_options}
  955. --test-command ${CMAKE_CTEST_COMMAND} -V
  956. )
  957. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Environment")
  958. add_test(QtAutomocNoQt ${CMAKE_CTEST_COMMAND}
  959. --build-and-test
  960. "${CMake_SOURCE_DIR}/Tests/QtAutomocNoQt"
  961. "${CMake_BINARY_DIR}/Tests/QtAutomocNoQt"
  962. ${build_generator_args}
  963. --build-project QtAutomocNoQt
  964. --build-options ${build_options}
  965. -DCMAKE_BUILD_TYPE=\${CTEST_CONFIGURATION_TYPE}
  966. )
  967. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/QtAutomocNoQt")
  968. # On Windows there is no RPATH, so while Qt might be available for building,
  969. # the required dlls may not be in the PATH, so we can't run the executables
  970. # on that platform.
  971. if(WIN32)
  972. set(run_autogen_test ${CMAKE_CTEST_COMMAND} -V)
  973. set(run_autouic_test ${CMAKE_CTEST_COMMAND} -V)
  974. else()
  975. set(run_autogen_test QtAutogen)
  976. set(run_autouic_test QtAutoUicInterface)
  977. endif()
  978. find_package(Qt5Widgets QUIET NO_MODULE)
  979. if(Qt5Widgets_FOUND)
  980. add_test(Qt5Autogen ${CMAKE_CTEST_COMMAND}
  981. --build-and-test
  982. "${CMake_SOURCE_DIR}/Tests/QtAutogen"
  983. "${CMake_BINARY_DIR}/Tests/Qt5Autogen"
  984. ${build_generator_args}
  985. --build-project QtAutogen
  986. --build-exe-dir "${CMake_BINARY_DIR}/Tests/Qt5Autogen"
  987. --force-new-ctest-process
  988. --build-options ${build_options}
  989. -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} -DQT_TEST_VERSION=5
  990. --test-command ${run_autogen_test}
  991. )
  992. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt5Autogen")
  993. add_test(Qt5AutoUicInterface ${CMAKE_CTEST_COMMAND}
  994. --build-and-test
  995. "${CMake_SOURCE_DIR}/Tests/QtAutoUicInterface"
  996. "${CMake_BINARY_DIR}/Tests/Qt5AutoUicInterface"
  997. ${build_generator_args}
  998. --build-project QtAutoUicInterface
  999. --build-exe-dir "${CMake_BINARY_DIR}/Tests/Qt5AutoUicInterface"
  1000. --force-new-ctest-process
  1001. --build-options ${build_options}
  1002. -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} -DQT_TEST_VERSION=5
  1003. --test-command ${run_autouic_test}
  1004. )
  1005. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt5AutoUicInterface")
  1006. endif()
  1007. if(QT4_WORKS AND QT_QTGUI_FOUND)
  1008. add_test(Qt4Autogen ${CMAKE_CTEST_COMMAND}
  1009. --build-and-test
  1010. "${CMake_SOURCE_DIR}/Tests/QtAutogen"
  1011. "${CMake_BINARY_DIR}/Tests/Qt4Autogen"
  1012. ${build_generator_args}
  1013. --build-project QtAutogen
  1014. --build-exe-dir "${CMake_BINARY_DIR}/Tests/Qt4Autogen"
  1015. --force-new-ctest-process
  1016. --build-options ${build_options}
  1017. -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} -DQT_TEST_VERSION=4
  1018. --test-command ${run_autogen_test}
  1019. )
  1020. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt4Autogen")
  1021. add_test(Qt4AutoUicInterface ${CMAKE_CTEST_COMMAND}
  1022. --build-and-test
  1023. "${CMake_SOURCE_DIR}/Tests/QtAutoUicInterface"
  1024. "${CMake_BINARY_DIR}/Tests/Qt4AutoUicInterface"
  1025. ${build_generator_args}
  1026. --build-project QtAutoUicInterface
  1027. --build-exe-dir "${CMake_BINARY_DIR}/Tests/Qt4AutoUicInterface"
  1028. --force-new-ctest-process
  1029. --build-options ${build_options}
  1030. -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} -DQT_TEST_VERSION=4
  1031. --test-command ${run_autouic_test}
  1032. )
  1033. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt4AutoUicInterface")
  1034. add_test(Qt4Targets ${CMAKE_CTEST_COMMAND}
  1035. --build-and-test
  1036. "${CMake_SOURCE_DIR}/Tests/Qt4Targets"
  1037. "${CMake_BINARY_DIR}/Tests/Qt4Targets"
  1038. ${build_generator_args}
  1039. --build-project Qt4Targets
  1040. --build-exe-dir "${CMake_BINARY_DIR}/Tests/Qt4Targets"
  1041. --force-new-ctest-process
  1042. --build-options ${build_options}
  1043. -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}
  1044. --test-command ${CMAKE_CTEST_COMMAND} -V
  1045. )
  1046. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt4Targets")
  1047. if(Qt5Widgets_FOUND AND NOT Qt5Widgets_VERSION VERSION_LESS 5.1.0)
  1048. add_test(Qt4And5Automoc ${CMAKE_CTEST_COMMAND}
  1049. --build-and-test
  1050. "${CMake_SOURCE_DIR}/Tests/Qt4And5Automoc"
  1051. "${CMake_BINARY_DIR}/Tests/Qt4And5Automoc"
  1052. ${build_generator_args}
  1053. --build-project Qt4And5Automoc
  1054. --build-exe-dir "${CMake_BINARY_DIR}/Tests/Qt4And5Automoc"
  1055. --force-new-ctest-process
  1056. --build-options ${build_options}
  1057. --test-command ${CMAKE_CTEST_COMMAND} -V
  1058. )
  1059. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt4And5Automoc")
  1060. endif()
  1061. endif()
  1062. find_package(GTK2 QUIET)
  1063. if(GTK2_FOUND)
  1064. add_subdirectory(FindGTK2)
  1065. endif()
  1066. add_test(ExternalProject ${CMAKE_CTEST_COMMAND}
  1067. --build-and-test
  1068. "${CMake_SOURCE_DIR}/Tests/ExternalProject"
  1069. "${CMake_BINARY_DIR}/Tests/ExternalProject"
  1070. ${build_generator_args}
  1071. --build-project ExternalProjectTest
  1072. --build-exe-dir "${CMake_BINARY_DIR}/Tests/ExternalProject"
  1073. --force-new-ctest-process
  1074. --build-options ${build_options}
  1075. --test-command ${CMAKE_CTEST_COMMAND} -V
  1076. )
  1077. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/ExternalProject")
  1078. set_tests_properties(ExternalProject PROPERTIES
  1079. TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT})
  1080. add_test(ExternalProjectUpdateSetup ${CMAKE_CTEST_COMMAND}
  1081. --build-and-test
  1082. "${CMake_SOURCE_DIR}/Tests/ExternalProjectUpdate"
  1083. "${CMake_BINARY_DIR}/Tests/ExternalProjectUpdate"
  1084. ${build_generator_args}
  1085. --build-project ExternalProjectUpdateTest
  1086. --build-exe-dir "${CMake_BINARY_DIR}/Tests/ExternalProjectUpdate"
  1087. --force-new-ctest-process
  1088. --build-options ${build_options}
  1089. --test-command ${CMAKE_CTEST_COMMAND} -V
  1090. )
  1091. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/ExternalProjectUpdate")
  1092. set_tests_properties(ExternalProjectUpdateSetup PROPERTIES
  1093. TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT})
  1094. add_test(NAME ExternalProjectUpdate
  1095. COMMAND ${CMAKE_CMAKE_COMMAND}
  1096. -DExternalProjectUpdate_SOURCE_DIR:PATH=${CMake_SOURCE_DIR}/Tests/ExternalProjectUpdate
  1097. -DExternalProjectUpdate_BINARY_DIR:PATH=${CMake_BINARY_DIR}/Tests/ExternalProjectUpdate
  1098. -DCMAKE_TEST_GENERATOR=${CMAKE_TEST_GENERATOR}
  1099. -DCMAKE_TEST_GENERATOR_TOOLSET=${CMAKE_TEST_GENERATOR_TOOLSET}
  1100. -DCMAKE_CTEST_COMMAND=${CMAKE_CTEST_COMMAND}
  1101. -P ${CMake_SOURCE_DIR}/Tests/ExternalProjectUpdate/ExternalProjectUpdateTest.cmake
  1102. )
  1103. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/ExternalProjectUpdate")
  1104. set_tests_properties(ExternalProjectUpdate PROPERTIES
  1105. TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT}
  1106. WORKING_DIRECTORY ${CMake_SOURCE_DIR}/Tests/ExternalProjectUpdate
  1107. DEPENDS ExternalProjectUpdateSetup )
  1108. # do each of the tutorial steps
  1109. foreach(STP RANGE 1 7)
  1110. add_test(TutorialStep${STP} ${CMAKE_CTEST_COMMAND}
  1111. --build-and-test
  1112. "${CMake_SOURCE_DIR}/Tests/Tutorial/Step${STP}"
  1113. "${CMake_BINARY_DIR}/Tests/Tutorial/Step${STP}"
  1114. --build-two-config
  1115. ${build_generator_args}
  1116. --build-project Tutorial
  1117. --build-options ${build_options}
  1118. --test-command Tutorial 25.0)
  1119. endforeach()
  1120. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Tutorial")
  1121. add_test(testing ${CMAKE_CTEST_COMMAND} -C \${CTEST_CONFIGURATION_TYPE}
  1122. --build-and-test
  1123. "${CMake_SOURCE_DIR}/Tests/Testing"
  1124. "${CMake_BINARY_DIR}/Tests/Testing"
  1125. ${build_generator_args}
  1126. --build-project Testing
  1127. --build-options ${build_options}
  1128. --test-command ${CMAKE_CTEST_COMMAND} -C \${CTEST_CONFIGURATION_TYPE}
  1129. )
  1130. set_tests_properties(testing PROPERTIES PASS_REGULAR_EXPRESSION "Passed")
  1131. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Testing")
  1132. add_test(wrapping ${CMAKE_CTEST_COMMAND}
  1133. --build-and-test
  1134. "${CMake_SOURCE_DIR}/Tests/Wrapping"
  1135. "${CMake_BINARY_DIR}/Tests/Wrapping"
  1136. ${build_generator_args}
  1137. --build-project Wrapping
  1138. --build-exe-dir "${CMake_BINARY_DIR}/Tests/Wrapping/bin"
  1139. --build-options ${build_options}
  1140. --test-command wrapping
  1141. )
  1142. add_test(qtwrapping ${CMAKE_CTEST_COMMAND}
  1143. --build-and-test
  1144. "${CMake_SOURCE_DIR}/Tests/Wrapping"
  1145. "${CMake_BINARY_DIR}/Tests/Wrapping"
  1146. ${build_generator_args}
  1147. --build-project Wrapping
  1148. --build-exe-dir "${CMake_BINARY_DIR}/Tests/Wrapping/bin"
  1149. --build-options ${build_options}
  1150. --test-command qtwrapping
  1151. )
  1152. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Wrapping")
  1153. add_test(testdriver1 ${CMAKE_CTEST_COMMAND}
  1154. --build-and-test
  1155. "${CMake_SOURCE_DIR}/Tests/TestDriver"
  1156. "${CMake_BINARY_DIR}/Tests/TestDriver"
  1157. ${build_generator_args}
  1158. --build-exe-dir "${CMake_BINARY_DIR}/Tests/Wrapping/bin"
  1159. --build-project TestDriverTest
  1160. --build-options ${build_options}
  1161. --test-command TestDriverTest test1
  1162. )
  1163. add_test(testdriver2 ${CMAKE_CTEST_COMMAND}
  1164. --build-and-test
  1165. "${CMake_SOURCE_DIR}/Tests/TestDriver"
  1166. "${CMake_BINARY_DIR}/Tests/TestDriver"
  1167. ${build_generator_args}
  1168. --build-exe-dir "${CMake_BINARY_DIR}/Tests/Wrapping/bin"
  1169. --build-project TestDriverTest
  1170. --build-options ${build_options}
  1171. --test-command TestDriverTest test2
  1172. )
  1173. add_test(testdriver3 ${CMAKE_CTEST_COMMAND}
  1174. --build-and-test
  1175. "${CMake_SOURCE_DIR}/Tests/TestDriver"
  1176. "${CMake_BINARY_DIR}/Tests/TestDriver"
  1177. ${build_generator_args}
  1178. --build-exe-dir "${CMake_BINARY_DIR}/Tests/Wrapping/bin"
  1179. --build-project TestDriverTest
  1180. --build-options ${build_options}
  1181. --test-command TestDriverTest subdir/test3
  1182. )
  1183. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/TestDriver")
  1184. add_test(Dependency ${CMAKE_CTEST_COMMAND}
  1185. --build-and-test
  1186. "${CMake_SOURCE_DIR}/Tests/Dependency"
  1187. "${CMake_BINARY_DIR}/Tests/Dependency"
  1188. --build-exe-dir "${CMake_BINARY_DIR}/Tests/Dependency/Exec"
  1189. ${build_generator_args}
  1190. --build-project Dependency
  1191. --build-options ${build_options}
  1192. --test-command exec
  1193. )
  1194. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Dependency")
  1195. if("${CMAKE_SYSTEM_NAME}" MATCHES syllable)
  1196. # RPATH isn't supported under Syllable, so the tests don't
  1197. # find their libraries. In order to fix that LIBRARY_OUTPUT_DIR
  1198. # in the tests would have to be adjusted to ${EXECUTABLE_OUTPUT_DIR}/lib .
  1199. # For now we just require on Syllable that the user adjusts the DLL_PATH
  1200. # environment variable, so except the two tests below all other tests will succeed.
  1201. set(_DLL_PATH "$ENV{DLL_PATH}")
  1202. if(NOT "${_DLL_PATH}" MATCHES "^(.*:)?\\@bindir\\@/\\.(:.*)?$")
  1203. message(FATAL_ERROR "In order to successfully run the CMake test suite on Syllable you need to add \"\\@bindir\\@/.\" to the DLL_PATH environment variable")
  1204. endif()
  1205. if(NOT "${_DLL_PATH}" MATCHES "^(.*:)?\\@bindir\\@/\\.\\./lib(:.*)?$")
  1206. message(FATAL_ERROR "In order to successfully run the CMake test suite on Syllable you need to add \"\\@bindir\\@/../lib\" to the DLL_PATH environment variable")
  1207. endif()
  1208. else()
  1209. add_test(JumpWithLibOut ${CMAKE_CTEST_COMMAND}
  1210. --build-and-test
  1211. "${CMake_SOURCE_DIR}/Tests/Jump"
  1212. "${CMake_BINARY_DIR}/Tests/Jump/WithLibOut"
  1213. --build-exe-dir "${CMake_BINARY_DIR}/Tests/Jump/WithLibOut/Executable"
  1214. --build-project Jump
  1215. ${build_generator_args}
  1216. --build-options ${build_options}
  1217. -DLIBRARY_OUTPUT_PATH:PATH=${CMake_BINARY_DIR}/Tests/Jump/WithLibOut/Lib
  1218. --test-command jumpExecutable
  1219. )
  1220. add_test(JumpNoLibOut ${CMAKE_CTEST_COMMAND}
  1221. --build-and-test
  1222. "${CMake_SOURCE_DIR}/Tests/Jump"
  1223. "${CMake_BINARY_DIR}/Tests/Jump/NoLibOut"
  1224. --build-exe-dir "${CMake_BINARY_DIR}/Tests/Jump/NoLibOut/Executable"
  1225. --build-run-dir "${CMake_BINARY_DIR}/Tests/Jump/NoLibOut/Executable"
  1226. --build-project Jump
  1227. ${build_generator_args}
  1228. --build-options ${build_options}
  1229. --test-command jumpExecutable
  1230. )
  1231. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Jump")
  1232. add_test(Plugin ${CMAKE_CTEST_COMMAND}
  1233. --build-and-test
  1234. "${CMake_SOURCE_DIR}/Tests/Plugin"
  1235. "${CMake_BINARY_DIR}/Tests/Plugin"
  1236. ${build_generator_args}
  1237. --build-project Plugin
  1238. --build-two-config
  1239. --build-options ${build_options}
  1240. --test-command bin/example)
  1241. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Plugin")
  1242. if(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG)
  1243. ADD_TEST_MACRO(RuntimePath RuntimePath)
  1244. endif()
  1245. endif()
  1246. if(APPLE AND "${DARWIN_MAJOR_VERSION}" GREATER 9)
  1247. add_test(MacRuntimePath ${CMAKE_CTEST_COMMAND}
  1248. --build-and-test
  1249. "${CMake_SOURCE_DIR}/Tests/MacRuntimePath"
  1250. "${CMake_BINARY_DIR}/Tests/MacRuntimePath"
  1251. ${build_generator_args}
  1252. --build-project MacRuntimePath
  1253. --build-options ${build_options}
  1254. -DCMAKE_TEST_MAKEPROGRAM:FILEPATH=${CMAKE_TEST_MAKEPROGRAM}
  1255. )
  1256. endif()
  1257. add_test(linkorder1 ${CMAKE_CTEST_COMMAND}
  1258. --build-and-test
  1259. "${CMake_SOURCE_DIR}/Tests/LinkLineOrder"
  1260. "${CMake_BINARY_DIR}/Tests/LinkLineOrder"
  1261. ${build_generator_args}
  1262. --build-project LinkLineOrder
  1263. --build-options ${build_options}
  1264. --test-command Exec1
  1265. )
  1266. add_test(linkorder2 ${CMAKE_CTEST_COMMAND}
  1267. --build-and-test
  1268. "${CMake_SOURCE_DIR}/Tests/LinkLineOrder"
  1269. "${CMake_BINARY_DIR}/Tests/LinkLineOrder"
  1270. ${build_generator_args}
  1271. --build-project LinkLineOrder
  1272. --build-options ${build_options}
  1273. --test-command Exec2
  1274. )
  1275. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/LinkLineOrder")
  1276. set_tests_properties ( qtwrapping PROPERTIES DEPENDS wrapping)
  1277. set_tests_properties ( testdriver1 PROPERTIES DEPENDS qtwrapping)
  1278. set_tests_properties ( testdriver2 PROPERTIES DEPENDS testdriver1)
  1279. set_tests_properties ( testdriver3 PROPERTIES DEPENDS testdriver2)
  1280. set_tests_properties ( linkorder2 PROPERTIES DEPENDS linkorder1)
  1281. set_tests_properties ( SimpleInstall-Stage2 PROPERTIES DEPENDS SimpleInstall)
  1282. # Test static linking on toolchains known to support it.
  1283. if("${CMAKE_C_COMPILER_ID}" MATCHES "^(GNU)$"
  1284. AND NOT APPLE AND NOT WIN32 AND NOT CYGWIN
  1285. AND EXISTS "/usr/lib/libm.a")
  1286. add_test(LinkStatic ${CMAKE_CTEST_COMMAND}
  1287. --build-and-test
  1288. "${CMake_SOURCE_DIR}/Tests/LinkStatic"
  1289. "${CMake_BINARY_DIR}/Tests/LinkStatic"
  1290. ${build_generator_args}
  1291. --build-project LinkStatic
  1292. --build-options ${build_options}
  1293. -DMATH_LIBRARY:FILEPATH=/usr/lib/libm.a
  1294. --test-command LinkStatic
  1295. )
  1296. endif()
  1297. if(NOT CMAKE_TEST_DIFFERENT_GENERATOR)
  1298. add_test(kwsys ${CMAKE_CTEST_COMMAND}
  1299. --build-and-test
  1300. "${CMake_SOURCE_DIR}/Source/kwsys"
  1301. "${CMake_BINARY_DIR}/Tests/kwsys"
  1302. ${build_generator_args}
  1303. --build-project kwsys
  1304. --build-options ${build_options}
  1305. --test-command kwsysTestsCxx testIOS
  1306. )
  1307. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/kwsys")
  1308. endif()
  1309. if(MAKE_SUPPORTS_SPACES)
  1310. add_test(SubDirSpaces ${CMAKE_CTEST_COMMAND}
  1311. --build-and-test
  1312. "${CMake_SOURCE_DIR}/Tests/SubDirSpaces"
  1313. "${CMake_BINARY_DIR}/Tests/SubDirSpaces"
  1314. --build-exe-dir
  1315. "${CMake_BINARY_DIR}/Tests/SubDirSpaces/Executable Sources"
  1316. ${build_generator_args}
  1317. --build-project SUBDIR
  1318. --build-options ${build_options}
  1319. --test-command test
  1320. "${CMake_BINARY_DIR}/Tests/SubDirSpaces/ShouldBeHere"
  1321. "${CMake_BINARY_DIR}/Tests/SubDirSpaces/testfromsubdir.obj"
  1322. )
  1323. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/SubDirSpaces")
  1324. endif ()
  1325. if (WIN32)
  1326. add_test(SubDir ${CMAKE_CTEST_COMMAND}
  1327. --build-and-test
  1328. "${CMake_SOURCE_DIR}/Tests/SubDir"
  1329. "${CMake_BINARY_DIR}/Tests/SubDir"
  1330. --build-exe-dir "${CMake_BINARY_DIR}/Tests/SubDir/Executable"
  1331. ${build_generator_args}
  1332. --build-project SUBDIR
  1333. --build-options ${build_options}
  1334. --test-command test
  1335. "${CMake_BINARY_DIR}/Tests/SubDir/ShouldBeHere"
  1336. "${CMake_BINARY_DIR}/Tests/SubDir/testfromsubdir.obj"
  1337. )
  1338. else ()
  1339. add_test(SubDir ${CMAKE_CTEST_COMMAND}
  1340. --build-and-test
  1341. "${CMake_SOURCE_DIR}/Tests/SubDir"
  1342. "${CMake_BINARY_DIR}/Tests/SubDir"
  1343. --build-exe-dir "${CMake_BINARY_DIR}/Tests/SubDir/Executable"
  1344. ${build_generator_args}
  1345. --build-project SUBDIR
  1346. --build-options ${build_options}
  1347. --test-command test
  1348. "${CMake_BINARY_DIR}/Tests/SubDir/ShouldBeHere"
  1349. "${CMake_BINARY_DIR}/Tests/SubDir/testfromsubdir.o"
  1350. )
  1351. endif ()
  1352. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/SubDir")
  1353. if(CMAKE_TEST_MSVC)
  1354. ADD_TEST_MACRO(ForceInclude foo)
  1355. ADD_TEST_MACRO(PDBDirectoryAndName myexe)
  1356. ADD_TEST_MACRO(PrecompiledHeader foo)
  1357. endif()
  1358. if(CMAKE_TEST_MSVC OR
  1359. "${CMAKE_TEST_GENERATOR}" MATCHES "(MSYS|MinGW) Makefiles")
  1360. ADD_TEST_MACRO(ModuleDefinition example_exe)
  1361. endif()
  1362. ADD_TEST_MACRO(CheckCompilerRelatedVariables CheckCompilerRelatedVariables)
  1363. if("${CMAKE_TEST_GENERATOR}" MATCHES "Makefile")
  1364. add_test(MakeClean ${CMAKE_CTEST_COMMAND}
  1365. --build-and-test
  1366. "${CMake_SOURCE_DIR}/Tests/MakeClean"
  1367. "${CMake_BINARY_DIR}/Tests/MakeClean"
  1368. ${build_generator_args}
  1369. --build-project MakeClean
  1370. --build-exe-dir "${CMake_BINARY_DIR}/MakeClean"
  1371. --build-options ${build_options}
  1372. --test-command check_clean
  1373. )
  1374. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/MakeClean")
  1375. endif()
  1376. if(NOT DEFINED CTEST_RUN_MFC)
  1377. set(CTEST_RUN_MFC OFF)
  1378. if(MSVC)
  1379. set(CTEST_RUN_MFC ON)
  1380. # Look for evidence that this is a VCExpress build. If so, avoid
  1381. # the MFC test by default.
  1382. string(TOLOWER "${CMAKE_MAKE_PROGRAM};${CMAKE_TEST_MAKEPROGRAM}" mkprog)
  1383. if(mkprog MATCHES "vcexpress")
  1384. message(STATUS
  1385. "CMAKE_TEST_MAKEPROGRAM indicates vcexpress, avoiding MFC test")
  1386. set(CTEST_RUN_MFC OFF)
  1387. endif()
  1388. # Since MSBuild might also be the "makeprogram" for a VCExpress
  1389. # build tree, use one more heuristic, too. The string representing
  1390. # the .vcproj file type contains "VCExpress" on machines where an
  1391. # express edition of VS was installed last:
  1392. if(CTEST_RUN_MFC)
  1393. execute_process(COMMAND cmd /c assoc .vcproj
  1394. OUTPUT_STRIP_TRAILING_WHITESPACE
  1395. OUTPUT_VARIABLE ov)
  1396. if(ov MATCHES "VCExpress")
  1397. message(STATUS
  1398. ".vcproj file association indicates VCExpress, avoiding MFC test")
  1399. set(CTEST_RUN_MFC OFF)
  1400. endif()
  1401. endif()
  1402. # For the Watcom WMake generator, avoid the MFC test by default.
  1403. if(CTEST_RUN_MFC)
  1404. if("${CMAKE_TEST_GENERATOR}" MATCHES "WMake")
  1405. message(STATUS
  1406. "using the Watcom WMake generator, avoiding MFC test")
  1407. set(CTEST_RUN_MFC OFF)
  1408. endif()
  1409. endif()
  1410. # Last resort, after quick checks are done. Do a try_compile, and avoid
  1411. # the MFC test if the simplest possible MFC app cannot be compiled.
  1412. if(CTEST_RUN_MFC AND NOT DEFINED HAVE_MFC)
  1413. configure_file(
  1414. ${CMAKE_CURRENT_SOURCE_DIR}/MFC/try_compile/CMakeLists.txt
  1415. ${CMAKE_CURRENT_BINARY_DIR}/MFC/try_compile/CMakeLists.txt
  1416. COPYONLY
  1417. )
  1418. configure_file(
  1419. ${CMAKE_CURRENT_SOURCE_DIR}/MFC/mfc1/stdafx.cpp
  1420. ${CMAKE_CURRENT_BINARY_DIR}/MFC/try_compile/stdafx.cpp
  1421. COPYONLY
  1422. )
  1423. configure_file(
  1424. ${CMAKE_CURRENT_SOURCE_DIR}/MFC/mfc1/stdafx.h
  1425. ${CMAKE_CURRENT_BINARY_DIR}/MFC/try_compile/stdafx.h
  1426. COPYONLY
  1427. )
  1428. message(STATUS "Looking for MFC")
  1429. try_compile(HAVE_MFC
  1430. ${CMAKE_CURRENT_BINARY_DIR}/MFC/try_compile/build
  1431. ${CMAKE_CURRENT_BINARY_DIR}/MFC/try_compile
  1432. try_compile_mfc
  1433. OUTPUT_VARIABLE HAVE_MFC_OUTPUT)
  1434. if(HAVE_MFC)
  1435. message(STATUS "Looking for MFC - found")
  1436. set(HAVE_MFC 1 CACHE INTERNAL "Have MFC")
  1437. file(APPEND
  1438. ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
  1439. "Determining if MFC exists passed with the following output:\n"
  1440. "${HAVE_MFC_OUTPUT}\n\n")
  1441. else()
  1442. message(STATUS "Looking for MFC - not found")
  1443. set(HAVE_MFC "" CACHE INTERNAL "Have MFC")
  1444. file(APPEND
  1445. ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
  1446. "Determining if MFC exists failed with the following output:\n"
  1447. "${HAVE_MFC_OUTPUT}\n\n")
  1448. endif()
  1449. endif()
  1450. if(CTEST_RUN_MFC AND NOT HAVE_MFC)
  1451. message(STATUS
  1452. "cannot compile simplest ever MFC app, avoiding MFC test")
  1453. set(CTEST_RUN_MFC OFF)
  1454. endif()
  1455. endif()
  1456. endif()
  1457. if(CTEST_RUN_MFC)
  1458. add_test(MFC ${CMAKE_CTEST_COMMAND}
  1459. --build-and-test
  1460. "${CMake_SOURCE_DIR}/Tests/MFC"
  1461. "${CMake_BINARY_DIR}/Tests/MFC"
  1462. --build-two-config
  1463. ${build_generator_args}
  1464. --build-project mfc_driver
  1465. --build-options ${build_options}
  1466. --test-command ${CMAKE_CTEST_COMMAND}
  1467. -C \${CTEST_CONFIGURATION_TYPE} -VV)
  1468. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/MFC")
  1469. endif()
  1470. if(${CMAKE_TEST_GENERATOR} MATCHES "Visual Studio")
  1471. if(NOT MSVC60)
  1472. ADD_TEST_MACRO(SBCS SBCS)
  1473. endif()
  1474. if(NOT "${CMAKE_TEST_GENERATOR}" MATCHES "Visual Studio [6789]( |$)"
  1475. AND NOT CMAKE_TEST_GENERATOR_TOOLSET)
  1476. ADD_TEST_MACRO(VSWindowsFormsResx VSWindowsFormsResx)
  1477. endif()
  1478. add_test(VSExternalInclude ${CMAKE_CTEST_COMMAND}
  1479. --build-and-test
  1480. "${CMake_SOURCE_DIR}/Tests/VSExternalInclude"
  1481. "${CMake_BINARY_DIR}/Tests/VSExternalInclude"
  1482. --build-two-config
  1483. ${build_generator_args}
  1484. --build-project VSExternalInclude
  1485. --build-options ${build_options}
  1486. --test-command VSExternalInclude)
  1487. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/VSExternalInclude")
  1488. add_test(VSMidl ${CMAKE_CTEST_COMMAND}
  1489. --build-and-test
  1490. "${CMake_SOURCE_DIR}/Tests/VSMidl"
  1491. "${CMake_BINARY_DIR}/Tests/VSMidl"
  1492. --build-two-config
  1493. ${build_generator_args}
  1494. --build-project VSMidl
  1495. --build-options ${build_options}
  1496. --test-command VSMidl)
  1497. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/VSMidl")
  1498. if(CMAKE_TEST_DEVENV)
  1499. # The test (and tested property) works with .sln files, so it's skipped when:
  1500. # * Using VS6, which doesn't use .sln files
  1501. # * cmake --build is set up to use MSBuild, since the MSBuild invocation does not use the .sln file
  1502. set(_last_test "")
  1503. foreach(config ${CMAKE_CONFIGURATION_TYPES})
  1504. add_test(NAME VSExcludeFromDefaultBuild-${config} COMMAND ${CMAKE_CTEST_COMMAND}
  1505. --build-and-test
  1506. "${CMake_SOURCE_DIR}/Tests/VSExcludeFromDefaultBuild"
  1507. "${CMake_BINARY_DIR}/Tests/VSExcludeFromDefaultBuild"
  1508. --build-config ${config}
  1509. --build-two-config
  1510. --build-generator ${CMAKE_TEST_GENERATOR}
  1511. --build-makeprogram ${CMAKE_TEST_DEVENV}
  1512. --build-generator-toolset "${CMAKE_TEST_GENERATOR_TOOLSET}"
  1513. --build-project VSExcludeFromDefaultBuild
  1514. --test-command ${CMAKE_COMMAND}
  1515. -D "activeConfig=${config}"
  1516. -D "allConfigs=${CMAKE_CONFIGURATION_TYPES}"
  1517. -D "dir=${CMake_BINARY_DIR}/Tests/VSExcludeFromDefaultBuild"
  1518. -P "${CMake_SOURCE_DIR}/Tests/VSExcludeFromDefaultBuild/ResultTest.cmake")
  1519. if(_last_test)
  1520. set_property(TEST VSExcludeFromDefaultBuild-${config} PROPERTY DEPENDS ${_last_test})
  1521. endif()
  1522. set(_last_test "VSExcludeFromDefaultBuild-${config}")
  1523. endforeach()
  1524. unset(_last_test)
  1525. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/VSExcludeFromDefaultBuild")
  1526. endif()
  1527. if(CMAKE_TEST_GENERATOR MATCHES "Visual Studio ([0-5]|[6-9][0-9])")
  1528. # This is Visual Studio 10 or above, so the default build tool is MSBuild.
  1529. add_test(NAME VSProjectInSubdir COMMAND ${CMAKE_CTEST_COMMAND}
  1530. --build-and-test
  1531. "${CMake_SOURCE_DIR}/Tests/VSProjectInSubdir"
  1532. "${CMake_BINARY_DIR}/Tests/VSProjectInSubdir"
  1533. --build-two-config
  1534. --build-generator ${CMAKE_TEST_GENERATOR}
  1535. --build-generator-toolset "${CMAKE_TEST_GENERATOR_TOOLSET}"
  1536. --build-project VSProjectInSubdir
  1537. --build-target test)
  1538. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/VSProjectInSubdir")
  1539. endif()
  1540. endif()
  1541. if (APPLE)
  1542. if (CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
  1543. set(BundleTestInstallDir
  1544. "${CMake_BINARY_DIR}/Tests/BundleTest/InstallDirectory")
  1545. add_test(BundleTest ${CMAKE_CTEST_COMMAND}
  1546. --build-and-test
  1547. "${CMake_SOURCE_DIR}/Tests/BundleTest"
  1548. "${CMake_BINARY_DIR}/Tests/BundleTest"
  1549. --build-two-config
  1550. ${build_generator_args}
  1551. --build-project BundleTest
  1552. --build-target install
  1553. # --build-target package
  1554. --build-options ${build_options}
  1555. "-DCMAKE_INSTALL_PREFIX:PATH=${BundleTestInstallDir}"
  1556. "-DCMake_SOURCE_DIR:PATH=${CMake_SOURCE_DIR}"
  1557. --test-command
  1558. ${BundleTestInstallDir}/Applications/SecondBundleExe.app/Contents/MacOS/SecondBundleExe)
  1559. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/BundleTest")
  1560. add_test(CFBundleTest ${CMAKE_CTEST_COMMAND}
  1561. --build-and-test
  1562. "${CMake_SOURCE_DIR}/Tests/CFBundleTest"
  1563. "${CMake_BINARY_DIR}/Tests/CFBundleTest"
  1564. --build-two-config
  1565. ${build_generator_args}
  1566. --build-project CFBundleTest
  1567. --build-options ${build_options}
  1568. --test-command
  1569. ${CMAKE_CMAKE_COMMAND} -DCTEST_CONFIGURATION_TYPE=\${CTEST_CONFIGURATION_TYPE}
  1570. -Ddir=${CMake_BINARY_DIR}/Tests/CFBundleTest
  1571. -Dgen=${CMAKE_TEST_GENERATOR}
  1572. -P ${CMake_SOURCE_DIR}/Tests/CFBundleTest/VerifyResult.cmake)
  1573. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CFBundleTest")
  1574. ADD_TEST_MACRO(ObjC++ ObjC++)
  1575. endif ()
  1576. endif ()
  1577. if(APPLE AND CTEST_TEST_CPACK)
  1578. add_test(BundleGeneratorTest ${CMAKE_CTEST_COMMAND}
  1579. --build-and-test
  1580. "${CMake_SOURCE_DIR}/Tests/BundleGeneratorTest"
  1581. "${CMake_BINARY_DIR}/Tests/BundleGeneratorTest"
  1582. --build-two-config
  1583. ${build_generator_args}
  1584. --build-project BundleGeneratorTest
  1585. --build-target package
  1586. --build-options ${build_options}
  1587. "-DCMAKE_INSTALL_PREFIX:PATH=${CMake_BINARY_DIR}/Tests/BundleGeneratorTest/InstallDirectory"
  1588. )
  1589. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/BundleGeneratorTest")
  1590. endif()
  1591. add_test(WarnUnusedUnusedViaSet ${CMAKE_CTEST_COMMAND}
  1592. --build-and-test
  1593. "${CMake_SOURCE_DIR}/Tests/VariableUnusedViaSet"
  1594. "${CMake_BINARY_DIR}/Tests/WarnUnusedUnusedViaSet"
  1595. ${build_generator_args}
  1596. --build-noclean
  1597. --build-project WarnUnusedUnusedViaSet
  1598. --build-options ${build_options}
  1599. "--warn-unused-vars")
  1600. set_tests_properties(WarnUnusedUnusedViaSet PROPERTIES
  1601. PASS_REGULAR_EXPRESSION "unused variable \\(changing definition\\) 'UNUSED_VARIABLE'")
  1602. set_tests_properties(WarnUnusedUnusedViaSet PROPERTIES
  1603. FAIL_REGULAR_EXPRESSION "unused variable \\(unsetting\\) 'UNUSED_VARIABLE'")
  1604. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUnusedUnusedViaSet")
  1605. add_test(WarnUnusedUnusedViaUnset ${CMAKE_CTEST_COMMAND}
  1606. --build-and-test
  1607. "${CMake_SOURCE_DIR}/Tests/VariableUnusedViaUnset"
  1608. "${CMake_BINARY_DIR}/Tests/WarnUnusedUnusedViaUnset"
  1609. ${build_generator_args}
  1610. --build-noclean
  1611. --build-project WarnUnusedUnusedViaUnset
  1612. --build-options ${build_options}
  1613. "--warn-unused-vars")
  1614. set_tests_properties(WarnUnusedUnusedViaUnset PROPERTIES
  1615. PASS_REGULAR_EXPRESSION "CMake Warning .*VariableUnusedViaUnset.CMakeLists.txt:7 \\(set\\):")
  1616. set_tests_properties(WarnUnusedUnusedViaUnset PROPERTIES
  1617. FAIL_REGULAR_EXPRESSION "CMake Warning .*VariableUnusedViaUnset.CMakeLists.txt:5 \\(set\\):")
  1618. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUnusedUnusedViaUnset")
  1619. if("${CMAKE_TEST_GENERATOR}" MATCHES "Makefile" AND NOT WIN32)
  1620. # Ninja does not support ADDITIONAL_MAKE_CLEAN_FILES and therefore fails
  1621. # this test. (See #13371)
  1622. # Apparently Visual Studio does not support it either. As the MakeClean
  1623. # test above is only run with the Makefiles generator, only run this
  1624. # test with the Makefiles generator also.
  1625. add_test(WarnUnusedCliUnused ${CMAKE_CTEST_COMMAND}
  1626. --build-and-test
  1627. "${CMake_SOURCE_DIR}/Tests/WarnUnusedCliUnused"
  1628. "${CMake_BINARY_DIR}/Tests/WarnUnusedCliUnused"
  1629. ${build_generator_args}
  1630. --build-project WarnUnusedCliUnused
  1631. --build-options ${build_options}
  1632. "-DUNUSED_CLI_VARIABLE=Unused")
  1633. set_tests_properties(WarnUnusedCliUnused PROPERTIES
  1634. PASS_REGULAR_EXPRESSION "CMake Warning:.*Manually-specified variables were not used by the project:.* UNUSED_CLI_VARIABLE")
  1635. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUnusedCliUnused")
  1636. endif()
  1637. add_test(WarnUnusedCliUsed ${CMAKE_CTEST_COMMAND}
  1638. --build-and-test
  1639. "${CMake_SOURCE_DIR}/Tests/VariableUsage"
  1640. "${CMake_BINARY_DIR}/Tests/WarnUnusedCliUsed"
  1641. ${build_generator_args}
  1642. --build-noclean
  1643. --build-project WarnUnusedCliUsed
  1644. --build-options ${build_options}
  1645. "-DUSED_VARIABLE=Usage proven")
  1646. set_tests_properties(WarnUnusedCliUsed PROPERTIES
  1647. PASS_REGULAR_EXPRESSION "Usage proven")
  1648. set_tests_properties(WarnUnusedCliUsed PROPERTIES
  1649. FAIL_REGULAR_EXPRESSION "CMake Warning: The variable, 'USED_VARIABLE'")
  1650. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUnusedCliUsed")
  1651. add_test(WarnUninitialized ${CMAKE_CTEST_COMMAND}
  1652. --build-and-test
  1653. "${CMake_SOURCE_DIR}/Tests/VariableUsage"
  1654. "${CMake_BINARY_DIR}/Tests/WarnUninitialized"
  1655. ${build_generator_args}
  1656. --build-noclean
  1657. --build-project WarnUninitialized
  1658. --build-options ${build_options}
  1659. "--warn-uninitialized")
  1660. set_tests_properties(WarnUninitialized PROPERTIES
  1661. PASS_REGULAR_EXPRESSION "uninitialized variable 'USED_VARIABLE'")
  1662. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUninitialized")
  1663. add_test(TestsWorkingDirectory ${CMAKE_CTEST_COMMAND}
  1664. --build-and-test
  1665. "${CMake_SOURCE_DIR}/Tests/TestsWorkingDirectory"
  1666. "${CMake_BINARY_DIR}/Tests/TestsWorkingDirectory"
  1667. ${build_generator_args}
  1668. --build-project TestsWorkingDirectoryProj
  1669. --build-exe-dir "${CMake_BINARY_DIR}/Tests/TestsWorkingDirectory"
  1670. --force-new-ctest-process
  1671. --build-options ${build_options}
  1672. --test-command ${CMAKE_CTEST_COMMAND} -V -C \${CTEST_CONFIGURATION_TYPE}
  1673. )
  1674. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/TestsWorkingDirectory")
  1675. # Make sure CTest can handle a test with no newline in output.
  1676. add_test(CTest.NoNewline
  1677. ${CMAKE_CMAKE_COMMAND} -E echo_append "This line has no newline!")
  1678. # A simple test for ctest in script mode
  1679. configure_file("${CMake_SOURCE_DIR}/Tests/CTestScriptMode/CTestTestScriptMode.cmake.in"
  1680. "${CMake_BINARY_DIR}/Tests/CTestScriptMode/CTestTestScriptMode.cmake" @ONLY)
  1681. # add_test(CTest.ScriptMode ${CMAKE_CTEST_COMMAND}
  1682. # -S "${CMake_BINARY_DIR}/Tests/CTestScriptMode/CTestTestScriptMode.cmake"
  1683. # )
  1684. # A test for ctest_build() with targets in subdirectories
  1685. set(ctest_configure_options)
  1686. if(CMAKE_TEST_GENERATOR_TOOLSET)
  1687. list(APPEND ctest_configure_options -T ${CMAKE_TEST_GENERATOR_TOOLSET})
  1688. endif()
  1689. if(CMAKE_TEST_MAKEPROGRAM)
  1690. list(APPEND ctest_configure_options -DCMAKE_MAKE_PROGRAM:FILEPATH=${CMAKE_TEST_MAKEPROGRAM})
  1691. endif()
  1692. configure_file("${CMake_SOURCE_DIR}/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake.in"
  1693. "${CMake_BINARY_DIR}/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake" @ONLY)
  1694. unset(ctest_configure_options)
  1695. add_test(CTest.BuildCommand.ProjectInSubdir
  1696. ${CMAKE_CTEST_COMMAND} -S "${CMake_BINARY_DIR}/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake")
  1697. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CTestBuildCommandProjectInSubdir/Nested")
  1698. set(CTEST_TEST_UPDATE 1)
  1699. if(CTEST_TEST_UPDATE)
  1700. # Test CTest Update with Subversion
  1701. find_package(Subversion QUIET)
  1702. if(Subversion_FOUND)
  1703. get_filename_component(_Subversion_BIN_DIR
  1704. ${Subversion_SVN_EXECUTABLE} PATH)
  1705. find_program(Subversion_SVNADMIN_EXECUTABLE svnadmin
  1706. HINTS ${_Subversion_BIN_DIR}
  1707. )
  1708. mark_as_advanced(Subversion_SVNADMIN_EXECUTABLE)
  1709. if(NOT Subversion_SVNADMIN_EXECUTABLE)
  1710. set(Subversion_FOUND FALSE)
  1711. endif()
  1712. endif()
  1713. if(Subversion_FOUND)
  1714. set(CTestUpdateSVN_DIR "CTest UpdateSVN")
  1715. configure_file("${CMake_SOURCE_DIR}/Tests/CTestUpdateSVN.cmake.in"
  1716. "${CMake_BINARY_DIR}/Tests/CTestUpdateSVN.cmake" @ONLY)
  1717. add_test(CTest.UpdateSVN ${CMAKE_CMAKE_COMMAND}
  1718. -P "${CMake_BINARY_DIR}/Tests/CTestUpdateSVN.cmake"
  1719. )
  1720. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${CTestUpdateSVN_DIR}")
  1721. endif()
  1722. # Test CTest Update with CVS
  1723. if(EXISTS ${CMAKE_ROOT}/Modules/FindCVS.cmake)
  1724. find_package(CVS QUIET)
  1725. else()
  1726. find_program(CVS_EXECUTABLE NAMES cvs)
  1727. set(CVS_FOUND ${CVS_EXECUTABLE})
  1728. endif()
  1729. set(CTEST_TEST_UPDATE_CVS ${CVS_FOUND})
  1730. if(CTEST_TEST_UPDATE_CVS AND NOT UNIX)
  1731. if("${CVS_EXECUTABLE}" MATCHES "cygwin")
  1732. message(STATUS "No CTest.UpdateCVS test with cygwin cvs.exe outside cygwin!")
  1733. set(CTEST_TEST_UPDATE_CVS 0)
  1734. endif()
  1735. endif()
  1736. if(CTEST_TEST_UPDATE_CVS)
  1737. set(CTestUpdateCVS_DIR "CTest UpdateCVS")
  1738. configure_file("${CMake_SOURCE_DIR}/Tests/CTestUpdateCVS.cmake.in"
  1739. "${CMake_BINARY_DIR}/Tests/CTestUpdateCVS.cmake" @ONLY)
  1740. add_test(CTest.UpdateCVS ${CMAKE_CMAKE_COMMAND}
  1741. -P "${CMake_BINARY_DIR}/Tests/CTestUpdateCVS.cmake"
  1742. )
  1743. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${CTestUpdateCVS_DIR}")
  1744. endif()
  1745. # Test CTest Update with BZR
  1746. find_program(BZR_EXECUTABLE NAMES bzr)
  1747. mark_as_advanced(BZR_EXECUTABLE)
  1748. set(CTEST_TEST_UPDATE_BZR 0)
  1749. if(BZR_EXECUTABLE)
  1750. if(NOT "${BZR_EXECUTABLE}" MATCHES "cygwin" OR UNIX)
  1751. set(CTEST_TEST_UPDATE_BZR 1)
  1752. endif()
  1753. endif()
  1754. if(CTEST_TEST_UPDATE_BZR)
  1755. # Check if xmloutput plugin is there
  1756. execute_process(COMMAND ${BZR_EXECUTABLE} xmlplugins RESULT_VARIABLE xmlplugres
  1757. OUTPUT_QUIET ERROR_QUIET)
  1758. if( NOT ${xmlplugres} )
  1759. set(CTestUpdateBZR_DIR "CTest UpdateBZR")
  1760. configure_file("${CMake_SOURCE_DIR}/Tests/CTestUpdateBZR.cmake.in"
  1761. "${CMake_BINARY_DIR}/Tests/CTestUpdateBZR.cmake" @ONLY)
  1762. add_test(CTest.UpdateBZR ${CMAKE_CMAKE_COMMAND}
  1763. -P "${CMake_BINARY_DIR}/Tests/CTestUpdateBZR.cmake"
  1764. )
  1765. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${CTestUpdateBZR_DIR}")
  1766. set(CTestUpdateBZR_DIR "CTest UpdateBZR_CLocale")
  1767. configure_file("${CMake_SOURCE_DIR}/Tests/CTestUpdateBZR.cmake.in"
  1768. "${CMake_BINARY_DIR}/Tests/CTestUpdateBZR_CLocale.cmake" @ONLY)
  1769. add_test(CTest.UpdateBZR.CLocale ${CMAKE_CMAKE_COMMAND}
  1770. -P "${CMake_BINARY_DIR}/Tests/CTestUpdateBZR_CLocale.cmake"
  1771. )
  1772. set_tests_properties(CTest.UpdateBZR.CLocale PROPERTIES ENVIRONMENT LC_ALL=C)
  1773. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${CTestUpdateBZR_DIR}")
  1774. endif()
  1775. endif()
  1776. # Test CTest Update with GIT
  1777. find_program(GIT_EXECUTABLE NAMES git)
  1778. mark_as_advanced(GIT_EXECUTABLE)
  1779. set(CTEST_TEST_UPDATE_GIT 0)
  1780. if(GIT_EXECUTABLE)
  1781. if(NOT "${GIT_EXECUTABLE}" MATCHES "cygwin" OR UNIX)
  1782. set(CTEST_TEST_UPDATE_GIT 1)
  1783. endif()
  1784. endif()
  1785. if(CTEST_TEST_UPDATE_GIT)
  1786. set(CTestUpdateGIT_DIR "CTest UpdateGIT")
  1787. configure_file("${CMake_SOURCE_DIR}/Tests/CTestUpdateGIT.cmake.in"
  1788. "${CMake_BINARY_DIR}/Tests/CTestUpdateGIT.cmake" @ONLY)
  1789. add_test(CTest.UpdateGIT ${CMAKE_CMAKE_COMMAND}
  1790. -P "${CMake_BINARY_DIR}/Tests/CTestUpdateGIT.cmake"
  1791. )
  1792. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${CTestUpdateGIT_DIR}")
  1793. endif()
  1794. # Test CTest Update with HG
  1795. find_program(HG_EXECUTABLE NAMES hg)
  1796. mark_as_advanced(HG_EXECUTABLE)
  1797. set(CTEST_TEST_UPDATE_HG 0)
  1798. if(HG_EXECUTABLE)
  1799. if(NOT "${HG_EXECUTABLE}" MATCHES "cygwin" OR UNIX)
  1800. set(CTEST_TEST_UPDATE_HG 1)
  1801. endif()
  1802. endif()
  1803. if(CTEST_TEST_UPDATE_HG)
  1804. set(CTestUpdateHG_DIR "CTest UpdateHG")
  1805. configure_file("${CMake_SOURCE_DIR}/Tests/CTestUpdateHG.cmake.in"
  1806. "${CMake_BINARY_DIR}/Tests/CTestUpdateHG.cmake" @ONLY)
  1807. add_test(CTest.UpdateHG ${CMAKE_CMAKE_COMMAND}
  1808. -P "${CMake_BINARY_DIR}/Tests/CTestUpdateHG.cmake"
  1809. )
  1810. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${CTestUpdateHG_DIR}")
  1811. endif()
  1812. # Test CTest Update with P4
  1813. find_program(P4_EXECUTABLE NAMES p4)
  1814. find_program(P4D_EXECUTABLE NAMES p4d)
  1815. mark_as_advanced(P4_EXECUTABLE P4D_EXECUTABLE)
  1816. set(CTEST_TEST_UPDATE_P4 0)
  1817. if(P4_EXECUTABLE AND P4D_EXECUTABLE)
  1818. if(NOT "${P4_EXECUTABLE};${P4D_EXECUTABLE}" MATCHES "cygwin" OR UNIX)
  1819. set(CTEST_TEST_UPDATE_P4 1)
  1820. endif()
  1821. endif()
  1822. if(CTEST_TEST_UPDATE_P4)
  1823. set(CTestUpdateP4_DIR "CTest UpdateP4")
  1824. configure_file("${CMake_SOURCE_DIR}/Tests/CTestUpdateP4.cmake.in"
  1825. "${CMake_BINARY_DIR}/Tests/CTestUpdateP4.cmake" @ONLY)
  1826. add_test(CTest.UpdateP4 ${CMAKE_CMAKE_COMMAND}
  1827. -P "${CMake_BINARY_DIR}/Tests/CTestUpdateP4.cmake"
  1828. )
  1829. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${CTestUpdateP4_DIR}")
  1830. endif()
  1831. endif()
  1832. configure_file(
  1833. "${CMake_SOURCE_DIR}/Tests/CTestTestFailure/testNoBuild.cmake.in"
  1834. "${CMake_BINARY_DIR}/Tests/CTestTestFailure/testNoBuild.cmake"
  1835. @ONLY ESCAPE_QUOTES)
  1836. add_test(CTestTestNoBuild ${CMAKE_CTEST_COMMAND}
  1837. -S "${CMake_BINARY_DIR}/Tests/CTestTestFailure/testNoBuild.cmake" -V
  1838. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestFailure/testOut1.log"
  1839. )
  1840. set_tests_properties(CTestTestNoBuild PROPERTIES
  1841. FAIL_REGULAR_EXPRESSION "Error" WILL_FAIL true)
  1842. configure_file(
  1843. "${CMake_SOURCE_DIR}/Tests/CTestTestFailure/testNoExe.cmake.in"
  1844. "${CMake_BINARY_DIR}/Tests/CTestTestFailure/testNoExe.cmake"
  1845. @ONLY ESCAPE_QUOTES)
  1846. add_test(CTestTestNoExe ${CMAKE_CTEST_COMMAND}
  1847. -S "${CMake_BINARY_DIR}/Tests/CTestTestFailure/testNoExe.cmake" -V
  1848. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestFailure/testOut2.log"
  1849. )
  1850. set_tests_properties(CTestTestNoExe PROPERTIES DEPENDS CTestTestNoBuild
  1851. PASS_REGULAR_EXPRESSION "Could not find executable"
  1852. FAIL_REGULAR_EXPRESSION "SegFault")
  1853. configure_file(
  1854. "${CMake_SOURCE_DIR}/Tests/CTestTestUpload/test.cmake.in"
  1855. "${CMake_BINARY_DIR}/Tests/CTestTestUpload/test.cmake"
  1856. @ONLY ESCAPE_QUOTES)
  1857. add_test(CTestTestUpload ${CMAKE_CTEST_COMMAND}
  1858. -S "${CMake_BINARY_DIR}/Tests/CTestTestUpload/test.cmake" -V
  1859. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestUpload/testOut.log"
  1860. )
  1861. set_tests_properties(CTestTestUpload PROPERTIES
  1862. PASS_REGULAR_EXPRESSION "Upload\\.xml")
  1863. configure_file(
  1864. "${CMake_SOURCE_DIR}/Tests/CTestTestEmptyBinaryDirectory/test.cmake.in"
  1865. "${CMake_BINARY_DIR}/Tests/CTestTestEmptyBinaryDirectory/test.cmake"
  1866. @ONLY ESCAPE_QUOTES)
  1867. add_test(CTestTestEmptyBinaryDirectory ${CMAKE_CTEST_COMMAND}
  1868. -S "${CMake_BINARY_DIR}/Tests/CTestTestEmptyBinaryDirectory/test.cmake" -V
  1869. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestEmptyBinaryDirectory/testOut.log"
  1870. )
  1871. set_tests_properties(CTestTestEmptyBinaryDirectory PROPERTIES
  1872. PASS_REGULAR_EXPRESSION "TEST_SUCCESS")
  1873. configure_file(
  1874. "${CMake_SOURCE_DIR}/Tests/CTestTestConfigFileInBuildDir/test1.cmake.in"
  1875. "${CMake_BINARY_DIR}/Tests/CTestTestConfigFileInBuildDir1/test1.cmake"
  1876. @ONLY ESCAPE_QUOTES)
  1877. add_test(CTestTestConfigFileInBuildDir1 ${CMAKE_CTEST_COMMAND}
  1878. -S "${CMake_BINARY_DIR}/Tests/CTestTestConfigFileInBuildDir1/test1.cmake" -V
  1879. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestConfigFileInBuildDir1/testOut1.log"
  1880. )
  1881. REGEX_ESCAPE_STRING(CTEST_TEST_ESCAPED_SOURCE_DIR "${CMake_SOURCE_DIR}")
  1882. set_tests_properties(CTestTestConfigFileInBuildDir1 PROPERTIES DEPENDS CTestTestNoBuild
  1883. PASS_REGULAR_EXPRESSION
  1884. "Reading ctest configuration file: ${CTEST_TEST_ESCAPED_SOURCE_DIR}.Tests.CTestTestConfigFileInBuildDir.CTestConfig.cmake")
  1885. configure_file(
  1886. "${CMake_SOURCE_DIR}/Tests/CTestTestConfigFileInBuildDir/test2.cmake.in"
  1887. "${CMake_BINARY_DIR}/Tests/CTestTestConfigFileInBuildDir2/test2.cmake"
  1888. @ONLY ESCAPE_QUOTES)
  1889. configure_file(
  1890. "${CMake_SOURCE_DIR}/Tests/CTestTestConfigFileInBuildDir/CTestConfig.cmake"
  1891. "${CMake_BINARY_DIR}/Tests/CTestTestConfigFileInBuildDir2/CTestConfig.cmake"
  1892. @ONLY ESCAPE_QUOTES COPYONLY)
  1893. add_test(CTestTestConfigFileInBuildDir2 ${CMAKE_CTEST_COMMAND}
  1894. -S "${CMake_BINARY_DIR}/Tests/CTestTestConfigFileInBuildDir2/test2.cmake" -V
  1895. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestConfigFileInBuildDir2/testOut2.log"
  1896. )
  1897. REGEX_ESCAPE_STRING(CTEST_TEST_ESCAPED_BINARY_DIR "${CMake_BINARY_DIR}")
  1898. set_tests_properties(CTestTestConfigFileInBuildDir2 PROPERTIES DEPENDS CTestTestNoBuild
  1899. REQUIRED_FILES ${CMake_BINARY_DIR}/Tests/CTestTestConfigFileInBuildDir2/CTestConfig.cmake
  1900. PASS_REGULAR_EXPRESSION
  1901. "Reading ctest configuration file: ${CTEST_TEST_ESCAPED_BINARY_DIR}.Tests.CTestTestConfigFileInBuildDir2.CTestConfig.cmake")
  1902. # test coverage for mumps
  1903. # create a MumpsCoverage dir in the binary tree under Testing to
  1904. # avoid the .NoDartCoverage files in the cmake testing tree
  1905. configure_file(
  1906. "${CMake_SOURCE_DIR}/Tests/MumpsCoverage/DartConfiguration.tcl.in"
  1907. "${CMake_BINARY_DIR}/Testing/MumpsCoverage/DartConfiguration.tcl")
  1908. configure_file(
  1909. "${CMake_SOURCE_DIR}/Tests/MumpsCoverage/gtm_coverage.mcov.in"
  1910. "${CMake_BINARY_DIR}/Testing/MumpsCoverage/gtm_coverage.mcov")
  1911. file(COPY "${CMake_SOURCE_DIR}/Tests/MumpsCoverage/VistA-FOIA"
  1912. DESTINATION "${CMake_BINARY_DIR}/Testing/MumpsCoverage")
  1913. add_test(NAME CTestGTMCoverage
  1914. COMMAND cmake -E chdir
  1915. ${CMake_BINARY_DIR}/Testing/MumpsCoverage
  1916. $<TARGET_FILE:ctest> -T Coverage --debug)
  1917. set_tests_properties(CTestGTMCoverage PROPERTIES
  1918. PASS_REGULAR_EXPRESSION
  1919. "Process file.*XINDEX.m.*Total LOC:.*127.*Percentage Coverage: 85.83.*"
  1920. ENVIRONMENT COVFILE=)
  1921. configure_file(
  1922. "${CMake_SOURCE_DIR}/Tests/MumpsCoverage/DartConfiguration.cache.tcl.in"
  1923. "${CMake_BINARY_DIR}/Testing/MumpsCacheCoverage/DartConfiguration.tcl")
  1924. configure_file(
  1925. "${CMake_SOURCE_DIR}/Tests/MumpsCoverage/cache_coverage.cmcov.in"
  1926. "${CMake_BINARY_DIR}/Testing/MumpsCacheCoverage/cache_coverage.cmcov")
  1927. file(COPY "${CMake_SOURCE_DIR}/Tests/MumpsCoverage/VistA-FOIA"
  1928. DESTINATION "${CMake_BINARY_DIR}/Testing/MumpsCacheCoverage")
  1929. add_test(NAME CTestCacheCoverage
  1930. COMMAND cmake -E chdir
  1931. ${CMake_BINARY_DIR}/Testing/MumpsCacheCoverage
  1932. $<TARGET_FILE:ctest> -T Coverage --debug)
  1933. set_tests_properties(CTestCacheCoverage PROPERTIES
  1934. PASS_REGULAR_EXPRESSION
  1935. "Process file.*XINDEX.m.*Total LOC:.*125.*Percentage Coverage: 85.60.*"
  1936. ENVIRONMENT COVFILE=)
  1937. # Adding a test case for Python Coverage
  1938. configure_file(
  1939. "${CMake_SOURCE_DIR}/Tests/PythonCoverage/coverage.xml.in"
  1940. "${CMake_BINARY_DIR}/Testing/PythonCoverage/coverage.xml")
  1941. configure_file(
  1942. "${CMake_SOURCE_DIR}/Tests/PythonCoverage/DartConfiguration.tcl.in"
  1943. "${CMake_BINARY_DIR}/Testing/PythonCoverage/DartConfiguration.tcl")
  1944. file(COPY "${CMake_SOURCE_DIR}/Tests/PythonCoverage/coveragetest"
  1945. DESTINATION "${CMake_BINARY_DIR}/Testing/PythonCoverage")
  1946. add_test(NAME CTestPythonCoverage
  1947. COMMAND cmake -E chdir
  1948. ${CMake_BINARY_DIR}/Testing/PythonCoverage
  1949. $<TARGET_FILE:ctest> -T Coverage --debug)
  1950. set_tests_properties(CTestPythonCoverage PROPERTIES
  1951. PASS_REGULAR_EXPRESSION
  1952. "Process file.*foo.py.*Total LOC:.*13.*Percentage Coverage: 84.62.*"
  1953. ENVIRONMENT COVFILE=)
  1954. function(add_config_tests cfg)
  1955. set(base "${CMake_BINARY_DIR}/Tests/CTestConfig")
  1956. # Test -S script with a -C config arg to ctest:
  1957. configure_file(
  1958. "${CMake_SOURCE_DIR}/Tests/CTestConfig/script.cmake.in"
  1959. "${base}/${cfg}-script.cmake"
  1960. @ONLY ESCAPE_QUOTES)
  1961. add_test(CTestConfig.Script.${cfg} ${CMAKE_CTEST_COMMAND}
  1962. -C ${cfg}
  1963. -S "${base}/${cfg}-script.cmake" -VV
  1964. --output-log "${base}/${cfg}-script.log"
  1965. )
  1966. # Test -D dashboard with a -C config arg to ctest.
  1967. # (Actual commands inside a cmake -P script because we need to be able to set
  1968. # the working directory reliably...)
  1969. configure_file(
  1970. "${CMake_SOURCE_DIR}/Tests/CTestConfig/dashboard.cmake.in"
  1971. "${base}/${cfg}-dashboard.cmake"
  1972. @ONLY ESCAPE_QUOTES)
  1973. add_test(CTestConfig.Dashboard.${cfg} ${CMAKE_CMAKE_COMMAND}
  1974. -P "${base}/${cfg}-dashboard.cmake" -VV
  1975. )
  1976. endfunction()
  1977. add_config_tests(Debug)
  1978. add_config_tests(MinSizeRel)
  1979. add_config_tests(Release)
  1980. add_config_tests(RelWithDebInfo)
  1981. # Test -S script with some -D variable definition args to ctest:
  1982. add_test(CTestConfig.ScriptWithArgs ${CMAKE_CTEST_COMMAND}
  1983. -C "Release"
  1984. -D arg1=this
  1985. -D arg2=that
  1986. -D "arg3=the other"
  1987. "-Darg4=this is the fourth"
  1988. -Darg5=the_fifth
  1989. -Darg6:STRING=value-with-type
  1990. -S "${CMake_SOURCE_DIR}/Tests/CTestConfig/ScriptWithArgs.cmake" -VV
  1991. --output-log "${CMake_BINARY_DIR}/Tests/CTestConfig/ScriptWithArgs.log"
  1992. )
  1993. ADD_TEST_MACRO(CMakeCommands.target_link_libraries target_link_libraries)
  1994. ADD_TEST_MACRO(CMakeCommands.target_include_directories target_include_directories)
  1995. ADD_TEST_MACRO(CMakeCommands.target_compile_definitions target_compile_definitions)
  1996. ADD_TEST_MACRO(CMakeCommands.target_compile_options target_compile_options)
  1997. configure_file(
  1998. "${CMake_SOURCE_DIR}/Tests/CTestTestCrash/test.cmake.in"
  1999. "${CMake_BINARY_DIR}/Tests/CTestTestCrash/test.cmake"
  2000. @ONLY ESCAPE_QUOTES)
  2001. add_test(CTestTestCrash ${CMAKE_CTEST_COMMAND}
  2002. -S "${CMake_BINARY_DIR}/Tests/CTestTestCrash/test.cmake" -V
  2003. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestCrash/testOutput.log"
  2004. )
  2005. # with watcom the SEGFAULT is not found, it just fails
  2006. if(CMAKE_TEST_GENERATOR MATCHES "Watcom WMake")
  2007. set_tests_properties(CTestTestCrash PROPERTIES
  2008. PASS_REGULAR_EXPRESSION "Failed")
  2009. else()
  2010. set_tests_properties(CTestTestCrash PROPERTIES
  2011. PASS_REGULAR_EXPRESSION "(Illegal|SegFault)")
  2012. endif()
  2013. configure_file(
  2014. "${CMake_SOURCE_DIR}/Tests/CTestTestBadExe/test.cmake.in"
  2015. "${CMake_BINARY_DIR}/Tests/CTestTestBadExe/test.cmake"
  2016. @ONLY ESCAPE_QUOTES)
  2017. add_test(CTestTestBadExe ${CMAKE_CTEST_COMMAND}
  2018. -S "${CMake_BINARY_DIR}/Tests/CTestTestBadExe/test.cmake" -V
  2019. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestBadExe/testOutput.log"
  2020. )
  2021. set(CTestTestBadExe_REGEX "BAD_COMMAND")
  2022. # some cygwin can not be made to produce a BAD_COMMAND error
  2023. # the best we can get from it is a failed test
  2024. if(CYGWIN)
  2025. set(CTestTestBadExe_REGEX "(\\*\\*\\*Failed)|BAD_COMMAND")
  2026. endif()
  2027. set_tests_properties(CTestTestBadExe PROPERTIES
  2028. PASS_REGULAR_EXPRESSION "${CTestTestBadExe_REGEX}")
  2029. configure_file(
  2030. "${CMake_SOURCE_DIR}/Tests/CTestTestParallel/test.cmake.in"
  2031. "${CMake_BINARY_DIR}/Tests/CTestTestParallel/test.cmake"
  2032. @ONLY ESCAPE_QUOTES)
  2033. add_test(CTestTestParallel ${CMAKE_CTEST_COMMAND}
  2034. -S "${CMake_BINARY_DIR}/Tests/CTestTestParallel/test.cmake" -V
  2035. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestParallel/testOutput.log"
  2036. )
  2037. ADD_TEST_MACRO(CTestTestSerialInDepends ${CMAKE_CTEST_COMMAND} -j 4
  2038. --output-on-failure -C "\${CTestTest_CONFIG}")
  2039. ADD_TEST_MACRO(CTestTestMissingDependsExe ${CMAKE_CTEST_COMMAND}
  2040. --output-on-failure -C "\${CTestTest_CONFIG}")
  2041. set_tests_properties(CTestTestMissingDependsExe PROPERTIES
  2042. PASS_REGULAR_EXPRESSION "\\*\\*\\*Not Run"
  2043. )
  2044. ADD_TEST_MACRO(CTestTestSerialOrder ${CMAKE_CTEST_COMMAND}
  2045. --output-on-failure -C "\${CTestTest_CONFIG}")
  2046. if(NOT BORLAND)
  2047. set(CTestLimitDashJ_CTEST_OPTIONS --force-new-ctest-process)
  2048. add_test_macro(CTestLimitDashJ ${CMAKE_CTEST_COMMAND} -j 4
  2049. --output-on-failure -C "\${CTestTest_CONFIG}")
  2050. endif()
  2051. add_test(CTestTestPrintLabels ${CMAKE_CTEST_COMMAND} --print-labels)
  2052. set_tests_properties(CTestTestPrintLabels PROPERTIES LABELS "Label1;Label2")
  2053. set_tests_properties(CTestTestPrintLabels PROPERTIES PASS_REGULAR_EXPRESSION
  2054. "All Labels:.* Label1.* Label2")
  2055. configure_file(
  2056. "${CMake_SOURCE_DIR}/Tests/CTestTestResourceLock/test.cmake.in"
  2057. "${CMake_BINARY_DIR}/Tests/CTestTestResourceLock/test.cmake"
  2058. @ONLY ESCAPE_QUOTES)
  2059. add_test(CTestTestResourceLock ${CMAKE_CTEST_COMMAND}
  2060. -S "${CMake_BINARY_DIR}/Tests/CTestTestResourceLock/test.cmake" -V
  2061. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestResourceLock/output.log"
  2062. )
  2063. configure_file(
  2064. "${CMake_SOURCE_DIR}/Tests/CTestTestScheduler/test.cmake.in"
  2065. "${CMake_BINARY_DIR}/Tests/CTestTestScheduler/test.cmake"
  2066. @ONLY ESCAPE_QUOTES)
  2067. add_test(CTestTestScheduler ${CMAKE_CTEST_COMMAND}
  2068. -S "${CMake_BINARY_DIR}/Tests/CTestTestScheduler/test.cmake" -V
  2069. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestScheduler/testOutput.log"
  2070. )
  2071. set_tests_properties(CTestTestScheduler PROPERTIES
  2072. PASS_REGULAR_EXPRESSION "Start 1.*Start 2.*Start 3.*Start 4.*Start 4.*Start 3.*Start 2.*Start 1"
  2073. RESOURCE_LOCK "CostData")
  2074. configure_file(
  2075. "${CMake_SOURCE_DIR}/Tests/CTestTestCostSerial/test.cmake.in"
  2076. "${CMake_BINARY_DIR}/Tests/CTestTestCostSerial/test.cmake"
  2077. @ONLY ESCAPE_QUOTES)
  2078. add_test(CTestTestCostSerial ${CMAKE_CTEST_COMMAND}
  2079. -S "${CMake_BINARY_DIR}/Tests/CTestTestCostSerial/test.cmake" -V
  2080. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestCostSerial/testOutput.log"
  2081. )
  2082. set_tests_properties(CTestTestCostSerial PROPERTIES
  2083. PASS_REGULAR_EXPRESSION "Start 2.*Start 3.*Start 1.*Start 2.*Start 3.*Start 1"
  2084. RESOURCE_LOCK "CostData")
  2085. configure_file(
  2086. "${CMake_SOURCE_DIR}/Tests/CTestTestStopTime/test.cmake.in"
  2087. "${CMake_BINARY_DIR}/Tests/CTestTestStopTime/test.cmake"
  2088. @ONLY ESCAPE_QUOTES)
  2089. configure_file(
  2090. "${CMake_SOURCE_DIR}/Tests/CTestTestStopTime/GetDate.cmake"
  2091. "${CMake_BINARY_DIR}/Tests/CTestTestStopTime/GetDate.cmake"
  2092. COPYONLY)
  2093. add_test(CTestTestStopTime ${CMAKE_CTEST_COMMAND}
  2094. -S "${CMake_BINARY_DIR}/Tests/CTestTestStopTime/test.cmake" -V
  2095. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestStopTime/testOutput.log"
  2096. )
  2097. set_tests_properties(CTestTestStopTime PROPERTIES
  2098. PASS_REGULAR_EXPRESSION "The stop time has been passed")
  2099. configure_file(
  2100. "${CMake_SOURCE_DIR}/Tests/CTestTestSubdir/test.cmake.in"
  2101. "${CMake_BINARY_DIR}/Tests/CTestTestSubdir/test.cmake"
  2102. @ONLY ESCAPE_QUOTES)
  2103. add_test(CTestTestSubdir ${CMAKE_CTEST_COMMAND}
  2104. -S "${CMake_BINARY_DIR}/Tests/CTestTestSubdir/test.cmake" -V
  2105. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestSubdir/testOutput.log"
  2106. )
  2107. #make sure all 3 subdirs were added
  2108. set_tests_properties(CTestTestSubdir PROPERTIES
  2109. PASS_REGULAR_EXPRESSION "0 tests failed out of 3")
  2110. configure_file(
  2111. "${CMake_SOURCE_DIR}/Tests/CTestTestTimeout/test.cmake.in"
  2112. "${CMake_BINARY_DIR}/Tests/CTestTestTimeout/test.cmake"
  2113. @ONLY ESCAPE_QUOTES)
  2114. add_test(CTestTestTimeout ${CMAKE_CTEST_COMMAND}
  2115. -C "\${CTestTest_CONFIG}"
  2116. -S "${CMake_BINARY_DIR}/Tests/CTestTestTimeout/test.cmake" -V
  2117. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestTimeout/testOutput.log"
  2118. )
  2119. set_tests_properties(CTestTestTimeout PROPERTIES
  2120. PASS_REGULAR_EXPRESSION "TestTimeout *\\.+ *\\*\\*\\*Timeout.*CheckChild *\\.+ *Passed")
  2121. add_test(
  2122. NAME CTestTestRerunFailed
  2123. COMMAND ${CMAKE_CTEST_COMMAND} --rerun-failed)
  2124. set_tests_properties(CTestTestRerunFailed PROPERTIES
  2125. PASS_REGULAR_EXPRESSION "1/1 Test #1: TestTimeout" DEPENDS CTestTestTimeout
  2126. WORKING_DIRECTORY ${CMake_BINARY_DIR}/Tests/CTestTestTimeout)
  2127. configure_file(
  2128. "${CMake_SOURCE_DIR}/Tests/CTestTestZeroTimeout/test.cmake.in"
  2129. "${CMake_BINARY_DIR}/Tests/CTestTestZeroTimeout/test.cmake"
  2130. @ONLY ESCAPE_QUOTES)
  2131. add_test(CTestTestZeroTimeout ${CMAKE_CTEST_COMMAND}
  2132. -S "${CMake_BINARY_DIR}/Tests/CTestTestZeroTimeout/test.cmake" -V
  2133. --output-log
  2134. "${CMake_BINARY_DIR}/Tests/CTestTestZeroTimeout/testOutput.log")
  2135. set_tests_properties(CTestTestZeroTimeout PROPERTIES
  2136. FAIL_REGULAR_EXPRESSION "\\*\\*\\*Timeout")
  2137. configure_file(
  2138. "${CMake_SOURCE_DIR}/Tests/CTestTestDepends/test.cmake.in"
  2139. "${CMake_BINARY_DIR}/Tests/CTestTestDepends/test.cmake"
  2140. @ONLY ESCAPE_QUOTES)
  2141. add_test(CTestTestDepends ${CMAKE_CTEST_COMMAND}
  2142. -C "\${CTestTest_CONFIG}"
  2143. -S "${CMake_BINARY_DIR}/Tests/CTestTestDepends/test.cmake" -V
  2144. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestDepends/testOutput.log"
  2145. )
  2146. configure_file(
  2147. "${CMake_SOURCE_DIR}/Tests/CTestTestCycle/test.cmake.in"
  2148. "${CMake_BINARY_DIR}/Tests/CTestTestCycle/test.cmake"
  2149. @ONLY ESCAPE_QUOTES)
  2150. add_test(CTestTestCycle ${CMAKE_CTEST_COMMAND}
  2151. -C "\${CTestTest_CONFIG}"
  2152. -S "${CMake_BINARY_DIR}/Tests/CTestTestCycle/test.cmake" -V
  2153. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestCycle/testOutput.log"
  2154. )
  2155. set_tests_properties(CTestTestCycle PROPERTIES
  2156. PASS_REGULAR_EXPRESSION "a cycle exists in the test dependency graph")
  2157. configure_file(
  2158. "${CMake_SOURCE_DIR}/Tests/CTestTestRunScript/test.cmake.in"
  2159. "${CMake_BINARY_DIR}/Tests/CTestTestRunScript/test.cmake"
  2160. @ONLY ESCAPE_QUOTES)
  2161. configure_file(
  2162. "${CMake_SOURCE_DIR}/Tests/CTestTestRunScript/hello.cmake.in"
  2163. "${CMake_BINARY_DIR}/Tests/CTestTestRunScript/hello.cmake"
  2164. @ONLY ESCAPE_QUOTES)
  2165. add_test(CTestTestRunScript ${CMAKE_CTEST_COMMAND}
  2166. -S "${CMake_BINARY_DIR}/Tests/CTestTestRunScript/test.cmake" -V
  2167. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestRunScript/testOutput.log"
  2168. )
  2169. add_test(CTestTestShowOnly ${CMAKE_CTEST_COMMAND} -N)
  2170. add_test(CTestBatchTest ${CMAKE_CTEST_COMMAND} -B)
  2171. configure_file(
  2172. "${CMake_SOURCE_DIR}/Tests/CTestTestFdSetSize/test.cmake.in"
  2173. "${CMake_BINARY_DIR}/Tests/CTestTestFdSetSize/test.cmake"
  2174. @ONLY ESCAPE_QUOTES)
  2175. add_test(CTestTestFdSetSize ${CMAKE_CTEST_COMMAND}
  2176. -S "${CMake_BINARY_DIR}/Tests/CTestTestFdSetSize/test.cmake" -j20 -V --timeout 120
  2177. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestFdSetSize/testOutput.log"
  2178. )
  2179. function(add_failed_submit_test name source build in out log regex)
  2180. configure_file("${in}" "${out}" @ONLY)
  2181. add_test(${name} ${CMAKE_CTEST_COMMAND} -S "${out}" -V --output-log "${log}")
  2182. set_tests_properties(${name} PROPERTIES PASS_REGULAR_EXPRESSION "${regex}")
  2183. endfunction()
  2184. set(regex "(Problems when submitting via S*CP")
  2185. set(regex "${regex}|Error message was: ")
  2186. set(regex "${regex}([Cc]ould *n.t resolve host")
  2187. set(regex "${regex}|[Cc]ould *n.t connect to host")
  2188. set(regex "${regex}|Empty reply from server")
  2189. set(regex "${regex}|The requested URL returned error")
  2190. set(regex "${regex}|libcurl was built with SSL disabled. https: not supported)")
  2191. set(regex "${regex}|Submission method .xmlrpc. not compiled into CTest")
  2192. set(regex "${regex}|Submission problem")
  2193. set(regex "${regex}|Submission successful)")
  2194. set(ctest_coverage_labels_args "")
  2195. foreach(drop_method cp ftp http https scp xmlrpc)
  2196. # Cycle through these values each time through the loop:
  2197. if(ctest_coverage_labels_args STREQUAL "")
  2198. set(ctest_coverage_labels_args "LABELS Everything")
  2199. elseif(ctest_coverage_labels_args STREQUAL "LABELS Everything")
  2200. set(ctest_coverage_labels_args "LABELS 0ArgTest")
  2201. else()
  2202. set(ctest_coverage_labels_args "")
  2203. endif()
  2204. add_failed_submit_test(CTestTestFailedSubmit-${drop_method}
  2205. "${CMake_SOURCE_DIR}/Tests/CTestTest/SmallAndFast"
  2206. "${CMake_BINARY_DIR}/Tests/CTestTestFailedSubmits/${drop_method}"
  2207. "${CMake_SOURCE_DIR}/Tests/CTestTestFailedSubmits/test.cmake.in"
  2208. "${CMake_BINARY_DIR}/Tests/CTestTestFailedSubmits/test-${drop_method}.cmake"
  2209. "${CMake_BINARY_DIR}/Tests/CTestTestFailedSubmits/test-${drop_method}.log"
  2210. "${regex}"
  2211. )
  2212. endforeach()
  2213. if (CMAKE_TESTS_CDASH_SERVER)
  2214. set(regex "^([^:]+)://([^/]+)(/.*)$")
  2215. if ("${CMAKE_TESTS_CDASH_SERVER}" MATCHES "${regex}")
  2216. set(protocol "${CMAKE_MATCH_1}")
  2217. set(server "${CMAKE_MATCH_2}")
  2218. set(path "${CMAKE_MATCH_3}")
  2219. else ()
  2220. set(protocol "http")
  2221. set(server "www.cdash.org")
  2222. set(path "/CDash")
  2223. message("warning: CMAKE_TESTS_CDASH_SERVER does not match expected regex...")
  2224. message(" ...using default url='${protocol}://${server}${path}' for CTestTest[23]")
  2225. endif ()
  2226. endif ()
  2227. if (CTEST_TEST_CTEST AND CMAKE_RUN_LONG_TESTS AND CMAKE_TESTS_CDASH_SERVER)
  2228. configure_file("${CMake_SOURCE_DIR}/Tests/CTestTest/test.cmake.in"
  2229. "${CMake_BINARY_DIR}/Tests/CTestTest/test.cmake" @ONLY ESCAPE_QUOTES)
  2230. add_test(CTestTest ${CMAKE_CTEST_COMMAND}
  2231. -S "${CMake_BINARY_DIR}/Tests/CTestTest/test.cmake" -V
  2232. --output-log "${CMake_BINARY_DIR}/Tests/CTestTest/testOutput.log"
  2233. )
  2234. configure_file("${CMake_SOURCE_DIR}/Tests/CTestTest2/test.cmake.in"
  2235. "${CMake_BINARY_DIR}/Tests/CTestTest2/test.cmake" @ONLY ESCAPE_QUOTES)
  2236. add_test(CTestTest2 ${CMAKE_CTEST_COMMAND}
  2237. -S "${CMake_BINARY_DIR}/Tests/CTestTest2/test.cmake" -V
  2238. --output-log "${CMake_BINARY_DIR}/Tests/CTestTest2/testOutput.log"
  2239. )
  2240. if("${CMAKE_TEST_GENERATOR}" MATCHES "Makefiles" OR "${CMAKE_TEST_GENERATOR}" MATCHES "Ninja")
  2241. configure_file("${CMake_SOURCE_DIR}/Tests/CTestTestLaunchers/test.cmake.in"
  2242. "${CMake_BINARY_DIR}/Tests/CTestTestLaunchers/test.cmake" @ONLY ESCAPE_QUOTES)
  2243. add_test(CTestTestLaunchers ${CMAKE_CTEST_COMMAND}
  2244. -S "${CMake_BINARY_DIR}/Tests/CTestTestLaunchers/test.cmake" -V
  2245. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestLaunchers/testOutput.log"
  2246. )
  2247. set_tests_properties(CTestTestLaunchers PROPERTIES
  2248. PASS_REGULAR_EXPRESSION "CTEST_TEST_LAUNCHER_SUCCESS")
  2249. endif()
  2250. configure_file("${CMake_SOURCE_DIR}/Tests/CTestTestChecksum/test.cmake.in"
  2251. "${CMake_BINARY_DIR}/Tests/CTestTestChecksum/test.cmake" @ONLY
  2252. ESCAPE_QUOTES)
  2253. add_test(CTestTestChecksum ${CMAKE_CTEST_COMMAND}
  2254. -S "${CMake_BINARY_DIR}/Tests/CTestTestChecksum/test.cmake" -V
  2255. --output-log
  2256. "${CMake_BINARY_DIR}/Tests/CTestTestChecksum/testOutput.log"
  2257. )
  2258. set_tests_properties(CTestTestChecksum PROPERTIES PASS_REGULAR_EXPRESSION
  2259. "Submission failed: Checksum failed for file")
  2260. # these tests take a long time, make sure they have it
  2261. # if timeouts have not already been set
  2262. get_test_property(CTestTest TIMEOUT PREVIOUS_TIMEOUT)
  2263. if ("${PREVIOUS_TIMEOUT}" MATCHES NOTFOUND)
  2264. set_tests_properties ( CTestTest
  2265. PROPERTIES TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT})
  2266. endif ()
  2267. get_test_property(CTestTest2 TIMEOUT PREVIOUS_TIMEOUT)
  2268. if ("${PREVIOUS_TIMEOUT}" MATCHES NOTFOUND)
  2269. set_tests_properties ( CTestTest2
  2270. PROPERTIES TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT})
  2271. endif ()
  2272. endif ()
  2273. if("${CMAKE_TEST_GENERATOR}" MATCHES Xcode)
  2274. set(CMAKE_SKIP_BOOTSTRAP_TEST 1)
  2275. endif()
  2276. if(EXISTS "${CMake_BINARY_DIR}/CMakeLists.txt")
  2277. # If there is CMakeLists.txt in the binary tree, assume in-source build
  2278. set(CMAKE_SKIP_BOOTSTRAP_TEST 1)
  2279. endif()
  2280. set(bootstrap "")
  2281. if(CMAKE_RUN_LONG_TESTS AND NOT CMAKE_SKIP_BOOTSTRAP_TEST)
  2282. if(UNIX)
  2283. set(bootstrap ${CMake_SOURCE_DIR}/bootstrap)
  2284. elseif(MSYS)
  2285. configure_file(${CMAKE_CURRENT_SOURCE_DIR}/bootstrap.bat.in
  2286. ${CMAKE_CURRENT_BINARY_DIR}/bootstrap.bat @ONLY)
  2287. set(bootstrap ${CMAKE_CURRENT_BINARY_DIR}/bootstrap.bat)
  2288. endif()
  2289. endif()
  2290. if(bootstrap)
  2291. add_test(NAME BootstrapTest
  2292. COMMAND ${CMAKE_CMAKE_COMMAND}
  2293. -D "bootstrap=${bootstrap}"
  2294. -D "bin_dir=${CMake_BINARY_DIR}/Tests/BootstrapTest"
  2295. -P ${CMAKE_CURRENT_SOURCE_DIR}/BootstrapTest.cmake
  2296. )
  2297. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/BootstrapTest")
  2298. # Make this test run early during parallel execution
  2299. set_tests_properties(BootstrapTest PROPERTIES COST 5000)
  2300. # provide more time for the bootstrap test
  2301. get_test_property(BootstrapTest TIMEOUT PREVIOUS_TIMEOUT)
  2302. if ("${PREVIOUS_TIMEOUT}" MATCHES NOTFOUND)
  2303. set_tests_properties ( BootstrapTest
  2304. PROPERTIES TIMEOUT 5400)
  2305. endif ()
  2306. endif()
  2307. if(CMAKE_Fortran_COMPILER)
  2308. add_test(Fortran ${CMAKE_CTEST_COMMAND}
  2309. --build-and-test
  2310. "${CMake_SOURCE_DIR}/Tests/Fortran"
  2311. "${CMake_BINARY_DIR}/Tests/Fortran"
  2312. ${build_generator_args}
  2313. --build-project testf
  2314. --build-two-config
  2315. --build-options ${build_options}
  2316. -DCMAKE_TEST_MAKEPROGRAM:FILEPATH=${CMAKE_TEST_MAKEPROGRAM}
  2317. --test-command testf)
  2318. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Fortran")
  2319. # FortranCInterface tests.
  2320. if(UNIX)
  2321. configure_file(${CMAKE_CURRENT_SOURCE_DIR}/FortranC/Flags.cmake.in
  2322. ${CMAKE_CURRENT_BINARY_DIR}/FortranC/Flags.cmake @ONLY)
  2323. add_test(FortranC.Flags ${CMAKE_CMAKE_COMMAND} -P
  2324. ${CMAKE_CURRENT_BINARY_DIR}/FortranC/Flags.cmake)
  2325. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/FortranC/Flags")
  2326. else()
  2327. add_test(FortranC ${CMAKE_CTEST_COMMAND}
  2328. --build-and-test
  2329. "${CMake_SOURCE_DIR}/Tests/FortranC"
  2330. "${CMake_BINARY_DIR}/Tests/FortranC"
  2331. ${build_generator_args}
  2332. --build-project FortranC
  2333. --build-two-config
  2334. --build-options ${build_options}
  2335. --test-command CMakeFiles/FortranCInterface/FortranCInterface)
  2336. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/FortranC")
  2337. endif()
  2338. endif()
  2339. find_package(Java COMPONENTS Development QUIET)
  2340. if(Java_JAVA_EXECUTABLE AND Java_JAVAC_EXECUTABLE AND Java_JAR_EXECUTABLE AND NOT MINGW
  2341. AND NOT "${CMAKE_TEST_GENERATOR}" MATCHES "Xcode")
  2342. get_filename_component(JNIPATH ${JAVA_COMPILE} PATH)
  2343. find_file(JNI_H jni.h
  2344. "${JNIPATH}/../include"
  2345. "${JNIPATH}/../java/include")
  2346. if(JNI_H AND EXISTS "${JNI_H}") # in case jni.h is a broken symlink
  2347. file(READ "${JNI_H}" JNI_FILE)
  2348. if("${JNI_FILE}" MATCHES "JDK1_2")
  2349. add_test(Java ${CMAKE_CTEST_COMMAND}
  2350. --build-and-test
  2351. "${CMake_SOURCE_DIR}/Tests/Java"
  2352. "${CMake_BINARY_DIR}/Tests/Java"
  2353. ${build_generator_args}
  2354. --build-project hello
  2355. --build-two-config
  2356. --build-run-dir "${CMake_BINARY_DIR}/Tests/Java/"
  2357. --build-options ${build_options}
  2358. --test-command ${JAVA_RUNTIME} -classpath hello.jar HelloWorld)
  2359. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Java")
  2360. endif()
  2361. endif()
  2362. endif()
  2363. # add some cross compiler tests, for now only with makefile based generators
  2364. if(CMAKE_TEST_GENERATOR MATCHES "Makefiles" OR CMAKE_TEST_GENERATOR MATCHES "KDevelop")
  2365. # if sdcc is found, build the SimpleCOnly project with sdcc
  2366. find_program(SDCC_EXECUTABLE sdcc)
  2367. mark_as_advanced(SDCC_EXECUTABLE)
  2368. if(SDCC_EXECUTABLE)
  2369. add_test(SimpleCOnly_sdcc ${CMAKE_CTEST_COMMAND}
  2370. --build-and-test
  2371. "${CMake_SOURCE_DIR}/Tests/SimpleCOnly"
  2372. "${CMake_BINARY_DIR}/Tests/SimpleCOnly_sdcc"
  2373. ${build_generator_args}
  2374. --build-project SimpleC
  2375. --build-options ${build_options}
  2376. "-DCMAKE_SYSTEM_NAME=Generic"
  2377. "-DCMAKE_C_COMPILER=${SDCC_EXECUTABLE}")
  2378. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/SimpleCOnly_sdcc")
  2379. endif()
  2380. # If a Linux -> MinGW cross compiler is found then try it
  2381. find_program(MINGW_CC_LINUX2WIN_EXECUTABLE i586-mingw32msvc-gcc)
  2382. find_program(MINGW_CXX_LINUX2WIN_EXECUTABLE i586-mingw32msvc-g++)
  2383. find_program(MINGW_RC_LINUX2WIN_EXECUTABLE i586-mingw32msvc-windres)
  2384. mark_as_advanced(MINGW_CC_LINUX2WIN_EXECUTABLE MINGW_CXX_LINUX2WIN_EXECUTABLE MINGW_RC_LINUX2WIN_EXECUTABLE)
  2385. if(MINGW_CC_LINUX2WIN_EXECUTABLE AND MINGW_CXX_LINUX2WIN_EXECUTABLE AND MINGW_RC_LINUX2WIN_EXECUTABLE)
  2386. add_test(Simple_Mingw_Linux2Win ${CMAKE_CTEST_COMMAND}
  2387. --build-and-test
  2388. "${CMake_SOURCE_DIR}/Tests/Simple"
  2389. "${CMake_BINARY_DIR}/Tests/Simple_Mingw_Linux2Win"
  2390. ${build_generator_args}
  2391. --build-project Simple
  2392. --build-options ${build_options}
  2393. "-DCMAKE_SYSTEM_NAME=Windows"
  2394. "-DCMAKE_C_COMPILER=${MINGW_CC_LINUX2WIN_EXECUTABLE}"
  2395. "-DCMAKE_CXX_COMPILER=${MINGW_CXX_LINUX2WIN_EXECUTABLE}"
  2396. "-DCMAKE_RC_COMPILER=${MINGW_RC_LINUX2WIN_EXECUTABLE}"
  2397. )
  2398. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Simple_Mingw_Linux2Win")
  2399. endif()
  2400. endif()
  2401. if(CMAKE_TEST_PROJECT_CSE_DIR)
  2402. set(script "${CMAKE_TEST_PROJECT_CSE_DIR}/BuildProjectCSE.cmake")
  2403. if(NOT EXISTS "${script}")
  2404. set(script "${CMAKE_TEST_PROJECT_CSE_DIR}/cse_build.cmake")
  2405. endif()
  2406. if(NOT EXISTS "${script}")
  2407. message("warning: CMAKE_TEST_PROJECT_CSE_DIR set, but no build script found...")
  2408. endif()
  2409. add_test(BuildCSE ${CMAKE_CTEST_COMMAND} -V -S "${script}")
  2410. set_tests_properties(BuildCSE PROPERTIES TIMEOUT 5400)
  2411. endif()
  2412. if(CMAKE_TEST_PLPLOT_DIR)
  2413. add_test(plplot ${CMAKE_CTEST_COMMAND} -V -S ${CMAKE_TEST_PLPLOT_DIR}/../../EasyDashboardScripts/plplot.cmake )
  2414. set_tests_properties ( plplot PROPERTIES TIMEOUT 5400)
  2415. endif()
  2416. if(CMAKE_TEST_CHICKEN_DIR)
  2417. add_test(Chicken ${CMAKE_CTEST_COMMAND} -V -S ${CMAKE_TEST_CHICKEN_DIR}/../../EasyDashboardScripts/Chicken.cmake )
  2418. set_tests_properties ( Chicken PROPERTIES TIMEOUT 5400)
  2419. endif()
  2420. if(CMAKE_TEST_KDELIBS_ALPHA_1_DIR)
  2421. add_test(KDELibsAlpha1 ${CMAKE_CTEST_COMMAND} -V -S ${CMAKE_TEST_KDELIBS_ALPHA_1_DIR}/../../EasyDashboardScripts/kdelibs.cmake )
  2422. set_tests_properties ( KDELibsAlpha1 PROPERTIES TIMEOUT 5400)
  2423. endif()
  2424. # If this is not an in-source build, provide a target to wipe out
  2425. # all the test build directories.
  2426. if(NOT EXISTS "${CMake_BINARY_DIR}/CMakeLists.txt")
  2427. configure_file(${CMake_SOURCE_DIR}/Tests/test_clean.cmake.in
  2428. ${CMake_BINARY_DIR}/Tests/test_clean.cmake @ONLY)
  2429. add_custom_target(test_clean
  2430. COMMAND ${CMAKE_COMMAND} -P ${CMake_BINARY_DIR}/Tests/test_clean.cmake
  2431. COMMENT "Removing test build directories."
  2432. )
  2433. endif()
  2434. add_test(NAME CMakeWizardTest COMMAND cmake -i)
  2435. set_property(TEST CMakeWizardTest PROPERTY PASS_REGULAR_EXPRESSION
  2436. "The \"cmake -i\" wizard mode is no longer supported.")
  2437. # If the cache variable CMAKE_CONTRACT_PROJECTS is set
  2438. # then the dashboard will run a contract with CMake test of that
  2439. # name. For example CMAKE_CONTRACT_PROJECTS = vtk542 would run
  2440. # the vtk542 contract test.
  2441. # For each Contract test, the project should provide a directory
  2442. # with at least one CMakeLists.txt file that uses ExternalProject
  2443. # to download and configure the project. The directory should also
  2444. # contain a RunTest.cmake file that has a single set of the format:
  2445. # set(project_RUN_TEST testToRun)
  2446. # The testToRun should be a test executable that can be run to
  2447. # smoke test the build.
  2448. foreach(project ${CMAKE_CONTRACT_PROJECTS})
  2449. include(Contracts/${project}/RunTest.cmake)
  2450. ADD_TEST_MACRO(Contracts.${project}
  2451. ${${project}_RUN_TEST})
  2452. # Contract test timeout in seconds.
  2453. # Default to 6 hours.
  2454. if(DEFINED ${project}_TEST_TIMEOUT)
  2455. set(timeout ${${project}_TEST_TIMEOUT})
  2456. elseif(CMAKE_CONTRACT_TEST_TIMEOUT_DEFAULT)
  2457. set(timeout ${CMAKE_CONTRACT_TEST_TIMEOUT_DEFAULT})
  2458. else()
  2459. set(timeout 21600)
  2460. endif()
  2461. set_tests_properties(Contracts.${project} PROPERTIES TIMEOUT ${timeout})
  2462. endforeach()
  2463. if(TEST_CompileCommandOutput)
  2464. set(CompileCommandOutput_BUILD_OPTIONS
  2465. -DMAKE_SUPPORTS_SPACES=${MAKE_SUPPORTS_SPACES})
  2466. ADD_TEST_MACRO(CompileCommandOutput
  2467. "${CMake_BINARY_DIR}/Tests/CMakeLib/runcompilecommands")
  2468. endif()
  2469. add_test(IncludeDirectories ${CMAKE_CTEST_COMMAND}
  2470. --build-and-test
  2471. "${CMake_SOURCE_DIR}/Tests/IncludeDirectories"
  2472. "${CMake_BINARY_DIR}/Tests/IncludeDirectories"
  2473. --build-two-config
  2474. ${build_generator_args}
  2475. --build-project IncludeDirectories
  2476. --build-options ${build_options}
  2477. --test-command IncludeDirectories)
  2478. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/IncludeDirectories")
  2479. add_test(InterfaceLinkLibraries ${CMAKE_CTEST_COMMAND}
  2480. --build-and-test
  2481. "${CMake_SOURCE_DIR}/Tests/InterfaceLinkLibraries"
  2482. "${CMake_BINARY_DIR}/Tests/InterfaceLinkLibraries"
  2483. --build-two-config
  2484. ${build_generator_args}
  2485. --build-project InterfaceLinkLibraries
  2486. --build-options ${build_options}
  2487. --test-command InterfaceLinkLibraries)
  2488. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/InterfaceLinkLibraries")
  2489. if(CMAKE_USE_KWSTYLE AND KWSTYLE_EXECUTABLE)
  2490. # The "make StyleCheck" command line as a test. If the test fails, look
  2491. # for lines like "Error #0 (624) Line length exceed 88 (max=79)" in the
  2492. # output to find where the style errors are...
  2493. add_test(KWStyle ${KWSTYLE_EXECUTABLE}
  2494. -xml ${CMake_BINARY_DIR}/CMake.kws.xml
  2495. -o ${CMake_SOURCE_DIR}/Utilities/KWStyle/CMakeOverwrite.txt
  2496. -v
  2497. -D ${CMake_BINARY_DIR}/CMakeKWSFiles.txt
  2498. )
  2499. set_tests_properties(KWStyle PROPERTIES
  2500. WORKING_DIRECTORY ${CMake_BINARY_DIR}/Utilities/KWStyle)
  2501. endif()
  2502. add_subdirectory(CMakeTests)
  2503. endif()