-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
85 lines (71 loc) · 3.08 KB
/
CMakeLists.txt
File metadata and controls
85 lines (71 loc) · 3.08 KB
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
cmake_minimum_required(VERSION 3.15)
SET(TEXTPARSER_VERSION_TAG CACHE STRING "")
SET(REVISION CACHE STRING "0")
if(NOT TEXTPARSER_VERSION_TAG)
find_package(Git QUIET)
set(GIT_DIR_PATH "${CMAKE_CURRENT_SOURCE_DIR}/.git")
if(EXISTS ${GIT_DIR_PATH})
if(Git_FOUND)
execute_process(
COMMAND ${GIT_EXECUTABLE} describe --tags --abbrev=0
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE TEXTPARSER_VERSION_TAG
OUTPUT_STRIP_TRAILING_WHITESPACE # Removes trailing newline/whitespace
RESULT_VARIABLE GIT_DESCRIBE_RESULT
ERROR_QUIET
)
execute_process(
COMMAND ${GIT_EXECUTABLE} rev-list ${TEXTPARSER_VERSION_TAG}..HEAD --count
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE GIT_REVISION
OUTPUT_STRIP_TRAILING_WHITESPACE # Removes trailing newline/whitespace
RESULT_VARIABLE GIT_REV_LIST_RESULT
ERROR_QUIET
)
execute_process(
COMMAND ${GIT_EXECUTABLE} describe --tags --dirty
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE GIT_COMMIT_NAME
OUTPUT_STRIP_TRAILING_WHITESPACE # Removes trailing newline/whitespace
RESULT_VARIABLE GIT_DESCRIBE_RESULT
ERROR_QUIET
)
set(REVISION ${GIT_REVISION})
endif()
endif()
endif()
if(NOT TEXTPARSER_VERSION_TAG MATCHES "^[0-9]+\\.[0-9]+\\.[0-9]+$")
message(FATAL_ERROR "Git last tag '${TEXTPARSER_VERSION_TAG}' is not in format X.Y.Z")
endif()
string(REGEX REPLACE "^([0-9]+\\.[0-9]+)\\..*$" "\\1" TEXTPARSER_VERSION_TAG_SHORT ${TEXTPARSER_VERSION_TAG})
project(textparser)
include(GNUInstallDirs)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin")
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/definitions/json_definition.json.h
COMMAND python ./json2h.py json_definition.json
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/definitions/json_definition.json
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/definitions
)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/definitions/cfml_definition.json.h
COMMAND python ./json2h.py cfml_definition.json
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/definitions/cfml_definition.json
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/definitions
)
add_subdirectory(src)
add_subdirectory(cli)
add_subdirectory(ccat)
add_subdirectory(tests)
# PkgConfig config
configure_file(textparser.pc.in textparser.pc @ONLY)
configure_file(textparser-json.pc.in textparser-json.pc @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/textparser.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
COMPONENT src)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/textparser-json.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
COMPONENT src)