Skip to content
Snippets Groups Projects
Commit 53704c96 authored by Erik Strand's avatar Erik Strand
Browse files

Add skeletal C++ framework

parent 5811c44c
No related branches found
No related tags found
No related merge requests found
*.swp *.swp
*.swo *.swo
.DS_Store .DS_Store
build
cmake_minimum_required(VERSION 3.13) # 3.13 is required for target_link_options
project(CompressedSensing CXX)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
endif()
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
find_package (Eigen3 3.3 REQUIRED NO_MODULE)
include(cmake/shared_settings.cmake)
add_executable(compressed_sensing
main.cpp
vector.h
)
target_link_libraries(compressed_sensing shared_settings Eigen3::Eigen)
target_compile_features(compressed_sensing PUBLIC cxx_std_17)
# This file defines an interface library used to add common compile flags to all targets.
add_library(shared_settings INTERFACE)
# Warning flags
target_compile_options(shared_settings INTERFACE
-Wall
-Wcast-align
-Wcast-qual
-Wextra
-Wundef
-Wuseless-cast
-Wzero-as-null-pointer-constant
-pedantic
)
# Speed flags
target_compile_options(shared_settings INTERFACE -march=native -ffast-math)
# Build type for profile generation
target_compile_options(shared_settings INTERFACE $<$<CONFIG:ProfileGenerate>:
-fprofile-generate
-O3
-DNDEBUG
>)
target_link_options(shared_settings INTERFACE $<$<CONFIG:ProfileGenerate>:-fprofile-generate>)
# Build type for profile use
target_compile_options(shared_settings INTERFACE $<$<CONFIG:ProfileUse>:
-fprofile-use
-O3
-DNDEBUG
>)
target_link_options(shared_settings INTERFACE $<$<CONFIG:ProfileUse>:-fprofile-use>)
main.cpp 0 → 100644
#include <iostream>
#include "vector.h"
using namespace cs;
//--------------------------------------------------------------------------------------------------
int main() {
Vector<double> x = Vector<double>::Random(5);
std::cout << x << '\n';
return 0;
}
vector.h 0 → 100644
#ifndef FUNSIM_VECTOR_H
#define FUNSIM_VECTOR_H
#include <Eigen/Core>
namespace cs {
//--------------------------------------------------------------------------------------------------
template <typename T>
using Vector = Eigen::Matrix<T, Eigen::Dynamic, 1>;
//--------------------------------------------------------------------------------------------------
template <typename T>
using Matrix = Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>;
}
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment