The branch, master, has been updated.

- Log -----------------------------------------------------------------

commit 854b168d17bfbee76faa06ff3394b647b2b25f9c
Author: Kornel Benko <kor...@lyx.org>
Date:   Thu Nov 1 13:00:19 2012 +0100

    Cmake build:
    Correct dependencies for version-info also at build-time
    (not only at configure time)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6b5fab4..e86b7d8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -275,12 +275,6 @@ if (LYX_LOCALVERSIONING)
                  MATH(EXPR tmp_REVISION_VERSION "(${CMAKE_MATCH_1}+40000)")
                  set(LYX_REVISION_VERSION 
"${LYX_PATCH_VERSION}-${tmp_REVISION_VERSION}git")
                endif()
-               # Override the value from configure.ac, if possible
-               EXECUTE_PROCESS(COMMAND ${LYX_GITVERSION} "log" "-1" 
"--format=%ci"
-                       WORKING_DIRECTORY "${TOP_SRC_DIR}"
-                       OUTPUT_VARIABLE LYX_DATEtmp 
OUTPUT_STRIP_TRAILING_WHITESPACE)
-
-               string(REGEX MATCH "([0-9]+-[0-9]+-[0-9]+)" LYX_DATE 
${LYX_DATEtmp})
        else()
                set(LYX_REVISION_VERSION git) #TODO use date
        endif()
@@ -294,6 +288,9 @@ else()
        set(PROGRAM_SUFFIX "")
 endif()
 
+add_custom_target(lyx_version ALL
+  COMMAND ${CMAKE_COMMAND} -DTOP_SRC_DIR=${TOP_SRC_DIR} 
-DLYX_CMAKE_DIR=${LYX_CMAKE_DIR} -DTOP_BINARY_DIR=${TOP_BINARY_DIR} 
-DLYX_DATE=${LYX_DATE} -P 
${TOP_SRC_DIR}/${LYX_CMAKE_DIR}/modules/LyXGetVersion.cmake
+  )
 
 if(APPLE)
        set(osx_bundle_program_name ${PACKAGE_BASE}${PROGRAM_SUFFIX})
@@ -548,6 +545,8 @@ if(WIN32)
        endif()
 endif()
 
+# Compute qt4-version from ${QTVERSION}
+
 message(STATUS "")
 foreach(_v PACKAGE PACKAGE_VERSION
        PROGRAM_SUFFIX LYX_DATE LYX_DIR_VER LYX_USERDIR_VER
@@ -690,9 +689,7 @@ else()
 endif()
 
 configure_file(${LYX_CMAKE_DIR}/config.h.cmake ${TOP_BINARY_DIR}/config.h)
-configure_file(${LYX_CMAKE_DIR}/lyx_date.h.cmake ${TOP_BINARY_DIR}/lyx_date.h)
 
-# Compute qt4-version from ${QTVERSION}
 if(QTVERSION MATCHES "^([0-9]+)\\.([0-9]+)\\.([0-9]+).*")
        MATH(EXPR QT4_VERSION 
"(${CMAKE_MATCH_1}<<16)|(${CMAKE_MATCH_2}<<8)|${CMAKE_MATCH_3}")
 endif()
diff --git a/development/cmake/lyx_date.h.cmake 
b/development/cmake/lyx_date.h.cmake
index ddbffea..11ac129 100644
--- a/development/cmake/lyx_date.h.cmake
+++ b/development/cmake/lyx_date.h.cmake
@@ -1,5 +1,5 @@
 /*
- * \file config.h
+ * \file lyx_date.h
  * This file is part of LyX, the document processor.
  * Licence details can be found in the file COPYING.
  *
diff --git a/development/cmake/modules/LyXGetVersion.cmake 
b/development/cmake/modules/LyXGetVersion.cmake
new file mode 100644
index 0000000..1f6cde7
--- /dev/null
+++ b/development/cmake/modules/LyXGetVersion.cmake
@@ -0,0 +1,54 @@
+#  Copyright (c) 2012, Kornel Benko, <kor...@lyx.org>
+#
+#  Redistribution and use in source and binary forms, with or without
+#  modification, are permitted provided that the following conditions
+#  are met:
+#
+#  1. Redistributions of source code must retain the copyright
+#         notice, this list of conditions and the following disclaimer.
+#  2. Redistributions in binary form must reproduce the copyright
+#         notice, this list of conditions and the following disclaimer in the
+#         documentation and/or other materials provided with the distribution.
+#  3. The name of the author may not be used to endorse or promote products
+#         derived from this software without specific prior written permission.
+#
+#  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
+#
+# To call this script, one has to provide following parameters
+# TOP_SRC_DIR
+# LYX_CMAKE_DIR
+# TOP_BINARY_DIR
+# LYX_DATE:    to be used if not under git control
+
+
+set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
+
+FIND_PROGRAM(LYX_GITVERSION git)
+if(LYX_GITVERSION)
+  # Override the value from configure.ac, if possible
+  EXECUTE_PROCESS(COMMAND ${LYX_GITVERSION} "log" "-1" "--format=%h %ci"
+    WORKING_DIRECTORY "${TOP_SRC_DIR}"
+    OUTPUT_VARIABLE LYX_DATEtmp OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+  if(LYX_DATEtmp MATCHES "^([0-9a-f]+) ([0-9]+-[0-9]+-[0-9]+)")
+    set(LYX_GITHASH ${CMAKE_MATCH_1})
+    set(LYX_DATE ${CMAKE_MATCH_2})
+    message(STATUS "Git-hash = ${LYX_GITHASH}")
+  endif()
+endif()
+
+configure_file(${TOP_SRC_DIR}/${LYX_CMAKE_DIR}/lyx_date.h.cmake 
${TOP_BINARY_DIR}/lyx_date.tmp)
+EXECUTE_PROCESS(
+  COMMAND ${CMAKE_COMMAND} -E copy_if_different ${TOP_BINARY_DIR}/lyx_date.tmp 
${TOP_BINARY_DIR}/lyx_date.h
+  COMMAND ${CMAKE_COMMAND} -E remove ${TOP_BINARY_DIR}/lyx_date.tmp
+)
+
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index b5a9a29..dd93a0a 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -116,6 +116,7 @@ add_executable(${_lyx}
        ${OSX_BUNDLE_FILES}
 )
 
+add_dependencies(${_lyx} lyx_version)
 
 lyx_add_gcc_pch(${_lyx})
 
diff --git a/src/tex2lyx/CMakeLists.txt b/src/tex2lyx/CMakeLists.txt
index 496cbdd..2053e30 100644
--- a/src/tex2lyx/CMakeLists.txt
+++ b/src/tex2lyx/CMakeLists.txt
@@ -53,6 +53,8 @@ target_link_libraries(${_tex2lyx}
        ${intl_link}
        ${ICONV_LIBRARY})
 
+add_dependencies(${_tex2lyx} lyx_version)
+
 if(WIN32)
        target_link_libraries(${_tex2lyx} shlwapi ole32 psapi)
 endif()

-----------------------------------------------------------------------

Summary of changes:
 CMakeLists.txt                                |   13 ++----
 development/cmake/lyx_date.h.cmake            |    2 +-
 development/cmake/modules/LyXGetVersion.cmake |   54 +++++++++++++++++++++++++
 src/CMakeLists.txt                            |    1 +
 src/tex2lyx/CMakeLists.txt                    |    2 +
 5 files changed, 63 insertions(+), 9 deletions(-)
 create mode 100644 development/cmake/modules/LyXGetVersion.cmake


hooks/post-receive
-- 
The LyX Source Repository

Reply via email to