-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
57 lines (45 loc) · 1.46 KB
/
CMakeLists.txt
File metadata and controls
57 lines (45 loc) · 1.46 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
cmake_minimum_required(VERSION 3.25)
project(cpuscope VERSION 0.1.0 LANGUAGES C CXX)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
message(FATAL_ERROR "In-source builds are not allowed. Please use a separate build directory.")
endif()
option(CPUSCOPE_WERROR "Enable CI build mode and treat warnings as errors" OFF)
option(ENABLE_MARCH_NATIVE "Enable -march=native optimization" OFF)
option(CPUSCOPE_BUILD_TESTS "Build tests" OFF)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
endif()
if(CMAKE_CXX_COMPILER_ID MATCHES "^(GNU|Clang|AppleClang)$")
add_compile_options(-Wall -Wextra -Wpedantic)
if(CPUSCOPE_WERROR)
add_compile_options(-Werror)
endif()
if(ENABLE_MARCH_NATIVE)
add_compile_options(-march=native)
endif()
endif()
if(NOT CMAKE_CXX_FLAGS MATCHES "-O[0-3s]")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2")
endif()
find_package(Threads REQUIRED)
find_package(LLVM QUIET)
if(CPUSCOPE_BUILD_TESTS)
include(CTest)
enable_testing()
include(FetchContent)
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG v1.17.0
)
FetchContent_MakeAvailable(googletest)
endif()
add_subdirectory(lib)
add_subdirectory(cli)
if(CPUSCOPE_BUILD_TESTS)
add_subdirectory(tests)
endif()