|  | 
| 3 | 3 | 
 | 
| 4 | 4 | Simplified CMake-based build system for the timelib library. | 
| 5 | 5 | 
 | 
| 6 |  | -## Usage | 
|  | 6 | +## Configuration variables | 
|  | 7 | +
 | 
|  | 8 | +* `TIMELIB_NAMESPACE` | 
|  | 9 | +
 | 
|  | 10 | +  Namespace string used as the project name and variables prefix. If not | 
|  | 11 | +  specified, default value is `TIMELIB`. | 
|  | 12 | +
 | 
|  | 13 | +  * `<TIMELIB_NAMESPACE>_VERSION`. | 
|  | 14 | +
 | 
|  | 15 | +* `TIMELIB_TARGET` | 
|  | 16 | +
 | 
|  | 17 | +  If specified, this target will be used to add timelib source files to it and | 
|  | 18 | +  compile properties. If not specified, a library target named `timelib` will be | 
|  | 19 | +  created. | 
|  | 20 | +
 | 
|  | 21 | +## Examples | 
| 7 | 22 | 
 | 
| 8 | 23 | Adding timelib with `add_subdirectory()`: | 
| 9 | 24 | 
 | 
| 10 | 25 | ```cmake | 
|  | 26 | +set(TIMELIB_NAMESPACE "PHP_EXT_DATE_TIMELIB") | 
| 11 | 27 | set(TIMELIB_TARGET php_ext_date) | 
| 12 | 28 | add_subdirectory(lib) | 
| 13 | 29 | ``` | 
| 14 | 30 | #]=============================================================================] | 
| 15 | 31 | 
 | 
| 16 | 32 | cmake_minimum_required(VERSION 4.2...4.3) | 
| 17 | 33 | 
 | 
|  | 34 | +if(NOT TIMELIB_NAMESPACE) | 
|  | 35 | +  set(TIMELIB_NAMESPACE "TIMELIB") | 
|  | 36 | +endif() | 
|  | 37 | + | 
| 18 | 38 | # The timelib version. | 
| 19 |  | -block(PROPAGATE timelib_VERSION) | 
|  | 39 | +block(PROPAGATE ${TIMELIB_NAMESPACE}_VERSION) | 
| 20 | 40 |   file( | 
| 21 | 41 |     STRINGS | 
| 22 | 42 |     timelib.h | 
| 23 | 43 |     _ | 
| 24 | 44 |     REGEX "^[ \t]*#[ \t]*define[ \t]+TIMELIB_ASCII_VERSION[ \t]+\"([0-9.]+[^\"]*)" | 
| 25 | 45 |   ) | 
| 26 | 46 | 
 | 
| 27 |  | -  set(timelib_VERSION "${CMAKE_MATCH_1}") | 
|  | 47 | +  set(${TIMELIB_NAMESPACE}_VERSION "${CMAKE_MATCH_1}") | 
| 28 | 48 | 
 | 
| 29 |  | -  message(STATUS "Configuring timelib ${timelib_VERSION}") | 
|  | 49 | +  message(STATUS "Configuring timelib ${${TIMELIB_NAMESPACE}_VERSION}") | 
| 30 | 50 | endblock() | 
| 31 | 51 | 
 | 
| 32 | 52 | project( | 
| 33 |  | -  timelib | 
| 34 |  | -  VERSION ${timelib_VERSION} | 
|  | 53 | +  ${TIMELIB_NAMESPACE} | 
|  | 54 | +  VERSION ${${TIMELIB_NAMESPACE}_VERSION} | 
| 35 | 55 |   #SPDX_LICENSE "MIT" | 
| 36 | 56 |   DESCRIPTION "Timezone and date/time library" | 
| 37 | 57 |   HOMEPAGE_URL "https://github.com/derickr/timelib" | 
|  | 
0 commit comments