use cmake everywhere for desktop build, fix build warnings

This commit is contained in:
Jeff Wang 2019-11-14 02:40:07 -05:00
parent f25a71b74c
commit f70510e46a
7 changed files with 32 additions and 12 deletions

View File

@ -1,8 +1,15 @@
cmake_minimum_required(VERSION 2.8)
cmake_minimum_required(VERSION 3.0)
# 3rd party tools
find_package(Qt5 COMPONENTS Widgets Qml Quick REQUIRED)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=c++11 -fsanitize=address,undefined")
# Compiler warnings
if(MSVC)
add_compile_options(/W4 /WX)
else()
add_compile_options(-Wall -Wextra -pedantic)
set(cpp_flags -std=c++11 -fsanitize=address,undefined)
add_compile_options("$<$<COMPILE_LANGUAGE:CXX>:${cxx_flags}>")
endif()
# Directory with source code
add_subdirectory(src)

View File

@ -1,13 +1,21 @@
# Qt
include_directories(${Qt5Widgets_INCLUDE_DIRS} ${QtQml_INCLUDE_DIRS})
add_definitions(${Qt5Widgets_DEFINITIONS} ${QtQml_DEFINITIONS} ${${Qt5Quick_DEFINITIONS}})
# decn library
add_library(decn decn/decn.c)
# calculator
add_library(calc qt_main.cpp calc.c utils.c lcd_emulator.c key.c)
target_link_libraries(calc Qt5::Widgets)
# tests
add_executable(keytest key.c)
target_compile_definitions(keytest PRIVATE KEY_TEST_APP=1)
add_executable(decn_test decn/decn_test.c utils.c)
target_link_libraries(decn_test decn)
# decn prototyping
add_subdirectory(decn/proto)

View File

@ -467,6 +467,7 @@ static int8_t compare_magn(void){ //returns a<b: -1, a==b: 0, a>b: 1
return a_signif_b;
}
#ifdef USE_COMPARE_DECN
static int8_t compare_decn(void){ //returns a<b: -1, a==b: 0, a>b: 1
int8_t is_neg;
@ -497,6 +498,7 @@ static int8_t compare_decn(void){ //returns a<b: -1, a==b: 0, a>b: 1
return is_neg * compare_magn();
}
#endif //USE_COMPARE_DECN
//WARNING: for add_decn() and sub_mag() functions only
//acc and the number from which exponent was taken MUST be stripped of leading 0s first

View File

@ -0,0 +1,9 @@
add_executable(div div_mfp.cpp)
target_link_libraries(div gmp)
add_executable(ln ln_mfp.cpp)
target_link_libraries(ln mpfr)
add_executable(exp exp.cpp)
target_link_libraries(exp mpfr)

View File

@ -1,10 +0,0 @@
all: div ln exp
div: div_mfp.cpp
g++ -Wall div_mfp.cpp -o div -lgmp
ln: ln_mfp.cpp
g++ -Wall ln_mfp.cpp -o ln -lmpfr
exp: exp.cpp
g++ -Wall exp.cpp -o exp -lmpfr

View File

@ -138,7 +138,9 @@ void raw_scan(void) __using(1){
//based on quick draw/integrator hybrid debounce algorithm from
//https://summivox.wordpress.com/2016/06/03/keyboard-matrix-scanning-and-debouncing/
#ifndef DESKTOP
#pragma nooverlay
#endif
void debounce(void) __using(1){
uint8_t i, j;
NewKeyPressed = -1; //initially

View File

@ -7,11 +7,13 @@
#ifdef DESKTOP
void _delay_ms(uint8_t ms){
//TODO:
(void) ms;
}
#ifdef ACCURATE_DELAY_US
void _delay_us(uint8_t us)
{
//TODO:
(void) us;
}
#endif
void backlight_off(void){ }