summaryrefslogtreecommitdiffstats
path: root/kdoctools/ConfigureChecks.cmake
blob: c98843e239664578879e20f9bd104dfa8cc3a72c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#################################################
#
#  (C) 2012-2020 Trinity Project
#
#  Improvements and feedback are welcome
#
#  This file is released under GPL >= 2
#
#################################################

if( NOT TDE_RELEASE_ENTITIES )

  set( TDEVERSION_FILE "${CMAKE_SOURCE_DIR}/tdecore/tdeversion.h" )
  set( ENTITIES_FILE "${CMAKE_CURRENT_SOURCE_DIR}/customization/entities/general.entities" )

  if( NOT EXISTS ${TDEVERSION_FILE} )
    tde_message_fatal( "${TDEVERSION_FILE} not found! Check your sources." )
  endif( )
  if( NOT EXISTS ${ENTITIES_FILE} )
    tde_message_fatal( "${ENTITIES_FILE} not found! Check your sources." )
  endif( )

  # read source metadata
  tde_read_src_metadata()

  # read TDE_VERSION_STRING
  file( STRINGS ${TDEVERSION_FILE} TDE_VERSION_STRING REGEX "define TDE_VERSION_STRING" )
  string( REGEX REPLACE ".*#define TDE_VERSION_STRING \"([^\"]*)\".*" "\\1"
          TDE_VERSION_STRING "${TDE_VERSION_STRING}" )
  if( "${TDE_VERSION_STRING}" STREQUAL "" )
    tde_message_fatal( "Cannot determine the Trinity version number." )
  endif( )

  # compose TDE_RELEASE_DATE
  if( "${TDE_VERSION_STRING}" MATCHES "DEVELOPMENT" )
    tde_curdatetime( TDE_RELEASE_DATE )
  else( )
    if( TDE_SCM_MODULE_DATETIME )
      set( TDE_RELEASE_DATE "${TDE_SCM_MODULE_DATETIME}" )
    else( )
      if( ${CMAKE_SYSTEM_NAME} MATCHES "BSD" )
        set( GNU_FIND_EXECUTABLE "gfind" )
      else( )
        set( GNU_FIND_EXECUTABLE "find" )
      endif( )
      execute_process(
        COMMAND ${GNU_FIND_EXECUTABLE} ${TDEVERSION_FILE} -printf "%Tm/%Te/%TY"
        OUTPUT_VARIABLE TDE_RELEASE_DATE
        OUTPUT_STRIP_TRAILING_WHITESPACE
      )
    endif( )
  endif( )

  string( REGEX REPLACE "^([0-9]+)/([0-9]+)*/([0-9]+).*" "2010-\\3"
          TDE_RELEASE_COPYRIGHT "${TDE_RELEASE_DATE}" )

  string( REGEX REPLACE "^([0-9]+)/([0-9]+)*/([0-9]+).*" "\\1"
          _release_month_num "${TDE_RELEASE_DATE}" )
  math( EXPR _release_month_index "${_release_month_num}-1" )
  set( _month_names "January;February;March;April;May;June;July;August;September;October;November;December" )
  list( GET _month_names ${_release_month_index} _release_month_name )
  string( REGEX REPLACE
          "^([0-9]+)/([0-9]+)*/([0-9]+).*"
          "${_release_month_name} \\2, \\3"
          TDE_RELEASE_DATE  "${TDE_RELEASE_DATE}" )

  # update entities
  message( STATUS "Updating ${ENTITIES_FILE}
    TDE Release Version: ${TDE_VERSION_STRING}
    TDE Release Date: ${TDE_RELEASE_DATE}
    TDE Release Copyright: ${TDE_RELEASE_COPYRIGHT}"
  )
  file( READ ${ENTITIES_FILE} ENTITIES_DATA )
  if( "${ENTITIES_DATA}" MATCHES "ENTITY tde-release-version" )
    string( REGEX REPLACE "(ENTITY tde-release-version) \"[^\"]*\""
            "\\1 \"${TDE_VERSION_STRING}\"" ENTITIES_DATA "${ENTITIES_DATA}" )
  else( )
    set( ENTITIES_DATA
         "${ENTITIES_DATA}<!ENTITY tde-release-version \"${TDE_VERSION_STRING}\">\n" )
  endif( )
  if( "${ENTITIES_DATA}" MATCHES "ENTITY tde-release-date" )
    string( REGEX REPLACE "(ENTITY tde-release-date) \"[^\"]*\""
            "\\1 \"${TDE_RELEASE_DATE}\"" ENTITIES_DATA "${ENTITIES_DATA}" )
  else( )
    set( ENTITIES_DATA
         "${ENTITIES_DATA}<!ENTITY tde-release-date \"${TDE_RELEASE_DATE}\">\n" )
  endif( )
  if( "${ENTITIES_DATA}" MATCHES "ENTITY tde-copyright-date" )
    string( REGEX REPLACE "(ENTITY tde-copyright-date) \"[^\"]*\""
            "\\1 \"${TDE_RELEASE_COPYRIGHT}\"" ENTITIES_DATA "${ENTITIES_DATA}" )
  else( )
    set( ENTITIES_DATA
         "${ENTITIES_DATA}<!ENTITY tde-copyright-date \"${TDE_RELEASE_COPYRIGHT}\">\n" )
  endif( )
  file( WRITE ${ENTITIES_FILE} "${ENTITIES_DATA}" )
  set( TDE_RELEASE_ENTITIES 1 CACHE INTERNAL "" )

endif( )