CMakeLists.txt 143 KB

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