-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
53 lines (44 loc) · 1.67 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
cmake_minimum_required(VERSION 3.1)
project(torchinfer LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 20)
# Build type
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
endif()
# Options can be turned on and off by providing cmake with a -DOPTIONNAME=ON (or OFF) argument.
# cmake .. -DCMAKE_BUILD_TYPE=DEBUG -DBUILD_SANITIZE=OFF
option(BUILD_SANITIZE "Adds sanitive flags" ON)
option(BUILD_ARGPARSE "Argparse" ON)
option(BUILD_SPDLOG "Logger" ON)
option(BUILD_BENCHMARK "Benchmark" OFF)
# Compilation flags
set(OPT_FLAGS "-Ofast -march=native -flto")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic -pthread -Werror")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${OPT_FLAGS}")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -g3 -Wno-unused-parameter")
if(BUILD_SANITIZE)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=address")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fsanitize=address")
endif()
if (BUILD_ARGPARSE)
add_subdirectory(third_party/argparse)
endif()
if (BUILD_SPDLOG)
add_subdirectory(third_party/spdlog)
endif()
if (BUILD_BENCHMARK)
add_subdirectory(third_party/gtest)
add_subdirectory(third_party/gbenchmark)
endif()
# Binary directories
add_subdirectory(targets)
add_subdirectory(bench)
# Status build
message(STATUS "")
message(STATUS "BUILD SUMMARY")
message(STATUS " Build type : ${CMAKE_BUILD_TYPE}")
message(STATUS " Sanitize flags : ${BUILD_SANITIZE}")
message(STATUS " Argparse : ${BUILD_ARGPARSE}")
message(STATUS " Logger : ${BUILD_SPDLOG}")
message(STATUS " Benchmark : ${BUILD_BENCHMARK}")
message(STATUS "")