diff options
author | saurabhb17 | 2020-02-26 16:11:59 +0530 |
---|---|---|
committer | GitHub | 2020-02-26 16:11:59 +0530 |
commit | e255d0622297488c1c52755be670733418c994cf (patch) | |
tree | 1392c90227aeea231c1d86371131e04c40382918 /CMakeModules/CreateSVNVersionHeader.cmake | |
parent | 0db48f6533517ecebfd9f0693f89deca28408b76 (diff) | |
parent | c38609295ad4b617aef472b9c575aee18710a50f (diff) | |
download | KiCad-eSim-e255d0622297488c1c52755be670733418c994cf.tar.gz KiCad-eSim-e255d0622297488c1c52755be670733418c994cf.tar.bz2 KiCad-eSim-e255d0622297488c1c52755be670733418c994cf.zip |
Merge pull request #1 from saurabhb17/develop
Secondary files
Diffstat (limited to 'CMakeModules/CreateSVNVersionHeader.cmake')
-rw-r--r-- | CMakeModules/CreateSVNVersionHeader.cmake | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/CMakeModules/CreateSVNVersionHeader.cmake b/CMakeModules/CreateSVNVersionHeader.cmake new file mode 100644 index 0000000..1c6b9d9 --- /dev/null +++ b/CMakeModules/CreateSVNVersionHeader.cmake @@ -0,0 +1,61 @@ +macro(create_svn_version_header) + # Include Subversion support to automagically create version header file. + find_package(Subversion) + + if(Subversion_FOUND) + # Copied from the CMake module FindSubversion.cmake. The default + # version prevents generating the output files when the "svn info" + # command fails. Just fall back to using "build_version.h" for + # the version strings. + set(_Subversion_SAVED_LC_ALL "$ENV{LC_ALL}") + set(ENV{LC_ALL} C) + + execute_process( + COMMAND ${Subversion_SVN_EXECUTABLE} info ${PROJECT_SOURCE_DIR} + OUTPUT_VARIABLE Kicad_WC_INFO + ERROR_VARIABLE _svn_error + RESULT_VARIABLE _svn_result + OUTPUT_STRIP_TRAILING_WHITESPACE) + + if(NOT ${_svn_result} EQUAL 0) + message(STATUS + "Using <build_version.h> for version string.") + else(NOT ${_svn_result} EQUAL 0) + string(REGEX REPLACE "^(.*\n)?URL: ([^\n]+).*" + "\\2" Kicad_WC_URL "${Kicad_WC_INFO}") + string(REGEX REPLACE "^(.*\n)?Revision: ([^\n]+).*" + "\\2" Kicad_WC_REVISION "${Kicad_WC_INFO}") + string(REGEX REPLACE "^(.*\n)?Last Changed Author: ([^\n]+).*" + "\\2" Kicad_WC_LAST_CHANGED_AUTHOR "${Kicad_WC_INFO}") + string(REGEX REPLACE "^(.*\n)?Last Changed Rev: ([^\n]+).*" + "\\2" Kicad_WC_LAST_CHANGED_REV "${Kicad_WC_INFO}") + string(REGEX REPLACE "^(.*\n)?Last Changed Date: ([^\n]+).*" + "\\2" Kicad_WC_LAST_CHANGED_DATE "${Kicad_WC_INFO}") + endif(NOT ${_svn_result} EQUAL 0) + + set(ENV{LC_ALL} ${_Subversion_SAVED_LC_ALL}) + endif(Subversion_FOUND) + + # Check to make sure 'svn info' command did not fail. Otherwise fallback + # to version strings defined in "<kicad-src-dir>/include/build_version.h". + if(Kicad_WC_LAST_CHANGED_DATE) + string(REGEX REPLACE "^([0-9]+)\\-([0-9]+)\\-([0-9]+).*" "\\1\\2\\3" + _kicad_svn_date ${Kicad_WC_LAST_CHANGED_DATE}) + set(KICAD_BUILD_VERSION + "(${_kicad_svn_date} SVN-R${Kicad_WC_LAST_CHANGED_REV})") + + # Definition to conditionally use date and revision returned from the + # Subversion info command instead of hand coded date and revision in + # "include/build_version.h". If subversion is not found then the date + # and version information must be manually edited. + # Directive means SVN build, program version and build version will + # reflect this. + add_definitions(-DHAVE_SVN_VERSION) + + # Generate version.h. + configure_file(${CMAKE_SOURCE_DIR}/CMakeModules/version.h.cmake + ${CMAKE_BINARY_DIR}/version.h) + + message(STATUS "Kicad SVN build version: ${KICAD_BUILD_VERSION}") + endif(Kicad_WC_LAST_CHANGED_DATE) +endmacro(create_svn_version_header) |