mirror of
https://github.com/louisrubet/rpn
synced 2024-11-17 07:47:50 +01:00
95 lines
3.9 KiB
CMake
95 lines
3.9 KiB
CMake
# -*- mode: CMAKE; -*-
|
|
|
|
cmake_minimum_required(VERSION 2.6)
|
|
|
|
project(linenoise)
|
|
|
|
set(CMAKE_BINARY_DIR "${CMAKE_SOURCE_DIR}/build")
|
|
|
|
if(NOT CMAKE_BUILD_TYPE)
|
|
set(CMAKE_BUILD_TYPE Release CACHE string "Choose the type of build, options are: None Debug Release" FORCE)
|
|
endif()
|
|
|
|
message(STATUS "Build mode: ${CMAKE_BUILD_TYPE}")
|
|
|
|
# INFO
|
|
set(RPN_VERSION "2.1" CACHE path "rpn version")
|
|
set(RPN_DISPLAY_NAME "rpn")
|
|
set(RPN_URL_INFO_ABOUT "https://github.com/louisrubet/rpn")
|
|
set(RPN_CONTACT "louis@rubet.fr")
|
|
set(RPN_FRIENDLY_STRING "rpn - Reverse Polish Notation language")
|
|
|
|
# compiler options
|
|
if(CMAKE_COMPILER_IS_GNUCXX)
|
|
message(STATUS "Compiler type GNU: ${CMAKE_CXX_COMPILER}")
|
|
set(BASE_COMPILER_OPTIONS "-Wl,--no-as-needed -lreadline -lmpfr")
|
|
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_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} ${BASE_COMPILER_OPTIONS} -Os")
|
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${BASE_COMPILER_OPTIONS} -O3 -fomit-frame-pointer")
|
|
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} ${BASE_COMPILER_OPTIONS} -O3 -g")
|
|
|
|
#elseif(MSVC)
|
|
# message(STATUS "Compiler type MSVC: ${CMAKE_CXX_COMPILER}")
|
|
# add_definitions("-D_CRT_SECURE_NO_WARNINGS=1")
|
|
#
|
|
# foreach (flag_var
|
|
# CMAKE_CXX_FLAGS
|
|
# CMAKE_CXX_FLAGS_DEBUG
|
|
# CMAKE_CXX_FLAGS_RELEASE
|
|
# CMAKE_CXX_FLAGS_MINSIZEREL
|
|
# CMAKE_CXX_FLAGS_RELWITHDEBINFO)
|
|
# if (flag_var MATCHES "DEBUG")
|
|
# set(${flag_var} "${${flag_var}} /MTd")
|
|
# else ()
|
|
# set(${flag_var} "${${flag_var}} /MT")
|
|
# endif ()
|
|
# endforeach()
|
|
# # https://msdn.microsoft.com/en-us/library/aa267384%28VS.60%29.aspx
|
|
# set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /INCREMENTAL:NO /SUBSYSTEM:CONSOLE /LTCG /ignore:4099 /NODEFAULTLIB:libc.lib /NODEFAULTLIB:libcmt.lib /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:libcd.lib /NODEFAULTLIB:msvcrtd.lib")
|
|
# set(CMAKE_EXE_LINKER_FLAGS_MINSIZEREL "${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL} /SUBSYSTEM:CONSOLE /ignore:4099 /NODEFAULTLIB:libc.lib /NODEFAULTLIB:libcmtd.lib /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:libcd.lib /NODEFAULTLIB:msvcrtd.lib")
|
|
# set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /SUBSYSTEM:CONSOLE /ignore:4099 /NODEFAULTLIB:libc.lib /NODEFAULTLIB:libcmtd.lib /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:libcd.lib /NODEFAULTLIB:msvcrtd.lib")
|
|
# set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} /SUBSYSTEM:CONSOLE /ignore:4099 /NODEFAULTLIB:libc.lib /NODEFAULTLIB:libcmtd.lib /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:libcd.lib /NODEFAULTLIB:msvcrtd.lib")
|
|
else()
|
|
# unknown compiler
|
|
message(STATUS "Compiler type UNKNOWN: ${CMAKE_CXX_COMPILER}")
|
|
set(BASE_COMPILER_OPTIONS "-std=c++11 -Wall -Wextra")
|
|
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_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} ${BASE_COMPILER_OPTIONS} -Os")
|
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${BASE_COMPILER_OPTIONS} -O3 -fomit-frame-pointer")
|
|
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} ${BASE_COMPILER_OPTIONS} -O3 -g")
|
|
|
|
endif()
|
|
|
|
include_directories(${PROJECT_SOURCE_DIR}/src)
|
|
|
|
# build liblinenoise
|
|
add_executable(
|
|
rpn
|
|
src/main.cpp
|
|
src/object.cpp
|
|
src/program.cpp
|
|
)
|
|
|
|
# install
|
|
install(TARGETS rpn DESTINATION bin)
|
|
|
|
# packaging
|
|
include(CPack)
|
|
|
|
if (MSVC)
|
|
else ()
|
|
set(CPACK_SET_DESTDIR ON)
|
|
endif ()
|
|
|
|
set(CPACK_PACKAGE_VENDOR "Louis Rubet")
|
|
set(CPACK_PACKAGE_CONTACT "louis@rubet.fr")
|
|
set(CPACK_PACKAGE_VERSION "${RPN_VERSION}")
|
|
|
|
set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE")
|
|
|
|
set(CPACK_STRIP_FILES "ON")
|
|
|
|
set(CPACK_PACKAGE_NAME "rpn")
|
|
set(CPACK_DEBIAN_PACKAGE_SECTION "utilities")
|