-
Notifications
You must be signed in to change notification settings - Fork 508
/
CMakeLists.txt
90 lines (78 loc) · 3.14 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
80
81
82
83
84
85
86
87
88
89
cmake_minimum_required(VERSION 3.0)
project(ZQCNN)
set(CMAKE_CXX_STANDARD 11)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE release CACHE STRING "Choose the type of build" FORCE)
endif()
if(NOT SIMD_ARCH_TYPE)
set(SIMD_ARCH_TYPE x86)
endif()
if(NOT BLAS_TYPE)
set(BLAS_TYPE ZQ_GEMM)
endif()
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(archbit "x64")
else()
set(archbit "x86")
endif()
if(WIN32)
set(archos "win32")
elseif(UNIX)
set(archos "unix")
endif()
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/cmake-out-${archos}-${archbit}/${CMAKE_BUILD_TYPE})
#message("CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
file(MAKE_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
if(WIN32)
execute_process(COMMAND "MKLINK" /D ${CMAKE_CURRENT_LIST_DIR}/data ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/data)
execute_process(COMMAND "MKLINK" /D ${CMAKE_CURRENT_LIST_DIR}/model ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/model)
elseif(UNIX)
execute_process(COMMAND "ln" -nsf ${CMAKE_CURRENT_LIST_DIR}/data ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/data)
execute_process(COMMAND "ln" -nsf ${CMAKE_CURRENT_LIST_DIR}/model ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/model)
endif()
if((CMAKE_CXX_COMPILER_ID MATCHES "GNU") OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
#add_definitions(-Wall -Wextra -Wno-unused-function)
add_definitions(-fPIC)
if(CMAKE_BUILD_TYPE MATCHES "(Release|RELEASE|release)")
add_definitions(-Ofast)
add_definitions(-ffast-math)
endif()
if(SIMD_ARCH_TYPE MATCHES "(arm|arm64|arm64-fp16)")
add_definitions(-DZQ_CNN_USE_ARM_NEON)
if(SIMD_ARCH_TYPE MATCHES "arm64|arm64-fp16")
add_definitions(-march=armv8-a)
add_definitions(-DZQ_CNN_USE_ARM_NEON_ARMV8)
add_definitions(-DZQ_CNN_USE_FMADD128)
if(SIMD_ARCH_TYPE MATCHES "arm64-fp16")
add_definitions(-DZQ_CNN_USE_ARM_NEON_FP16)
add_definitions(-mfpu=neon-fp-armv8)
endif()
else()
#add_definitions(-march=native)
add_definitions(-mfpu=neon)
add_definitions(-mfloat-abi=softfp)
endif()
if(BLAS_TYPE MATCHES "zq_gemm")
add_definitions(-DZQ_CNN_USE_ZQ_GEMM=1)
elseif(BLAS_TYPE MATCHES "openblas")
add_definitions(-DZQ_CNN_USE_BLAS_GEMM=1)
elseif(BLAS_TYPE MATCHES "openblas_zq_gemm")
add_definitions(-DZQ_CNN_USE_BOTH_BLAS_ZQ_GEMM)
endif()
else()
add_compile_options(-mavx2)
endif()
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Intel")
add_compile_options(/QxAVX2)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
add_compile_options(/arch:AVX2)
endif()
set(ZQCNN_INCLUDE_DIRS ${CMAKE_CURRENT_LIST_DIR}/ZQ_GEMM
${CMAKE_CURRENT_LIST_DIR}/ZQCNN
${CMAKE_CURRENT_LIST_DIR}/3rdparty/include
CACHE INTERNAL "ZQCNN include dirs")
set(ZQCNN_LIBRARY_DIR ${CMAKE_CURRENT_LIST_DIR}/3rdparty/lib)
add_subdirectory(ZQ_GEMM)
add_subdirectory(ZQCNN)
add_subdirectory(SamplesZQCNN)
add_subdirectory(SamplesZQlibFaceID)