-
Notifications
You must be signed in to change notification settings - Fork 11
/
CMakeLists.txt
69 lines (61 loc) · 2.5 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
cmake_minimum_required(VERSION 3.0)
project(fast_ber VERSION "0.4")
if (NOT DEFINED CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 11)
endif()
option(SKIP_TESTING "Skip building tests" OFF)
option(SKIP_AUTO_GENERATION "Use checked in lexer rather than generating with bison" OFF)
if (NOT ${SKIP_TESTING})
enable_testing()
endif()
set(ABSEIL_LIBS absl::base absl::container absl::strings absl::variant absl::optional absl::time absl::flat_hash_set)
if (EXISTS "${CMAKE_BINARY_DIR}/conanbuildinfo.cmake")
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
set(ABSEIL_LIBS absl::absl)
find_package(absl REQUIRED CONFIG)
elseif (EXISTS "${CMAKE_SOURCE_DIR}/3rd_party/abseil-cpp/CMakeLists.txt")
add_subdirectory("3rd_party/abseil-cpp")
set(SKIP_INSTALL TRUE)
else()
find_package(absl REQUIRED)
endif()
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(default_build_type Release)
set(BENCHMARKS_INCLUDE_ASN1C true)
if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
add_compile_options("-O3" "-Wall" "-Wextra" "-pedantic" "-Wcast-align" "-Wpointer-arith" "-Wshadow")
add_compile_options("-Wfloat-equal" "-Wuninitialized")
add_compile_options("-Wno-missing-field-initializers") # Stop spam on g++-4.8
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wold-style-cast")
if (CMAKE_BUILD_TYPE MATCHES "Debug")
add_compile_options("-g")
if (${FB_ENABLE_SANITIZER})
message("Enabled sanitizer")
add_compile_options("-fsanitize=address" "-fsanitize=undefined" "-Werror")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address -fsanitize=undefined -static-libsan")
endif()
else()
add_definitions("-DNDEBUG -march=native")
if (NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
# Link time optimisation. Disabled on clang due to issue on travis
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -flto")
endif()
set(SKIP_AUTO_GENERATION true)
endif()
else()
set(SKIP_AUTO_GENERATION true) # Can't autogen on windows, used checked in files instead
set(BENCHMARKS_INCLUDE_ASN1C false)
set(CTEST_CONFIGURATION_TYPE "${CMAKE_BUILD_TYPE}")
add_compile_options("/W4")
add_compile_options("-DNOMINMAX")
if (CMAKE_BUILD_TYPE MATCHES "Release")
add_compile_options("/O2")
endif ()
endif()
add_subdirectory(src)
if (DEFINED CMAKE_TESTING_ENABLED)
add_subdirectory(test)
add_subdirectory(sample)
add_subdirectory(benchmarks)
endif()