-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
59 lines (49 loc) · 1.97 KB
/
CMakeLists.txt
File metadata and controls
59 lines (49 loc) · 1.97 KB
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
cmake_minimum_required(VERSION 3.10)
# Clone GoogleTest if not present
if(NOT EXISTS "${CMAKE_SOURCE_DIR}/third_party/googletest")
execute_process(
COMMAND git clone https://github.com/google/googletest.git "${CMAKE_SOURCE_DIR}/third_party/googletest"
RESULT_VARIABLE result
)
if(NOT result EQUAL 0)
message(FATAL_ERROR "Failed to clone googletest")
endif()
endif()
# Clone Google Benchmark if not present
if(NOT EXISTS "${CMAKE_SOURCE_DIR}/third_party/benchmark")
execute_process(
COMMAND git clone https://github.com/google/benchmark.git "${CMAKE_SOURCE_DIR}/third_party/benchmark"
RESULT_VARIABLE result
)
if(NOT result EQUAL 0)
message(FATAL_ERROR "Failed to clone benchmark")
endif()
endif()
project(BasicSIMD)
set(CMAKE_CXX_STANDARD 11)
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
endif()
add_library(BasicSIMD INTERFACE)
target_include_directories(BasicSIMD INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
target_sources(BasicSIMD INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/SIMD.h)
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
target_compile_options(BasicSIMD INTERFACE /arch:AVX2)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# Save assembly output with very detailed annotations
target_compile_options(BasicSIMD INTERFACE -march=native -fno-strict-aliasing -O3 -fno-tree-vectorize)
endif()
# Tests
if (NOT DISABLE_TESTS)
set(BENCHMARK_ENABLE_TESTING OFF CACHE BOOL "" FORCE)
set(BENCHMARK_ENABLE_GTEST_TESTS OFF CACHE BOOL "" FORCE)
set(gtest_build_samples OFF CACHE BOOL "" FORCE)
set(gtest_build_tests OFF CACHE BOOL "" FORCE)
set(gmock_build_tests OFF CACHE BOOL "" FORCE)
add_subdirectory(third_party/googletest)
# Add Google Benchmark
add_subdirectory(third_party/benchmark)
# Your test executable
add_executable(BasicSIMD_Tests tests/simd_tests.cpp)
target_link_libraries(BasicSIMD_Tests PRIVATE BasicSIMD gtest gtest_main benchmark benchmark_main)
endif()