diff --git a/CMakeLists.txt b/CMakeLists.txt index 582683b51f..47d86d4499 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,6 +25,23 @@ 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.") @@ -78,10 +95,15 @@ 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 ) + # Include paths. include_directories( - ${CMAKE_CURRENT_SOURCE_DIR}/include - ${CMAKE_CURRENT_SOURCE_DIR}/share) + ${CMAKE_SOURCE_DIR}/include + ${CMAKE_SOURCE_DIR}/share + ${CMAKE_BINARY_DIR}) # CMake will look in these dirs for nested 'CMakeLists.txt' files. # Binaries. diff --git a/CMakeModules/config.h.cmake b/CMakeModules/config.h.cmake new file mode 100644 index 0000000000..db5e265967 --- /dev/null +++ b/CMakeModules/config.h.cmake @@ -0,0 +1,8 @@ +/* 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__ */ diff --git a/change_log.txt b/change_log.txt index c86b09f25c..4f3597a556 100644 --- a/change_log.txt +++ b/change_log.txt @@ -5,6 +5,13 @@ Started 2007-June-11 Please add newer entries at the top, list the date and your name with email address. +2008-May-2 UPDATE Wayne Stambaugh +================================================================================ ++cmake + * Use Subversion to automatically generate build date and revision level + when building with CMake. Header file build_version.h will still need + manual updates when using the hand written make files. + 2008-May-2 UPDATE Dick Hollenbeck ================================================================================ diff --git a/include/build_version.h b/include/build_version.h index 66437b8e2a..8838d6596e 100644 --- a/include/build_version.h +++ b/include/build_version.h @@ -5,7 +5,12 @@ COMMON_GLOBL wxString g_BuildVersion #ifdef EDA_BASE - (wxT("(20080429-r1010)")) +# ifdef HAVE_SVN_VERSION +# include "config.h" + (wxT(KICAD_SVN_VERSION)) +# else + (wxT("(20080429-r1010)")) +# endif #endif ;