summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/AutoExportDll
diff options
context:
space:
mode:
authorDaniel Eiband <daniel.eiband@brainlab.com>2019-08-28 11:57:52 (GMT)
committerDaniel Eiband <daniel.eiband@brainlab.com>2019-09-09 13:43:15 (GMT)
commitff5028c5318c5d404390d8114d9453fc81fa9a33 (patch)
treeba70af3296671bcb05410ec2e53acb5421eaa4f6 /Tests/RunCMake/AutoExportDll
parent6db8f6a410d99e9a66847530bb520b329d2f1a9e (diff)
downloadCMake-ff5028c5318c5d404390d8114d9453fc81fa9a33.zip
CMake-ff5028c5318c5d404390d8114d9453fc81fa9a33.tar.gz
CMake-ff5028c5318c5d404390d8114d9453fc81fa9a33.tar.bz2
Windows: Prevent auto exports to be regenerated on every build
Check modified time stamps of input files against an existing exports file before generating the auto exports. Fixes: #19650
Diffstat (limited to 'Tests/RunCMake/AutoExportDll')
-rw-r--r--Tests/RunCMake/AutoExportDll/RunCMakeTest.cmake35
1 files changed, 33 insertions, 2 deletions
diff --git a/Tests/RunCMake/AutoExportDll/RunCMakeTest.cmake b/Tests/RunCMake/AutoExportDll/RunCMakeTest.cmake
index 27a609d..6c9be4b 100644
--- a/Tests/RunCMake/AutoExportDll/RunCMakeTest.cmake
+++ b/Tests/RunCMake/AutoExportDll/RunCMakeTest.cmake
@@ -7,9 +7,13 @@ file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
run_cmake(AutoExport)
unset(RunCMake_TEST_OPTIONS)
# don't run this test on Watcom or Borland make as it is not supported
-if("${RunCMake_GENERATOR}" MATCHES "Watcom WMake|Borland Makefiles")
+if(RunCMake_GENERATOR MATCHES "Watcom WMake|Borland Makefiles")
return()
endif()
+if(RunCMake_GENERATOR MATCHES "Ninja|Visual Studio" AND
+ CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
+ set(EXPORTS TRUE)
+endif()
# we build debug so the say.exe will be found in Debug/say.exe for
# Visual Studio generators
if(RunCMake_GENERATOR_IS_MULTI_CONFIG)
@@ -18,9 +22,36 @@ endif()
# build AutoExport
run_cmake_command(AutoExportBuild ${CMAKE_COMMAND} --build
${RunCMake_TEST_BINARY_DIR} --config Debug --clean-first)
+# save the current timestamp of exports.def
+if(EXPORTS)
+ set(EXPORTS_DEF "${RunCMake_TEST_BINARY_DIR}/say.dir/${INTDIR}exports.def")
+ if(NOT EXISTS "${EXPORTS_DEF}")
+ set(EXPORTS_DEF
+ "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/say.dir/${INTDIR}exports.def")
+ endif()
+ file(TIMESTAMP "${EXPORTS_DEF}" timestamp)
+ if(NOT timestamp)
+ message(SEND_ERROR "Could not get timestamp for \"${EXPORTS_DEF}\"")
+ endif()
+endif()
# run the executable that uses symbols from the dll
if(WIN32)
set(EXE_EXT ".exe")
endif()
run_cmake_command(AutoExportRun
- ${RunCMake_BINARY_DIR}/AutoExport-build/bin/${INTDIR}say${EXE_EXT})
+ ${RunCMake_TEST_BINARY_DIR}/bin/${INTDIR}say${EXE_EXT})
+# build AutoExport again without modification
+run_cmake_command(AutoExportBuildAgain ${CMAKE_COMMAND} --build
+ ${RunCMake_TEST_BINARY_DIR} --config Debug)
+# compare timestamps of exports.def to make sure it has not been updated
+if(EXPORTS)
+ file(TIMESTAMP "${EXPORTS_DEF}" timestamp_after)
+ if(NOT timestamp_after)
+ message(SEND_ERROR "Could not get timestamp for \"${EXPORTS_DEF}\"")
+ endif()
+ if (timestamp_after STREQUAL timestamp)
+ message(STATUS "AutoExportTimeStamp - PASSED")
+ else()
+ message(SEND_ERROR "\"${EXPORTS_DEF}\" has been updated.")
+ endif()
+endif()