forked from rust-leipzig/regex-performance
-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
68 lines (49 loc) · 2.45 KB
/
CMakeLists.txt
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
#######################
# Main CMakeList.txt #
# Regex Performance #
######################
cmake_minimum_required(VERSION 3.0)
project(RegexPeformance C CXX)
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif()
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(GENERAL_C_FLAGS "-march=native -Wall -Wstack-usage=5000 -fdiagnostics-color -pipe -fsigned-char -fno-asynchronous-unwind-tables -fno-stack-protector -Wunused-parameter")
set(CMAKE_C_FLAGS "-std=c11 ${GENERAL_C_FLAGS}" CACHE STRING "additional CFLAGS" FORCE)
set(CMAKE_C_FLAGS_DEBUG "-O0 -g")
set(CMAKE_C_FLAGS_RELEASE "-O3")
set(CMAKE_CXX_FLAGS "-std=c++11 ${GENERAL_C_FLAGS}" CACHE STRING "additional CFLAGS" FORCE)
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
## BUILD TYPE
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: Release Debug" FORCE)
endif()
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Release" "Debug")
if(NOT CMAKE_BUILD_TYPE MATCHES "^(Release|Debug)$")
message(FATAL_ERROR "CMAKE_BUILD_TYPE='${CMAKE_BUILD_TYPE}', must be one of Release Debug")
endif()
# Receive the current version from git
execute_process(COMMAND git describe --tags
OUTPUT_VARIABLE GIT_TAG_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE)
string(REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9]+).*" "\\1" MAJOR_VERSION_GIT ${GIT_TAG_VERSION})
string(REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9]+).*" "\\2" MINOR_VERSION_GIT ${GIT_TAG_VERSION})
string(REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9]+).*" "\\3" PATCH_VERSION_GIT ${GIT_TAG_VERSION})
# Write default version numbers. Values can be overwritten on command line.
set(MAJOR_VERSION "${MAJOR_VERSION_GIT}" CACHE STRING "major version")
set(MINOR_VERSION "${MINOR_VERSION_GIT}" CACHE STRING "minor version")
set(PATCH_VERSION "${PATCH_VERSION_GIT}" CACHE STRING "patch version")
string(CONCAT VERSION "${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}")
string(TIMESTAMP BUILD_DATE "%Y-%m-%dT%H:%M:%S")
message("")
message("*******************************************************************")
message("* Regex performance tool version ${VERSION}")
message("* Build type: ${CMAKE_BUILD_TYPE}")
message("* Can be changed with: cmake -DCMAKE_BUILD_TYPE=[Release|Debug]")
message("*******************************************************************")
message("")
add_subdirectory(vendor)
add_subdirectory(src)
message("")