-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathCMakeLists.txt
61 lines (52 loc) · 1.85 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
cmake_minimum_required(VERSION 3.14)
project(meojson CXX)
include_directories(./include)
option(BUILD_SAMPLE "Build sample in sample/sample.cpp" ON)
option(BUILD_BENCHMARK "Build benchmark in benchmark/benchmark.cpp" OFF)
option(ENABLE_NEON "Enable ARM NEON" OFF)
option(BUILD_TESTING "Build testing" ON)
set(CMAKE_CXX_STANDARD 17)
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" OR CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC")
add_compile_options("/utf-8" "/W4" "/WX")
else()
add_compile_options("-Wall;-Wextra;-Wpedantic;-Werror;-mtune=native")
if(CMAKE_SYSTEM_PROCESSOR MATCHES "AMD64|EM64T|x86_64")
add_compile_options("-msse4.1")
endif()
endif()
if(ENABLE_NEON)
add_compile_definitions(MEOJSON_ENABLE_NEON)
endif()
if (BUILD_SAMPLE)
add_executable(sample sample/sample.cpp include/json.hpp)
add_executable(json5_parse_sample sample/json5_parse.cpp include/json.hpp include/json5.hpp)
endif()
if (BUILD_TESTING)
file(GLOB testing_src
test/*.cpp
test/*.h
test/*.hpp
)
add_executable(testing ${testing_src} include/json.hpp)
file(GLOB testing20_src
test20/*.cpp
test20/*.h
test20/*.hpp
)
add_executable(testing20 ${testing20_src} include/json.hpp)
set_target_properties(testing20
PROPERTIES
CXX_STANDARD 20
)
endif()
if (BUILD_BENCHMARK)
SET(CMAKE_BUILD_TYPE "Release")
add_executable(benchmark benchmark/benchmark.cpp include/json.hpp)
if(CMAKE_SYSTEM_PROCESSOR MATCHES "AMD64|EM64T|x86_64")
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" OR CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC")
target_compile_options(benchmark PRIVATE "/arch:AVX2")
elseif(CMAKE_CXX_COMPILER_FRONTEND_VARIANT MATCHES "GNU|Clang")
target_compile_options(benchmark PRIVATE "-mavx2")
endif()
endif()
endif()