-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
45 lines (34 loc) · 1.52 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
cmake_minimum_required(VERSION 3.5.0)
project(espressoSq VERSION 0.1.0 LANGUAGES C CXX)
set(SOURCE_FILES_COMMON src/sq_avx.cpp)
set(SOURCE_FILES_AVX2 "")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -march=native -fPIC")
include(CheckCXXCompilerFlag)
# Check for AVX or AVX2 support first. Rn library only works with x86 intrinsics, but i plan to add arm support with NEON in the future.
check_cxx_compiler_flag("-mavx2" COMPILER_SUPPORTS_AVX2)
if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|AMD64|i[3-6]86")
message(STATUS "CPU architecture is x86")
add_definitions(-DARCH_X86)
if(COMPILER_SUPPORTS_AVX2)
message(STATUS "Compiler supports AVX2")
add_definitions(-DSUPPORTS_AVX2)
add_definitions(-DSUPPORTS_SIMD)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx2")
set(SOURCE_FILES_AVX2 src/approx_trig_avx2.cpp)
else()
message(STATUS "Compiler does not support AVX2")
endif()
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "arm|aarch64|ARM")
message(STATUS "CPU architecture is ARM (AArch64)")
message(STATUS "Compiler supports NEON.")
# NEON is automatically available on AArch64
add_definitions(-DARCH_ARM)
add_definitions(-DSUPPORTS_NEON)
add_definitions(-DSUPPORTS_SIMD)
set(SOURCE_FILES_AVX2 src/approx_trig_avx2.cpp)
endif()
set(SOURCE_FILES_ALL ${SOURCE_FILES_COMMON} ${SOURCE_FILES_AVX2})
# Define the library
add_library(espressoSq ${SOURCE_FILES_ALL})
# Specify the include directories
target_include_directories(espressoSq PUBLIC ${CMAKE_SOURCE_DIR}/includes)