forked from kfrlib/kfr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
93 lines (75 loc) · 2.83 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
90
91
92
93
# Copyright (C) 2016 D Levin (http://www.kfrlib.com)
# This file is part of KFR
#
# KFR is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# KFR is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with KFR.
cmake_minimum_required(VERSION 3.0)
set(CMAKE_CXX_FLAGS " ${CMAKE_CXX_FLAGS}" CACHE STRING "compile flags" FORCE)
project(kfr CXX)
message(STATUS "C++ compiler: ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION} ${CMAKE_CXX_COMPILER} ")
message(STATUS CMAKE_SYSTEM_PROCESSOR = ${CMAKE_SYSTEM_PROCESSOR})
if (MSVC)
message(STATUS MSVC)
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
set(CLANG 1)
else()
set(CLANG 0)
endif()
# Include list of source files
include(sources.cmake)
add_library(kfr INTERFACE)
target_sources(kfr INTERFACE ${KFR_SRC})
target_include_directories(kfr INTERFACE include)
add_library(kfr_dft include/kfr/dft/dft-src.cpp)
target_link_libraries(kfr_dft kfr)
add_definitions(-D_ENABLE_EXTENDED_ALIGNED_STORAGE)
option(ENABLE_TESTS "Enable tests and examples. This changes many compiler flags" OFF)
if (ENABLE_TESTS)
if (IOS)
set(STD_LIB)
else ()
set(STD_LIB stdc++)
endif ()
# Binary output directories
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${PROJECT_BINARY_DIR}/bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${PROJECT_BINARY_DIR}/bin/Debug)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
if (NOT MSVC OR CLANG)
# Enable C++14, disable exceptions and rtti
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
add_compile_options(-std=gnu++1y)
else ()
add_compile_options(-std=c++1y)
endif ()
add_compile_options(-fno-exceptions -fno-rtti )
if (NOT ARCH_FLAGS)
add_compile_options(-march=native)
message(STATUS "Building for native cpu")
if(WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mstackrealign -fno-asynchronous-unwind-tables")
endif()
else ()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ARCH_FLAGS}")
endif ()
if(NOT MSVC)
link_libraries(${STD_LIB} pthread m)
endif()
else ()
# Disable exceptions
add_compile_options(/EHsc /D_HAS_EXCEPTIONS=0 /D_CRT_SECURE_NO_WARNINGS=1)
add_compile_options(/arch:AVX)
endif ()
add_subdirectory(examples)
add_subdirectory(tests)
endif ()