CMakeLists.txt 131 KB

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