-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
79 lines (64 loc) · 1.93 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
cmake_minimum_required(VERSION 3.5)
if (POLICY CMP0048)
cmake_policy(SET CMP0048 NEW)
endif(POLICY CMP0048)
project(Rsvd VERSION 0.1.0 LANGUAGES CXX)
include(CTest)
set (CMAKE_CXX_STANDARD 14)
set (CMAKE_CXX_STANDARD_REQUIRED ON)
set (CMAKE_CXX_EXTENSIONS OFF)
set (CMAKE_EXPORT_COMPILE_COMMANDS ON)
option(RSVD_BUILD_EXAMPLES "Build the examples" ON)
option(RSVD_MARCH_NATIVE "Compile for the native microarchitecture" OFF)
option(RSVD_OPENMP "Use OpenMP" ON)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_LIST_DIR}/cmake")
find_package(Eigen3 REQUIRED)
set(
HEADERS
include/rsvd/Constants.hpp
include/rsvd/ErrorEstimators.hpp
include/rsvd/GramSchmidt.hpp
include/rsvd/Prelude.hpp
include/rsvd/RandomizedRangeFinder.hpp
include/rsvd/RandomizedSvd.hpp
include/rsvd/StandardNormalRandom.hpp
)
include_directories(
"include"
${Eigen3_INCLUDE_DIR}
)
# Flags
set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wpedantic -Werror -g")
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DEIGEN_NO_DEBUG")
# Examples
if(RSVD_BUILD_EXAMPLES)
add_executable(example_benchmark "examples/Benchmark/main.cpp")
add_executable(example_simple_usage "examples/SimpleUsage/main.cpp")
endif()
# -march=native
if(RSVD_MARCH_NATIVE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -march=native")
endif()
# -fopenmp
if(RSVD_OPENMP)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fopenmp")
endif()
# Unit Tests
set(
TESTS
test/ErrorEstimators.cpp
test/GramSchmidt.cpp
test/RandomizedRangeFinder.cpp
test/RandomizedSvd.cpp
test/StandardNormalRandom.cpp
)
if(BUILD_TESTING)
enable_testing()
add_subdirectory("external/googletest")
include_directories("external/googletest/include")
add_executable(rsvd_test ${TESTS} ${HEADERS})
target_link_libraries(rsvd_test PRIVATE gtest gtest_main)
add_test(Rsvd rsvd_test)
endif()