Commit 75bba55a authored by f3nix's avatar f3nix

CMake:

* Move svn version header creation to a macro (Unix-only for now).
* Use CVS version of FindSubversion macro.
parent 2773be4f
......@@ -25,23 +25,6 @@ if(CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS_DEBUG "-Wall -g3 -ggdb3 -DDEBUG")
endif(CMAKE_COMPILER_IS_GNUCXX)
# Include Subversion support to automagically create version header file.
find_package( Subversion )
if( Subversion_FOUND )
Subversion_WC_INFO( ${PROJECT_SOURCE_DIR} Kicad )
string( REGEX REPLACE "^([0-9]+)\\-([0-9]+)\\-([0-9]+).*" "\\1\\2\\3"
_kicad_svn_date ${Kicad_WC_LAST_CHANGED_DATE} )
set( KICAD_SVN_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_verison.h". If subversion is not found or the hand
# coded make files are used then the date and version information must
# be manually edited.
add_definitions( -DHAVE_SVN_VERSION )
endif( Subversion_FOUND )
# Locations for install targets.
set(KICAD_BIN bin CACHE PATH "Location of KiCad binaries.")
......@@ -95,9 +78,11 @@ include(${wxWidgets_USE_FILE})
# Include MinGW resource compiler.
include(MinGWResourceCompiler)
# Generate config.h.
configure_file( ${CMAKE_SOURCE_DIR}/CMakeModules/config.h.cmake
${CMAKE_BINARY_DIR}/config.h )
if(UNIX)
# Automagically create version header file.
include(CreateSVNVersionHeader)
create_svn_version_header()
endif(UNIX)
# Include paths.
include_directories(
......
......@@ -3,6 +3,6 @@ macro(check_find_package_result _VAR _PKGNAME)
message(STATUS "Check for installed ${_PKGNAME} -- found")
else(${_VAR})
message(STATUS "Check for installed ${_PKGNAME} -- not found")
message(FATAL_ERROR "${_PKGNAME} was not found - it is required to build KiCad")
message(FATAL_ERROR "${_PKGNAME} was not found - it is required to build Kicad")
endif(${_VAR})
endmacro(check_find_package_result)
macro(create_svn_version_header)
# Include Subversion support to automagically create version header file.
find_package(SubversionCVS)
if(Subversion_FOUND)
Subversion_WC_INFO(${PROJECT_SOURCE_DIR} Kicad)
string(REGEX REPLACE "^([0-9]+)\\-([0-9]+)\\-([0-9]+).*" "\\1\\2\\3"
_kicad_svn_date ${Kicad_WC_LAST_CHANGED_DATE})
set(KICAD_SVN_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.
add_definitions(-DHAVE_SVN_VERSION)
# Generate config.h.
configure_file(${CMAKE_SOURCE_DIR}/CMakeModules/config.h.cmake
${CMAKE_BINARY_DIR}/config.h)
endif(Subversion_FOUND)
endmacro(create_svn_version_header)
# CMake CVS r1.2.2.2
#
# - Extract information from a subversion working copy
# The module defines the following variables:
# Subversion_SVN_EXECUTABLE - path to svn command line client
# Subversion_VERSION_SVN - version of svn command line client
# Subversion_FOUND - true if the command line client was found
# If the command line client executable is found the macro
# Subversion_WC_INFO(<dir> <var-prefix>)
# is defined to extract information of a subversion working copy at
# a given location. The macro defines the following variables:
# <var-prefix>_WC_URL - url of the repository (at <dir>)
# <var-prefix>_WC_ROOT - root url of the repository
# <var-prefix>_WC_REVISION - current revision
# <var-prefix>_WC_LAST_CHANGED_AUTHOR - author of last commit
# <var-prefix>_WC_LAST_CHANGED_DATE - date of last commit
# <var-prefix>_WC_LAST_CHANGED_REV - revision of last commit
# <var-prefix>_WC_LAST_CHANGED_LOG - last log of base revision
# <var-prefix>_WC_INFO - output of command `svn info <dir>'
# Example usage:
# FIND_PACKAGE(Subversion)
# IF(Subversion_FOUND)
# Subversion_WC_INFO(${PROJECT_SOURCE_DIR} Project)
# MESSAGE("Current revision is ${Project_WC_REVISION}")
# ENDIF(Subversion_FOUND)
# Copyright (c) 2006, Tristan Carel
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the University of California, Berkeley nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# $Id: FindSubversion.cmake,v 1.2.2.2 2008/03/26 18:08:24 hoffman Exp $
SET(Subversion_FOUND FALSE)
SET(Subversion_SVN_FOUND FALSE)
# the subversion commands should be executed with the C locale, otherwise
# the message (which are parsed) may be translated, Alex
SET(_Subversion_SAVED_LC_ALL "$ENV{LC_ALL}" )
SET(ENV{LC_ALL} C)
SET(ENV{LANG} C)
FIND_PROGRAM(Subversion_SVN_EXECUTABLE svn
DOC "subversion command line client")
MARK_AS_ADVANCED(Subversion_SVN_EXECUTABLE)
IF(Subversion_SVN_EXECUTABLE)
SET(Subversion_SVN_FOUND TRUE)
SET(Subversion_FOUND TRUE)
MACRO(Subversion_WC_INFO dir prefix)
EXECUTE_PROCESS(COMMAND ${Subversion_SVN_EXECUTABLE} --version
WORKING_DIRECTORY ${dir}
OUTPUT_VARIABLE Subversion_VERSION_SVN
OUTPUT_STRIP_TRAILING_WHITESPACE)
EXECUTE_PROCESS(COMMAND ${Subversion_SVN_EXECUTABLE} info ${dir}
OUTPUT_VARIABLE ${prefix}_WC_INFO
ERROR_VARIABLE Subversion_svn_info_error
RESULT_VARIABLE Subversion_svn_info_result
OUTPUT_STRIP_TRAILING_WHITESPACE)
IF(NOT ${Subversion_svn_info_result} EQUAL 0)
MESSAGE(SEND_ERROR "Command \"${Subversion_SVN_EXECUTABLE} info ${dir}\" failed with output:\n${Subversion_svn_info_error}")
ELSE(NOT ${Subversion_svn_info_result} EQUAL 0)
STRING(REGEX REPLACE "^(.*\n)?svn, version ([.0-9]+).*"
"\\2" Subversion_VERSION_SVN "${Subversion_VERSION_SVN}")
STRING(REGEX REPLACE "^(.*\n)?URL: ([^\n]+).*"
"\\2" ${prefix}_WC_URL "${${prefix}_WC_INFO}")
STRING(REGEX REPLACE "^(.*\n)?Revision: ([^\n]+).*"
"\\2" ${prefix}_WC_REVISION "${${prefix}_WC_INFO}")
STRING(REGEX REPLACE "^(.*\n)?Last Changed Author: ([^\n]+).*"
"\\2" ${prefix}_WC_LAST_CHANGED_AUTHOR "${${prefix}_WC_INFO}")
STRING(REGEX REPLACE "^(.*\n)?Last Changed Rev: ([^\n]+).*"
"\\2" ${prefix}_WC_LAST_CHANGED_REV "${${prefix}_WC_INFO}")
STRING(REGEX REPLACE "^(.*\n)?Last Changed Date: ([^\n]+).*"
"\\2" ${prefix}_WC_LAST_CHANGED_DATE "${${prefix}_WC_INFO}")
ENDIF(NOT ${Subversion_svn_info_result} EQUAL 0)
EXECUTE_PROCESS(COMMAND
${Subversion_SVN_EXECUTABLE} log -r BASE ${dir}
OUTPUT_VARIABLE Subversion_LAST_CHANGED_LOG
ERROR_VARIABLE Subversion_svn_log_error
RESULT_VARIABLE Subversion_svn_log_result
OUTPUT_STRIP_TRAILING_WHITESPACE)
IF(NOT ${Subversion_svn_log_result} EQUAL 0)
MESSAGE(SEND_ERROR "Command \"${Subversion_SVN_EXECUTABLE} log -r BASE ${dir}\" failed with output:\n${Subversion_svn_log_error}")
ENDIF(NOT ${Subversion_svn_log_result} EQUAL 0)
ENDMACRO(Subversion_WC_INFO)
ENDIF(Subversion_SVN_EXECUTABLE)
# restore the previous LC_ALL
SET(ENV{LC_ALL} ${_Subversion_SAVED_LC_ALL})
IF(NOT Subversion_FOUND)
IF(NOT Subversion_FIND_QUIETLY)
MESSAGE(STATUS "Subversion was not found.")
ELSE(NOT Subversion_FIND_QUIETLY)
IF(Subversion_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Subversion was not found.")
ENDIF(Subversion_FIND_REQUIRED)
ENDIF(NOT Subversion_FIND_QUIETLY)
ENDIF(NOT Subversion_FOUND)
# FindSubversion.cmake ends here.
/* Do not modify this file, it was automatically generated by CMake */
#ifndef __KICAD_SVN_VERSION_H__
#define __KICAD_SVN_VERSION_H__
#cmakedefine KICAD_SVN_VERSION "@KICAD_SVN_VERSION@"
#endif /* __KICAD_SVN_VERSION_H__ */
/* Do not modify this file, it was automatically generated by CMake */
#ifndef __KICAD_SVN_VERSION_H__
#define __KICAD_SVN_VERSION_H__
#cmakedefine KICAD_SVN_VERSION "@KICAD_SVN_VERSION@"
#endif /* __KICAD_SVN_VERSION_H__ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment