-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
67 lines (54 loc) · 1.92 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
cmake_minimum_required(VERSION 3.15)
project(yaef VERSION 0.1.0 LANGUAGES C CXX)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
set(YAEF_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include")
set(YAEF_TESTS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/tests")
set(YAEF_BENCHMARKS_DIR "${YAEF_TEST_DIR}/benchmarks")
# normal library options
option(YAEF_OPTS_ENABLE_TESTS "enable unit tests" OFF)
option(YAEF_OPTS_ENABLE_BENCHMARKS "enable benchmarks" OFF)
# development-only options
option(_YAEF_DEV_OPTS_ENABLE_TEMP_RESULT_OUTPUT "(DEV-only) output the intemediate assembly code" OFF)
macro(yaef_info _msg)
string(CONCAT rem_msg ${ARGN})
message(STATUS "[yaef] ${_msg}${rem_msg}")
endmacro()
macro(yaef_fatal _msg)
string(CONCAT rem_msg ${ARGN})
message(FATAL_ERROR "[yaef] ${_msg}${rem_msg}")
endmacro()
if(YAEF_OPTS_ENABLE_TESTS)
yaef_info("unit tests are enabled")
else()
yaef_info("unit tests are disabled")
endif()
if(YAEF_OPTS_ENABLE_BENCHMARKS)
yaef_info("benchmarks are enabled")
else()
yaef_info("benchmarks are disabled")
endif()
add_library(yaef INTERFACE)
add_library(yaef::yaef ALIAS yaef)
target_include_directories(yaef INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/include")
if(MSVC)
target_compile_options(yaef INTERFACE /arch:AVX2)
if(_YAEF_DEV_OPTS_ENABLE_TEMP_RESULT_OUTPUT)
if(NOT ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" AND "_${CMAKE_CXX_SIMULATE_ID}" STREQUAL "_MSVC"))
target_compile_options(yaef INTERFACE /FAs)
endif()
endif()
else()
target_compile_options(yaef INTERFACE -Wall -Wextra
-msse -msse2 -msse3 -mssse3 -msse4 -msse4a -msse4.1 -msse4.2 -mavx -mavx2 -mbmi -mbmi2)
if(_YAEF_DEV_OPTS_ENABLE_TEMP_RESULT_OUTPUT)
target_compile_options(yaef INTERFACE -save-temps -fverbose-asm -masm=intel)
endif()
endif()
if(YAEF_OPTS_ENABLE_TESTS)
add_subdirectory(deps/Catch2)
add_subdirectory(tests)
endif()
if(YAEF_OPTS_ENABLE_BENCHMARKS)
add_subdirectory(tests/benchmarks)
endif()