-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
99 lines (83 loc) · 3.26 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
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
99
# Copyright (C) 2021 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
cmake_minimum_required(VERSION 3.13)
project(frontend LANGUAGES C CXX)
set(CMAKE_PROJECT_NAME ${PROJECT_NAME})
if(CMAKE_BUILD_TYPE)
set(RELEASE_TYPES
Debug
Release
RelWithDebInfo
MinSizeRel)
list(FIND RELEASE_TYPES ${CMAKE_BUILD_TYPE} INDEX_FOUND)
if(${INDEX_FOUND} EQUAL -1)
message(
FATAL_ERROR
"CMAKE_BUILD_TYPE must be one of Debug, Release, RelWithDebInfo, or MinSizeRel"
)
endif()
else()
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Choose the type of Build" FORCE)
endif()
message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
# versioning
configure_file("VERSION" "VERSION")
file(STRINGS "VERSION" ${CMAKE_PROJECT_NAME}_VERSION)
list(LENGTH ${CMAKE_PROJECT_NAME}_VERSION ${CMAKE_PROJECT_NAME}_VERSION_LEN)
if(${CMAKE_PROJECT_NAME}_VERSION_LEN LESS 4)
message(FATAL_ERROR "Invalid project version file format.")
endif()
list(GET ${CMAKE_PROJECT_NAME}_VERSION 0 ${CMAKE_PROJECT_NAME}_VERSION_PREFIX)
if(NOT ${CMAKE_PROJECT_NAME}_VERSION_PREFIX STREQUAL "v")
message(FATAL_ERROR "Invalid project version prefix format read from file.")
endif()
list(GET ${CMAKE_PROJECT_NAME}_VERSION 1 ${CMAKE_PROJECT_NAME}_VERSION_MAJOR)
list(GET ${CMAKE_PROJECT_NAME}_VERSION 2 ${CMAKE_PROJECT_NAME}_VERSION_MINOR)
list(GET ${CMAKE_PROJECT_NAME}_VERSION 3 ${CMAKE_PROJECT_NAME}_VERSION_REVISION)
set(VERSION_TXT "v${${CMAKE_PROJECT_NAME}_VERSION_MAJOR}.${${CMAKE_PROJECT_NAME}_VERSION_MINOR}.${${CMAKE_PROJECT_NAME}_VERSION_REVISION}")
if(${CMAKE_PROJECT_NAME}_VERSION_LEN GREATER 4)
list(GET ${CMAKE_PROJECT_NAME}_VERSION 4 ${CMAKE_PROJECT_NAME}_VERSION_BUILD)
set(VERSION_TXT "${VERSION_TXT}-${${CMAKE_PROJECT_NAME}_VERSION_BUILD}")
else()
set(${CMAKE_PROJECT_NAME}_VERSION_BUILD "")
endif()
message(STATUS "Project Version: ${VERSION_TXT}")
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
cmake_policy(SET CMP0079 NEW)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
option(HIDE_EXT_WARNINGS "Attempts to hide all warnings encountered by third-party projects" OFF)
message(STATUS "HIDE_EXT_WARNINGS: ${HIDE_EXT_WARNINGS}")
include(GNUInstallDirs)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
message(STATUS "CMAKE_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}")
# third party
include(FetchContent)
set(FETCHCONTENT_BASE_DIR ${CMAKE_BINARY_DIR}/third-party)
# common-lib
set(_COMPONENT_NAME "COMMON_LIB")
set(_COMPONENT_HEADER "hebench/modules")
set(_COMPONENT_LIB_NAME "hebench_common-lib")
set(_HEADER_ONLY FALSE)
include(cmake/utils/import-library.cmake)
## APIBridge
set(_COMPONENT_NAME "API_BRIDGE")
set(_COMPONENT_HEADER "hebench/api_bridge/api.h")
set(_COMPONENT_LIB_NAME "hebench_dynamic_lib_load" "api_bridge")
set(_HEADER_ONLY FALSE)
include(cmake/utils/import-library.cmake)
include(cmake/third-party/${_COMPONENT_NAME}_check.cmake)
# subprojects
add_subdirectory(report_gen)
add_subdirectory(dataset_loader)
add_subdirectory(test_harness)
## yaml-cpp
set(_COMPONENT_NAME "YAML_CPP")
set(_COMPONENT_HEADER "yaml-cpp/yaml.h")
set(_COMPONENT_LIB_NAME "yaml-cpp")
set(_HEADER_ONLY FALSE)
set(_LINK_TO "test_harness")
include(cmake/utils/import-library.cmake)