Skip to content

Commit

Permalink
Minor version string generation improvements.
Browse files Browse the repository at this point in the history
Remove the KICAD_REPO_NAME option from the main cmake file and the
generated config.h file since it is no longer used.

Set the default branch name to "undefined" in CreateGitVersionHeader.cmake
instead of the KICAD_REPO_NAME option.

Remove generating KICAD_FULL_VERSION from CreateGitVersionHeader.cmake
and add it to WriteVersionHeader.cmake so that the default settings and
the new KiCadVersion.cmake definitions can be used to generate the full
version string as well.

Check to see if the branch name is set and only use the version to
generate the full version string.  This allows the use of the KiCad
version cmake file to create a version only string like "4.0.4" with
no trailing branch name.

Change build_version.cpp to use the full version string rather than
concatenating the version and branch strings.
  • Loading branch information
stambaughw committed Oct 13, 2016
1 parent b54166d commit 03da56a
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 22 deletions.
4 changes: 0 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,6 @@ option( BUILD_GITHUB_PLUGIN "Build the GITHUB_PLUGIN for pcbnew." ON )

option( KICAD_SPICE "Build Kicad with internal Spice simulator." OFF )

# This can be set to a custom name to brag about a particular branch in the "About" dialog:
set( KICAD_REPO_NAME "unknown" CACHE STRING "Name of the tree from which this build came." )


# Global setting: exports are explicit
set( CMAKE_CXX_VISIBILITY_PRESET "hidden" )
set( CMAKE_VISIBILITY_INLINES_HIDDEN ON )
Expand Down
3 changes: 1 addition & 2 deletions CMakeModules/CreateGitVersionHeader.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ macro( create_git_version_header _git_src_path )
# version, set the build version string to "no-git" and the default
# branch name to unknown
set( KICAD_BUILD_VERSION "no-git" )
set( KICAD_BRANCH_NAME ${KICAD_REPO_NAME} )
set( KICAD_BRANCH_NAME "undefined" )
set( KICAD_FULL_VERSION "${KICAD_BUILD_VERSION}-${KICAD_BRANCH_NAME}")

# Include Git support to automagically create version header file.
Expand Down Expand Up @@ -108,5 +108,4 @@ macro( create_git_version_header _git_src_path )
endif()

set( KICAD_BUILD_VERSION ${KICAD_BUILD_VERSION} )
set( KICAD_FULL_VERSION "${KICAD_BUILD_VERSION}-${KICAD_BRANCH_NAME}")
endmacro()
25 changes: 15 additions & 10 deletions CMakeModules/WriteVersionHeader.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,25 @@
# CreateGitVersionHeader cannot determine the current repo version, a
# version.h file is still created with KICAD_BUILD_VERSION set to
# "no-vcs-found".
if( NOT KICAD_BUILD_VERSION )
include( ${CMAKE_MODULE_PATH}/KiCadVersion.cmake )
include( ${CMAKE_MODULE_PATH}/KiCadVersion.cmake )

# Attempt to detect if we have a git repo and set the version string.
if( EXISTS "${SRC_PATH}/.git" )
message( STATUS "Using Git to determine build version string." )
include( ${CMAKE_MODULE_PATH}/CreateGitVersionHeader.cmake )
create_git_version_header( ${SRC_PATH} )
set( _wvh_version_str ${KICAD_BUILD_VERSION} )
endif()
else()
# Attempt to detect if we have a git repo and set the version string.
if( EXISTS "${SRC_PATH}/.git" )
message( STATUS "Using Git to determine build version string." )
include( ${CMAKE_MODULE_PATH}/CreateGitVersionHeader.cmake )
create_git_version_header( ${SRC_PATH} )
set( _wvh_version_str ${KICAD_BUILD_VERSION} )
endif()

# If KICAD_BRANCH_NAME is empty, set KICAD_FULL_VERSION to just the build
# version rather than the concatenation of the build version and the branch
# name.
if( KICAD_BRANCH_NAME )
set( KICAD_FULL_VERSION "${_wvh_version_str}-${KICAD_BRANCH_NAME}" )
else()
set( KICAD_FULL_VERSION "${_wvh_version_str}" )
endif()

set( _wvh_new_version_text
"/* Do not modify this file, it was automatically generated by CMake. */
Expand Down
3 changes: 0 additions & 3 deletions CMakeModules/config.h.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,4 @@
#define KIFACE_SUFFIX "@KIFACE_SUFFIX@"
#define KIFACE_PREFIX "@KIFACE_PREFIX@"

/// Name of repo from which this build came.
#define KICAD_REPO_NAME "@KICAD_REPO_NAME@"

#endif // CONFIG_H_
5 changes: 2 additions & 3 deletions common/build_version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,8 @@
wxString GetBuildVersion()
{
wxString msg = wxString::Format(
wxT( "%s-%s" ),
wxT( KICAD_BUILD_VERSION ),
wxT( KICAD_BRANCH_NAME )
wxT( "%s" ),
wxT( KICAD_FULL_VERSION )
);

return msg;
Expand Down

0 comments on commit 03da56a

Please sign in to comment.