Skip to content

Commit

Permalink
Updated some cmake scripts. Improved psi/psi+ version detection
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitozz committed Jun 5, 2017
1 parent a7d2d7b commit 299ecb3
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 20 deletions.
33 changes: 25 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,32 @@ if(WIN32)
set(PLUGINS_PATH "/plugins" CACHE STRING "Install suffix for plugins")
endif()

set(APP_VERSION "1.0")
if(NOT PSI_PLUS_VERSION)
set(VER_FILE ${PROJECT_SOURCE_DIR}/version)
if(EXISTS "${VER_FILE}")
message(STATUS "Found Psi version file: ${VER_FILE}")
file(STRINGS "${VER_FILE}" VER_LINES)
string(REGEX MATCH "^([0-9])+\\.([0-9])+\\.?([a-fA-F0-9])*\\.?([a-fA-F0-9])*" VER_LINE ${VER_LINES})
set(VER_FILE ${PROJECT_SOURCE_DIR}/version)
if(EXISTS "${VER_FILE}")
message(STATUS "Found Psi version file: ${VER_FILE}")
file(STRINGS "${VER_FILE}" VER_LINES)
if(IS_PSIPLUS)
string(REGEX MATCH "^[0-9]+\\.[0-9]+\\.[0-9]+" VER_LINE_A ${VER_LINES})
string(REGEX MATCH "Psi:[a-fA-F0-9]+" PSI_REV ${VER_LINES})
string(REGEX MATCH "Psi\\+:[a-fA-F0-9]+" PSI_PLUS_REV ${VER_LINES})
string(REPLACE "Psi:" "" PSI_REV_NUM ${PSI_REV})
string(REGEX REPLACE "Psi\\+:" "" PSI_PLUS_REV_NUM ${PSI_PLUS_REV})
if(VER_LINE_A)
set(APP_VERSION ${VER_LINE_A})
message(STATUS "Psi version is: ${APP_VERSION}")
endif()
if(PSI_REV_NUM)
set(PSI_REVISION ${PSI_REV_NUM})
message(STATUS "Psi revision: ${PSI_REVISION}")
endif()
if(PSI_PLUS_REV_NUM)
set(PSI_PLUS_REVISION ${PSI_PLUS_REV_NUM})
message(STATUS "Psi+ revision: ${PSI_PLUS_REVISION}")
endif()
else()
string(REGEX MATCH "^[0-9]+\\.[0-9]+" VER_LINE ${VER_LINES})
if (VER_LINE)
set(PSI_PLUS_VERSION ${VER_LINE})
set(APP_VERSION ${VER_LINE})
message(STATUS "Psi version is: ${VER_LINE}")
endif()
endif()
Expand Down
4 changes: 2 additions & 2 deletions Readme-cmake.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ or

to build qjdns library as separate library (default ON)

> -DPSI_PLUS_VERSION=${version}
> -DPSI_VERSION=${version}

to set Psi-plus version manually (in format x.xx.xxx.xxx, where x is a decimal digit). Script sets this flag automatically from "version" file if it exists in psi-plus directory
to set Psi+ version manually ( Example for Psi+: 1.0.40 (2017-06-05, Psi:a7d2d7b8, Psi+:055e945, webkit) ). Script sets this flag automatically from "version" file if it exists in psi+ directory

> -DCMAKE_BUILD_TYPE=Release (default: Release)

Expand Down
25 changes: 16 additions & 9 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -178,21 +178,28 @@ else()
include_directories(${Iris_INCLUDE_DIR})
endif()

string(TIMESTAMP PSI_COMPILATION_DATE "%d-%m-%Y")
string(TIMESTAMP PSI_COMPILATION_DATE "%Y-%m-%d")
string(TIMESTAMP PSI_COMPILATION_TIME "%H:%M:%S")

if(ENABLE_WEBKIT)
#if(NOT USE_WEBENGINE)
set(PSI_VER_SUFFIX -webkit)
#else()
# set(PSI_VER_SUFFIX -webengine)
#endif()
if(NOT USE_WEBENGINE)
set(PSI_VER_SUFFIX ", webkit")
else()
set(PSI_VER_SUFFIX ", webengine")
endif()
endif()
if(ENABLE_SQL)
set( PSI_VER_SUFFIX "${PSI_VER_SUFFIX}, sql" )
endif()
if(NOT PSI_PLUS_VERSION)
set(PSI_PLUS_VERSION "${APP_VERSION}-dev" CACHE STRING "Version string of Psi")
#set(PSI_PLUS_VERSION "${APP_VERSION}" CACHE STRING "Version string of Psi")
if( NOT PSI_VERSION AND ( NOT IS_PSIPLUS ) )
set(PSI_VERSION "${APP_VERSION}-dev \(${PSI_COMPILATION_DATE}${PSI_VER_SUFFIX}\)")
endif()
if( NOT PSI_VERSION AND ( PSI_REVISION AND PSI_PLUS_REVISION ) )
set(PSI_VERSION "${APP_VERSION} \(${PSI_COMPILATION_DATE}, Psi:${PSI_REVISION}, Psi+:${PSI_PLUS_REVISION}${PSI_VER_SUFFIX}\)")
endif()
message(STATUS "Compilation date: ${PSI_COMPILATION_DATE}")
set(PSI_VERSION "${PSI_PLUS_VERSION}${PSI_VER_SUFFIX} \(${PSI_COMPILATION_DATE}\)")

#add_definitions(-DPSI_VERSION=${PSI_VERSION})

if(LINUX)
Expand Down
2 changes: 1 addition & 1 deletion src/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
#cmakedefine PSI_DATADIR "@PSI_DATADIR@"
#cmakedefine PSI_VERSION "@PSI_VERSION@"
#cmakedefine PSI_REVISION "@PSI_REVISION@"
#cmakedefine PSI_GIT_HASH "@PSI_GIT_HASH@"
#cmakedefine PSI_PLUS_REVISION "@PSI_PLUS_REVISION@"
#cmakedefine PSI_COMPILATION_DATE "@PSI_COMPILATION_DATE@"
#cmakedefine PSI_COMPILATION_TIME "@PSI_COMPILATION_TIME@"

0 comments on commit 299ecb3

Please sign in to comment.