Skip to content

Commit 295e73f

Browse files
committed
generate both version.h and version from CMakelists.txt
This forces consistency, since they will be re-generated whenever a git operation alters CMakelists.txt. They are still in the repo because users might not actually run cmake.
1 parent 2a840c1 commit 295e73f

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
/libs/
1111
/doc/doxyfile
1212
/dist/
13+
#/version
1314
#/include/json/version.h
1415

1516
# MSVC project files:

CMakeLists.txt

+15-6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# vim: et ts=4 sts=4 sw=4 tw=0
2+
13
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.5)
24
PROJECT(jsoncpp)
35
ENABLE_TESTING()
@@ -54,17 +56,24 @@ MACRO(jsoncpp_parse_version VERSION_TEXT OUPUT_PREFIX)
5456
ENDMACRO(jsoncpp_parse_version)
5557

5658
# Read out version from "version" file
57-
FILE(STRINGS "version" JSONCPP_VERSION)
58-
59+
#FILE(STRINGS "version" JSONCPP_VERSION)
60+
#SET( JSONCPP_VERSION_MAJOR X )
61+
#SET( JSONCPP_VERSION_MINOR Y )
62+
#SET( JSONCPP_VERSION_PATCH Z )
63+
SET( JSONCPP_VERSION 1.5.2 )
5964
jsoncpp_parse_version( ${JSONCPP_VERSION} JSONCPP_VERSION )
60-
IF(NOT JSONCPP_VERSION_FOUND)
61-
MESSAGE(FATAL_ERROR "Failed to parse version string properly. Expect X.Y.Z")
62-
ENDIF(NOT JSONCPP_VERSION_FOUND)
65+
#IF(NOT JSONCPP_VERSION_FOUND)
66+
# MESSAGE(FATAL_ERROR "Failed to parse version string properly. Expect X.Y.Z")
67+
#ENDIF(NOT JSONCPP_VERSION_FOUND)
6368

6469
MESSAGE(STATUS "JsonCpp Version: ${JSONCPP_VERSION_MAJOR}.${JSONCPP_VERSION_MINOR}.${JSONCPP_VERSION_PATCH}")
6570
# File version.h is only regenerated on CMake configure step
6671
CONFIGURE_FILE( "${PROJECT_SOURCE_DIR}/src/lib_json/version.h.in"
67-
"${PROJECT_SOURCE_DIR}/include/json/version.h" )
72+
"${PROJECT_SOURCE_DIR}/include/json/version.h"
73+
NEWLINE_STYLE UNIX )
74+
CONFIGURE_FILE( "${PROJECT_SOURCE_DIR}/version.in"
75+
"${PROJECT_SOURCE_DIR}/version"
76+
NEWLINE_STYLE UNIX )
6877

6978
macro(UseCompilationWarningAsError)
7079
if ( MSVC )

version.in

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@JSONCPP_VERSION@

0 commit comments

Comments
 (0)