-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
79 lines (69 loc) · 2.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
project(nanoblas C CXX ASM-ATT)
cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR)
function(nanoblas_target_setup)
foreach (tgt IN LISTS ARGV)
target_include_directories(${tgt} PRIVATE ${PROJECT_SOURCE_DIR}/src)
set_target_properties(${tgt} PROPERTIES C_STANDARD 99)
set_target_properties(${tgt} PROPERTIES C_STANDARD_REQUIRED ON)
if(${CMAKE_C_COMPILER_ID} MATCHES "GNU|Clang")
target_compile_options(${tgt} PRIVATE $<$<COMPILE_LANGUAGE:C>:-O3 -Werror -Wall -Wextra -Wpedantic -std=c99>)
endif()
if (has_builtin_prefetch)
target_compile_definitions(${tgt} PRIVATE HAS_BUILTIN_PREFETCH)
endif()
set_property(TARGET ${tgt} PROPERTY POSITION_INDEPENDENT_CODE ON)
endforeach()
endfunction()
include(${PROJECT_SOURCE_DIR}/cmake/detect_arch.cmake)
add_subdirectory(src)
foreach(s IN LISTS SRCS)
if (${s} MATCHES "_f32")
set(SRCS_F32 ${SRCS_F32} ${s})
elseif(${s} MATCHES "_f64")
set(SRCS_F64 ${SRCS_F64} ${s})
elseif(${s} MATCHES "_fxx")
set(SRCS_FXX ${SRCS_FXX} ${s})
else()
set(SRCS_TWICE ${SRCS_TWICE} ${s})
endif()
endforeach()
add_library(nanoblas_fxx OBJECT ${SRCS_FXX})
add_library(nanoblas_f32 OBJECT ${SRCS_TWICE} ${SRCS_F32})
add_library(nanoblas_f64 OBJECT ${SRCS_TWICE} ${SRCS_F64})
nanoblas_target_setup(nanoblas_fxx nanoblas_f32 nanoblas_f64)
target_compile_definitions(nanoblas_f32 PRIVATE USE_F32)
target_compile_definitions(nanoblas_f64 PRIVATE USE_F64)
add_library(nanoblas SHARED
$<TARGET_OBJECTS:nanoblas_fxx>
$<TARGET_OBJECTS:nanoblas_f32>
$<TARGET_OBJECTS:nanoblas_f64>
)
target_include_directories(nanoblas INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src>)
function(misc_target_setup)
foreach (tgt IN LISTS ARGV)
set_target_properties(${tgt} PROPERTIES C_STANDARD 99)
set_target_properties(${tgt} PROPERTIES C_STANDARD_REQUIRED ON)
set_target_properties(${tgt} PROPERTIES CXX_STANDARD 11)
set_target_properties(${tgt} PROPERTIES CXX_STANDARD_REQUIRED ON)
if(${CMAKE_C_COMPILER_ID} MATCHES "GNU|Clang")
target_compile_options(${tgt} PRIVATE $<$<COMPILE_LANGUAGE:C>:-O2 -Werror -Wall -Wextra -Wpedantic -std=c99>)
target_compile_options(${tgt} PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-O2 -Werror -Wall -Wextra -Wpedantic -std=c++11>)
endif()
endforeach()
endfunction()
option(ENABLE_TEST "enable test target" ON)
option(ENABLE_BENCH "enable benchmark target" ON)
option(ENABLE_PROFILE "enable profiling" OFF)
if (ENABLE_TEST)
enable_testing()
add_subdirectory(test)
endif()
if (ENABLE_BENCH)
add_subdirectory(bench)
endif()
if (ENABLE_PROFILE)
if(${CMAKE_C_COMPILER_ID} MATCHES "GNU|Clang")
set (CMAKE_C_FLAGS "-pg")
set (CMAKE_CXX_FLAGS "-pg")
endif()
endif()