2017-06-10 18:44:51 +02:00
|
|
|
# -*- mode: CMAKE; -*-
|
|
|
|
|
2017-06-10 19:00:40 +02:00
|
|
|
project(rpn)
|
2017-06-10 18:44:51 +02:00
|
|
|
|
2022-02-28 16:23:57 +01:00
|
|
|
cmake_minimum_required(VERSION 3.16)
|
2022-02-26 15:22:26 +01:00
|
|
|
|
2018-06-01 17:15:18 +02:00
|
|
|
if((NOT CMAKE_BUILD_TYPE MATCHES Debug)
|
|
|
|
AND (NOT CMAKE_BUILD_TYPE MATCHES Release))
|
2022-02-22 17:20:47 +01:00
|
|
|
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: None Debug Release" FORCE)
|
2017-06-10 18:44:51 +02:00
|
|
|
endif()
|
|
|
|
|
|
|
|
message(STATUS "Build mode: ${CMAKE_BUILD_TYPE}")
|
|
|
|
|
2022-02-28 10:49:49 +01:00
|
|
|
if(EXISTS "${PROJECT_SOURCE_DIR}/.git")
|
|
|
|
execute_process(COMMAND git describe --long HEAD OUTPUT_VARIABLE "GIT_VERSION" OUTPUT_STRIP_TRAILING_WHITESPACE)
|
|
|
|
add_definitions(-DGIT_VERSION="${GIT_VERSION}")
|
|
|
|
else(EXISTS ${PROJECT_SOURCE_DIR}/.git)
|
|
|
|
set(GIT_VERSION "unknown")
|
|
|
|
endif()
|
|
|
|
add_definitions(-DGIT_VERSION="${GIT_VERSION}")
|
|
|
|
message("GIT_VERSION is ${GIT_VERSION}")
|
2022-02-26 15:22:26 +01:00
|
|
|
|
2017-06-10 18:44:51 +02:00
|
|
|
# INFO
|
|
|
|
set(RPN_DISPLAY_NAME "rpn")
|
|
|
|
set(RPN_URL_INFO_ABOUT "https://github.com/louisrubet/rpn")
|
2017-06-12 21:59:44 +02:00
|
|
|
set(RPN_CONTACT "Louis Rubet <louis@rubet.fr>")
|
2022-02-26 15:22:26 +01:00
|
|
|
set(RPN_FRIENDLY_STRING "Reverse Polish Notation math language")
|
2017-06-19 21:43:26 +02:00
|
|
|
set(RPN_LICENSE "LGPLv3")
|
|
|
|
set(RPN_LICENSE_FILE "${PROJECT_SOURCE_DIR}/LICENSE")
|
|
|
|
set(RPN_DESCRIPTION_FILE "${PROJECT_SOURCE_DIR}/README.md")
|
2017-06-10 18:44:51 +02:00
|
|
|
|
2018-07-28 13:21:05 +02:00
|
|
|
# custom linenoise-ng
|
|
|
|
if(NOT EXISTS "${PROJECT_SOURCE_DIR}/linenoise-ng/.git")
|
2022-02-28 10:49:49 +01:00
|
|
|
execute_process(COMMAND git submodule init ${PROJECT_SOURCE_DIR}/linenoise-ng)
|
|
|
|
execute_process(COMMAND git submodule update ${PROJECT_SOURCE_DIR}/linenoise-ng)
|
|
|
|
execute_process(COMMAND git checkout v1.1.1-rpn WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/linenoise-ng)
|
2018-05-13 19:27:36 +02:00
|
|
|
endif()
|
|
|
|
|
2022-02-07 16:36:27 +01:00
|
|
|
# custom mpreal
|
|
|
|
if(NOT EXISTS "${PROJECT_SOURCE_DIR}/mpreal/.git")
|
2022-02-28 10:49:49 +01:00
|
|
|
execute_process(COMMAND git submodule init ${PROJECT_SOURCE_DIR}/mpreal)
|
|
|
|
execute_process(COMMAND git submodule update ${PROJECT_SOURCE_DIR}/mpreal)
|
|
|
|
execute_process(COMMAND git checkout mpfrc++-3.6.9 WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/mpreal)
|
2022-02-07 16:36:27 +01:00
|
|
|
endif()
|
|
|
|
|
2017-06-12 21:59:44 +02:00
|
|
|
# includes
|
2022-02-07 16:36:27 +01:00
|
|
|
include_directories(${PROJECT_SOURCE_DIR}/src ${PROJECT_SOURCE_DIR}/linenoise-ng/include ${PROJECT_SOURCE_DIR}/mpreal)
|
2017-06-10 18:44:51 +02:00
|
|
|
|
2022-02-26 16:44:28 +01:00
|
|
|
# src
|
|
|
|
set(RPN_SRC_FILES
|
|
|
|
${PROJECT_SOURCE_DIR}/src/main.cc
|
|
|
|
${PROJECT_SOURCE_DIR}/src/object.cc
|
|
|
|
${PROJECT_SOURCE_DIR}/src/mpreal-out.cc
|
|
|
|
${PROJECT_SOURCE_DIR}/src/program.cc
|
|
|
|
${PROJECT_SOURCE_DIR}/src/lexer.cc
|
|
|
|
${PROJECT_SOURCE_DIR}/src/input.cc
|
|
|
|
${PROJECT_SOURCE_DIR}/src/rpn-branch.cc
|
|
|
|
${PROJECT_SOURCE_DIR}/src/rpn-complex.cc
|
|
|
|
${PROJECT_SOURCE_DIR}/src/rpn-general.cc
|
|
|
|
${PROJECT_SOURCE_DIR}/src/rpn-logs.cc
|
|
|
|
${PROJECT_SOURCE_DIR}/src/rpn-program.cc
|
|
|
|
${PROJECT_SOURCE_DIR}/src/rpn-real.cc
|
|
|
|
${PROJECT_SOURCE_DIR}/src/rpn-stack.cc
|
|
|
|
${PROJECT_SOURCE_DIR}/src/rpn-store.cc
|
|
|
|
${PROJECT_SOURCE_DIR}/src/rpn-string.cc
|
|
|
|
${PROJECT_SOURCE_DIR}/src/rpn-test.cc
|
|
|
|
${PROJECT_SOURCE_DIR}/src/rpn-test-framework.cc
|
|
|
|
${PROJECT_SOURCE_DIR}/src/rpn-time.cc
|
|
|
|
${PROJECT_SOURCE_DIR}/src/rpn-trig.cc)
|
|
|
|
|
|
|
|
set(LINENOISE_NG_SRC_FILES
|
|
|
|
${PROJECT_SOURCE_DIR}/linenoise-ng/src/ConvertUTF.cpp
|
|
|
|
${PROJECT_SOURCE_DIR}/linenoise-ng/src/linenoise.cpp
|
|
|
|
${PROJECT_SOURCE_DIR}/linenoise-ng/src/wcwidth.cpp)
|
|
|
|
|
|
|
|
# compiler options
|
|
|
|
set_source_files_properties(${RPN_SRC_FILES} COMPILE_FLAGS # some harder warnings
|
|
|
|
"-Wall -Wextra -pedantic -Wno-missing-field-initializers")
|
|
|
|
|
|
|
|
if(CMAKE_COMPILER_IS_GNUCXX)
|
|
|
|
message(STATUS "Compiler type GNU: ${CMAKE_CXX_COMPILER}")
|
|
|
|
# TODO still up to date?
|
|
|
|
set(BASE_COMPILER_OPTIONS "-std=c++17 -Wl,--no-as-needed")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${BASE_COMPILER_OPTIONS}")
|
|
|
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${BASE_COMPILER_OPTIONS} -O0 -g")
|
|
|
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${BASE_COMPILER_OPTIONS} -O3 -s")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
add_executable(rpn ${RPN_SRC_FILES} ${LINENOISE_NG_SRC_FILES})
|
2022-02-26 15:22:26 +01:00
|
|
|
|
2017-06-28 22:47:13 +02:00
|
|
|
target_link_libraries(rpn mpfr)
|
2022-02-22 14:28:09 +01:00
|
|
|
target_link_libraries(rpn gmp)
|
2017-06-12 22:18:39 +02:00
|
|
|
|
2017-06-10 18:44:51 +02:00
|
|
|
# install
|
|
|
|
install(TARGETS rpn DESTINATION bin)
|