CMakeLists.txt 126 KB

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