Updated version information
dc / build (push) Successful in 15s
Details
dc / build (push) Successful in 15s
Details
This commit is contained in:
parent
4a71a91ee8
commit
0e15856762
|
@ -1,10 +1,25 @@
|
|||
cmake_minimum_required(VERSION 3.12)
|
||||
project(dc)
|
||||
|
||||
# Project name and version
|
||||
project(dc VERSION 1.0.4)
|
||||
|
||||
# Retrieve git hash
|
||||
execute_process(
|
||||
COMMAND git rev-parse --short HEAD
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE DC_GIT_HASH
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
|
||||
# Set C++ version
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
|
||||
# Set debug flags by default
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE Debug)
|
||||
endif()
|
||||
|
||||
# Debug build flags
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} \
|
||||
-Wall -Wextra -pedantic -Werror \
|
||||
-fstack-protector-strong -D_FORTIFY_SOURCE=2 \
|
||||
|
@ -12,11 +27,28 @@ set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} \
|
|||
-fstack-clash-protection -Wundef -Wshadow -Wpointer-arith \
|
||||
-Wcast-align -Wwrite-strings -ftrapv -std=c++20 -g -O2")
|
||||
|
||||
# Release build flags
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -std=c++20")
|
||||
|
||||
add_executable(dc main.cpp)
|
||||
include_directories(src)
|
||||
# Get build flags
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
set(DC_FLAGS "${CMAKE_CXX_FLAGS_DEBUG}")
|
||||
elseif(CMAKE_BUILD_TYPE STREQUAL "Release")
|
||||
set(DC_FLAGS "${CMAKE_CXX_FLAGS_RELEASE}")
|
||||
endif()
|
||||
|
||||
# Main file
|
||||
add_executable(dc main.cpp)
|
||||
|
||||
# Source files
|
||||
include_directories(src)
|
||||
add_subdirectory(src)
|
||||
|
||||
target_link_libraries(dc src)
|
||||
# Link sources to main
|
||||
target_link_libraries(dc src)
|
||||
|
||||
# Pass variables to the preprocessor
|
||||
add_compile_definitions(DC_VER="${PROJECT_VERSION}")
|
||||
add_compile_definitions(DC_HASH="${DC_GIT_HASH}")
|
||||
add_compile_definitions(DC_BUILD="${CMAKE_BUILD_TYPE}")
|
||||
add_compile_definitions(DC_FLAGS="${DC_FLAGS}")
|
||||
|
|
15
main.cpp
15
main.cpp
|
@ -11,8 +11,6 @@
|
|||
|
||||
using namespace dc;
|
||||
|
||||
#define DC_VERSION "1.0.3"
|
||||
|
||||
void helper() {
|
||||
std::cout << "RPN desktop calculator with macro support. Usage: \n"
|
||||
<< "-e, --expression <EXPRESSION> | Evaluate an expression\n"
|
||||
|
@ -21,6 +19,17 @@ void helper() {
|
|||
<< "-V, --version | Show version" << std::endl;
|
||||
}
|
||||
|
||||
void version() {
|
||||
std::cout << "dc (v" << DC_VER << ", " << DC_HASH << ", " << DC_BUILD ")" << std::endl;
|
||||
std::cout << "Compile flags: " << DC_FLAGS << std::endl;
|
||||
std::cout << "Copyright (c) 2024 Marco Cetica" << std::endl;
|
||||
std::cout << "License GPLv3+: GNU GPL version 3 or later\n" << std::endl;
|
||||
std::cout << "The original version of the dc command was written by Robert Morris\n"
|
||||
<< "and Lorinda Cherry. This version of dc is developed by Marco Cetica.\n" << std::endl;
|
||||
std::cout << "Project homepage: <https://git.marcocetica.com/marco/dc>.\n"
|
||||
<< "Email bug reports to: <email@marcocetica.com>." << std::endl;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int opt;
|
||||
const char *short_opts = "e:f:hV";
|
||||
|
@ -57,7 +66,7 @@ int main(int argc, char **argv) {
|
|||
}
|
||||
break;
|
||||
case 'V': {
|
||||
std::cout << "dc v" << DC_VERSION << std::endl;
|
||||
version();
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue