-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding example project and cmake build process
- Loading branch information
1 parent
f6e9529
commit 367ace9
Showing
4 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
cmake_minimum_required(VERSION 3) | ||
|
||
project(starter | ||
DESCRIPTION "a starter repo for building Universal applications" | ||
VERSION "0.0.1" | ||
LANGUAGES C CXX ASM | ||
HOMEPAGE_URL "https://github.com/stillwater-sc/universal") | ||
|
||
set(CMAKE_CXX_STANDARD 20) | ||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
|
||
find_package(Boost) | ||
if(Boost_FOUND) | ||
message(STATUS "Boost_INCLUDE_DIR" ${Boost_INCLUDE_DIR}) | ||
include_directories(${Boost_INCLUDE_DIR}) | ||
endif(Boost_FOUND) | ||
|
||
set(STARTER_ROOT_DIR ${PROJECT_SOURCE_DIR}) | ||
set(STARTER_INSTALL_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/include) | ||
set(STARTER_INSTALL_LIB_DIR ${PROJECT_SOURCE_DIR}/lib) | ||
set(STARTER_INSTALL_BIN_DIR ${PROJECT_SOURCE_DIR}/bin) | ||
|
||
add_definitions(-D UNIVERSAL_ENABLE_TEST=OFF) | ||
|
||
# include file for common includes | ||
include_directories(${STARTER_INSTALL_INCLUDE_DIR}) | ||
|
||
enable_testing() | ||
#include(CTest) | ||
|
||
# Universal is a C++ header-only library, so we do not need to build anything | ||
# if you do add this line, you will get all the Universal regression tests, | ||
# playground, education, applications, and command line utilities. | ||
# You can only add this build subdirectory to ONE and only ONE project | ||
# within the starter workspace. Multiple includes will yield multiple definitions | ||
# of build, install, and uninstall targets. | ||
#add_subdirectory(${STARTER_ROOT_DIR}/ext/stillwater-sc/universal build_universal) | ||
|
||
# MTL4 is a C++ header-only library, so we do not need to build anything | ||
#add_subdirectory(${STARTER_ROOT_DIR}/ext/stillwater-sc/mtl4 build_mtl4) | ||
|
||
add_subdirectory(src) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
cmake_minimum_required(VERSION 3.22) | ||
project(starter_examples) | ||
|
||
# simple starter skeleton for projects that use the Universal Number System library | ||
add_subdirectory(apps/example) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
cmake_minimum_required(VERSION 3.22) | ||
set(app_name example) | ||
project(${app_name} CXX) | ||
|
||
# Universal is a C++ header-only library, so we do not need to build anything | ||
include_directories(${STARTER_ROOT_DIR}/ext/stillwater-sc/universal/include) | ||
|
||
# source files that make up the command | ||
set(SOURCE_FILES | ||
example.cpp | ||
) | ||
|
||
add_executable(${app_name} ${SOURCE_FILES}) | ||
set(folder "Applications/Example") | ||
set_target_properties(${app_name} PROPERTIES FOLDER ${folder}) | ||
|
||
# add libraries if you need them | ||
#target_link_libraries(example required-library1 required-library2) | ||
install(TARGETS ${app_name} DESTINATION ${STARTER_INSTALL_BIN_DIR}) | ||
#install(FILES my-consolidated-include.hpp DESTINATION ${STARTER_INSTALL_INCLUDE_DIR}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#include <iostream> | ||
#include <iomanip> | ||
#include <cmath> | ||
|
||
#include <universal/number/edecimal/edecimal.hpp> | ||
#include <universal/number/fixpnt/fixpnt.hpp> | ||
|
||
int main(int argc, char* argv) | ||
try { | ||
edecimal d, e, f; | ||
|
||
e = 1.0f; | ||
f = 0xFFFF'FFFF'FFFF'FFFFull; | ||
d = e + f; | ||
|
||
std::cout << d << std::endl; | ||
|
||
return EXIT_SUCCESS; | ||
|
||
} | ||
catch (const char* msg) { | ||
std::cerr << msg << std::endl; | ||
return EXIT_FAILURE; | ||
} | ||
catch (const sw::universal::arithmetic_exception& err) { | ||
std::cerr << "Unprocessed universal arithmetic exception: " << err.what() << std::endl; | ||
return EXIT_FAILURE; | ||
} | ||
catch (...) { | ||
std::cerr << "Caught unknown exception" << std::endl; | ||
return EXIT_FAILURE; | ||
} |