[sword-svn] r2963 - in trunk: . cmake

greg.hellings at crosswire.org greg.hellings at crosswire.org
Wed Aug 14 07:02:02 MST 2013


Author: greg.hellings
Date: 2013-08-14 07:02:02 -0700 (Wed, 14 Aug 2013)
New Revision: 2963

Modified:
   trunk/CMakeLists.txt
   trunk/cmake/install.cmake
   trunk/cmake/options.cmake
   trunk/cmake/sources.cmake
Log:
Support for generating swversion.h in CMake.

Modified: trunk/CMakeLists.txt
===================================================================
--- trunk/CMakeLists.txt	2013-08-14 05:15:32 UTC (rev 2962)
+++ trunk/CMakeLists.txt	2013-08-14 14:02:02 UTC (rev 2963)
@@ -34,7 +34,8 @@
 # Source variables
 INCLUDE("${CMAKE_CURRENT_SOURCE_DIR}/cmake/sources.cmake")
 # Our local includes
-INCLUDE_DIRECTORIES("${CMAKE_CURRENT_SOURCE_DIR}/include")
+INCLUDE_DIRECTORIES("${CMAKE_CURRENT_BINARY_DIR}/include") # For swversion.h
+INCLUDE_DIRECTORIES("${CMAKE_CURRENT_SOURCE_DIR}/include") # For everything else
 
 ###########################################################################################
 # This will look for various libraries that libsword builds against.  There is no REQUIRED

Modified: trunk/cmake/install.cmake
===================================================================
--- trunk/cmake/install.cmake	2013-08-14 05:15:32 UTC (rev 2962)
+++ trunk/cmake/install.cmake	2013-08-14 14:02:02 UTC (rev 2963)
@@ -50,5 +50,7 @@
 ENDIF(LIBSWORD_LIBRARY_TYPE STREQUAL "Static")
 # The @ONLY restricts it because our ${variable} which are left there as part of pkg-config
 CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/sword.pc.in ${CMAKE_CURRENT_BINARY_DIR}/sword.pc @ONLY)
+CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/include/swversion.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/swversion.h @ONLY)
+
 INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/sword.pc
 	DESTINATION "${LIBDIR}/pkgconfig")

Modified: trunk/cmake/options.cmake
===================================================================
--- trunk/cmake/options.cmake	2013-08-14 05:15:32 UTC (rev 2962)
+++ trunk/cmake/options.cmake	2013-08-14 14:02:02 UTC (rev 2963)
@@ -21,3 +21,32 @@
 SET(INCLUDEDIR "${PREFIX}/include" CACHE STRING "C Header files install directory. Defaults to ${SWORD_INSTALL_DIR}/include.")
 
 SET(BINDIR "${PREFIX}/bin" CACHE STRING "Directory to install binary executable files. Defaults to ${SWORD_INSTALL_DIR}/bin.")
+
+# Post-processing of variables
+MACRO(PROCESS_VERSION LEVEL VALUE)
+    SET(SWORD_VERSION_${LEVEL} ${VALUE})
+    IF(${VALUE} LESS 10)
+        SET(${LEVEL} "00${VALUE}")
+    ELSEIF(${VALUE} LESS 100)
+        SET(${LEVEL} "0${VALUE}")
+    ELSE()
+        SET(${LEVEL} "${VALUE}")
+    ENDIF()
+ENDMACRO()
+
+STRING(REGEX MATCHALL "^([0-9]+)\\.([0-9]+)\\.([0-9]+)\\.?([0-9]+)?$"
+    SWORD_VERSION_PARTS "${SWORD_VERSION}")
+# We don't always have a nano version
+IF("${CMAKE_MATCH_4}" STREQUAL "")
+    SET(CMAKE_MATCH_4 "0")
+ENDIF("${CMAKE_MATCH_4}" STREQUAL "")
+
+SET(SWORD_VERSION_MAJOR ${CMAKE_MATCH_1}) # No post-processing on this, so it's not octal
+PROCESS_VERSION("MINOR" ${CMAKE_MATCH_2})
+PROCESS_VERSION("MICRO" ${CMAKE_MATCH_3})
+PROCESS_VERSION("NANO"  ${CMAKE_MATCH_4})
+
+SET(SWORD_VERSION_STR "${SWORD_VERSION}")
+SET(SWORD_VERSION_NUM "${SWORD_VERSION_MAJOR}${MINOR}${MICRO}${NANO}")
+
+MESSAGE(STATUS "SWORD Version ${SWORD_VERSION_NUM}")

Modified: trunk/cmake/sources.cmake
===================================================================
--- trunk/cmake/sources.cmake	2013-08-14 05:15:32 UTC (rev 2962)
+++ trunk/cmake/sources.cmake	2013-08-14 14:02:02 UTC (rev 2963)
@@ -345,7 +345,7 @@
 	include/swsearchable.h
 	include/swtext.h
 	include/swunicod.h
-	include/swversion.h
+    "${CMAKE_CURRENT_BINARY_DIR}/include/swversion.h"
 	include/sysdata.h
 
 	include/thmlfootnotes.h




More information about the sword-cvs mailing list