reduce compile time after each time cmake configure is executed (Version.h)

This commit is contained in:
wmayer
2018-08-21 14:06:33 +02:00
parent 4211defb4a
commit 3927a2ed8b
3 changed files with 23 additions and 16 deletions

View File

@@ -27,22 +27,24 @@ MACRO (fc_copy_sources target_name outpath)
ENDMACRO(fc_copy_sources)
MACRO (fc_copy_file_if_different inputfile outputfile)
if (EXISTS ${outputfile})
execute_process(
COMMAND ${CMAKE_COMMAND} -E compare_files ${inputfile}
${outputfile}
RESULT_VARIABLE DIFFERENT_FILES
OUTPUT_QUIET
ERROR_QUIET
)
if (EXISTS ${inputfile})
if (EXISTS ${outputfile})
execute_process(
COMMAND ${CMAKE_COMMAND} -E compare_files ${inputfile}
${outputfile}
RESULT_VARIABLE DIFFERENT_FILES
OUTPUT_QUIET
ERROR_QUIET
)
if (DIFFERENT_FILES)
if (DIFFERENT_FILES)
execute_process(COMMAND "${CMAKE_COMMAND}" -E copy "${inputfile}"
"${outputfile}")
endif()
else()
execute_process(COMMAND "${CMAKE_COMMAND}" -E copy "${inputfile}"
"${outputfile}")
endif()
else()
execute_process(COMMAND "${CMAKE_COMMAND}" -E copy "${inputfile}"
"${outputfile}")
endif()
ENDMACRO(fc_copy_file_if_different)

View File

@@ -15,6 +15,11 @@ EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/src/Tools/SubWC
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_STRIP_TRAILING_WHITESPACE)
fc_copy_file_if_different(
"${CMAKE_CURRENT_BINARY_DIR}/Version.h.out"
"${CMAKE_CURRENT_BINARY_DIR}/Version.h"
)
# as fallback if Version.h isn't created for any reason
if (NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/Version.h)
set(PACKAGE_WCREF ${PACKAGE_VERSION_PATCH})

View File

@@ -74,7 +74,7 @@ class VersionControl:
class UnknownControl(VersionControl):
def extractInfo(self, srcdir):
# Do not overwrite existing file with almost useless information
if os.path.exists(srcdir+"/src/Build/Version.h"):
if os.path.exists(srcdir+"/src/Build/Version.h.out"):
return False
self.rev = "Unknown"
self.date = "Unknown"
@@ -87,7 +87,7 @@ class UnknownControl(VersionControl):
class DebianChangelog(VersionControl):
def extractInfo(self, srcdir):
# Do not overwrite existing file with almost useless information
if os.path.exists(srcdir+"/src/Build/Version.h"):
if os.path.exists(srcdir+"/src/Build/Version.h.out"):
return False
try:
f = open(srcdir+"/debian/changelog")
@@ -385,12 +385,12 @@ def main():
lines = inp.readlines()
inp.close()
lines = i.writeVersion(lines)
out = open("%s/src/Build/Version.h" % (bindir),"w");
out = open("%s/src/Build/Version.h.out" % (bindir),"w");
out.writelines(lines)
out.write('\n')
out.close()
i.printInfo()
sys.stdout.write("%s/src/Build/Version.h written\n" % (bindir))
sys.stdout.write("%s/src/Build/Version.h.out written\n" % (bindir))
break
if __name__ == "__main__":