RunCMakeTest.cmake 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. include(RunCMake)
  2. set(RunCMake_TEST_NO_CLEAN TRUE)
  3. set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/AutoExport-build")
  4. # start by cleaning up because we don't clean up along the way
  5. file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
  6. # configure the AutoExport test
  7. run_cmake(AutoExport)
  8. unset(RunCMake_TEST_OPTIONS)
  9. # don't run this test on Watcom or Borland make as it is not supported
  10. if(RunCMake_GENERATOR MATCHES "Watcom WMake|Borland Makefiles")
  11. return()
  12. endif()
  13. if(RunCMake_GENERATOR MATCHES "Ninja|Visual Studio" AND
  14. CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
  15. set(EXPORTS TRUE)
  16. endif()
  17. # we build debug so the say.exe will be found in Debug/say.exe for
  18. # Visual Studio generators
  19. if(RunCMake_GENERATOR_IS_MULTI_CONFIG)
  20. set(INTDIR "Debug/")
  21. endif()
  22. # build AutoExport
  23. run_cmake_command(AutoExportBuild ${CMAKE_COMMAND} --build
  24. ${RunCMake_TEST_BINARY_DIR} --config Debug --clean-first)
  25. # save the current timestamp of exports.def
  26. if(EXPORTS)
  27. set(EXPORTS_DEF "${RunCMake_TEST_BINARY_DIR}/say.dir/${INTDIR}exports.def")
  28. if(NOT EXISTS "${EXPORTS_DEF}")
  29. set(EXPORTS_DEF
  30. "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/say.dir/${INTDIR}exports.def")
  31. endif()
  32. file(TIMESTAMP "${EXPORTS_DEF}" timestamp)
  33. if(NOT timestamp)
  34. message(SEND_ERROR "Could not get timestamp for \"${EXPORTS_DEF}\"")
  35. endif()
  36. endif()
  37. # run the executable that uses symbols from the dll
  38. if(WIN32)
  39. set(EXE_EXT ".exe")
  40. endif()
  41. run_cmake_command(AutoExportRun
  42. ${RunCMake_TEST_BINARY_DIR}/bin/${INTDIR}say${EXE_EXT})
  43. # build AutoExport again without modification
  44. run_cmake_command(AutoExportBuildAgain ${CMAKE_COMMAND} --build
  45. ${RunCMake_TEST_BINARY_DIR} --config Debug)
  46. # compare timestamps of exports.def to make sure it has not been updated
  47. if(EXPORTS)
  48. file(TIMESTAMP "${EXPORTS_DEF}" timestamp_after)
  49. if(NOT timestamp_after)
  50. message(SEND_ERROR "Could not get timestamp for \"${EXPORTS_DEF}\"")
  51. endif()
  52. if (timestamp_after STREQUAL timestamp)
  53. message(STATUS "AutoExportTimeStamp - PASSED")
  54. else()
  55. message(SEND_ERROR "\"${EXPORTS_DEF}\" has been updated.")
  56. endif()
  57. endif()