-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
58 lines (44 loc) · 1.59 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
cmake_minimum_required(VERSION 3.25)
include("FindAVX.cmake")
project(
randavx
LANGUAGES CXX
DESCRIPTION "random number generator that aims to be fast (uses avx512)"
VERSION 1.0
)
if (MSVC)
CHECK_FOR_AVX()
endif ()
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
option(RANDAVX_BENCHMARK "enables building of benchmarks" ON)
option(RANDAVX_BUILD_EXAMPLES "enables building of examples" ON)
if (LINUX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -mtune=native")
elseif (WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${AVX_FLAGS}")
else ()
message("i dont know about your platform :p")
endif ()
add_library(mqh_randavx INTERFACE)
target_include_directories(mqh_randavx INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>)
add_library(mqh::randavx ALIAS mqh_randavx)
if (RANDAVX_BENCHMARK)
set(BENCHMARK_ENABLE_GTEST_TESTS OFF)
set(BENCHMARK_ENABLE_TESTING OFF)
add_subdirectory(vendor/benchmark)
add_executable(benchmark_throughput benchmark/throughput.cc)
target_link_libraries(benchmark_throughput mqh::randavx benchmark)
add_executable(benchmark_unique benchmark/unique.cc)
target_link_libraries(benchmark_unique mqh::randavx)
add_executable(benchmark_randavx benchmark/bench.cc)
target_link_libraries(benchmark_randavx mqh::randavx benchmark)
endif ()
if (RANDAVX_BUILD_EXAMPLES)
add_executable(example1 example/example1.cc)
target_link_libraries(example1 mqh::randavx)
add_executable(example2 example/example2.cc)
target_link_libraries(example2 mqh::randavx)
add_executable(example3 example/example3.cc)
target_link_libraries(example3 mqh::randavx)
endif ()