2020-12-11 22:36:10 +01:00
|
|
|
cmake_minimum_required(VERSION 3.18)
|
2021-02-14 02:47:46 +01:00
|
|
|
project(Yerbacon VERSION 0.0.1 LANGUAGES "CXX")
|
2020-12-11 22:24:44 +01:00
|
|
|
|
|
|
|
set(CMAKE_CXX_STANDARD 20)
|
2020-12-11 22:36:10 +01:00
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
2021-02-26 18:51:38 +01:00
|
|
|
set(CMAKE_CXX_FLAGS "-Wall -pthread")
|
2020-12-11 22:36:10 +01:00
|
|
|
set(CMAKE_CXX_FLAGS_RELEASE "-Os")
|
2020-12-11 22:24:44 +01:00
|
|
|
|
2021-02-26 18:05:01 +01:00
|
|
|
if((${CMAKE_CXX_COMPILER_ID} STREQUAL GNU) OR (${CMAKE_CXX_COMPILER_ID} STREQUAL Clang))
|
2021-02-26 18:51:38 +01:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector -fstack-clash-protection")
|
2021-02-26 18:05:01 +01:00
|
|
|
endif()
|
|
|
|
|
2020-12-11 22:36:10 +01:00
|
|
|
if (${CMAKE_CXX_COMPILER_ID} STREQUAL GNU)
|
2021-03-01 12:03:25 +01:00
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc")
|
2021-02-14 12:57:42 +01:00
|
|
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fira-loop-pressure -ftree-loop-distribution -floop-interchange -ftree-vectorize -fipa-pta -s")
|
2020-12-11 22:36:10 +01:00
|
|
|
set(CMAKE_CXX_FLAGS "-flto -fno-use-linker-plugin -fwhole-program ${CMAKE_CXX_FLAGS}")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(MINGW OR MSVC)
|
|
|
|
if (UNIX)
|
|
|
|
SET(CMAKE_RC_COMPILE_OBJECT
|
|
|
|
"<CMAKE_RC_COMPILER> <FLAGS> -O coff <DEFINES> -i <SOURCE> -o <OBJECT>")
|
|
|
|
SET(CMAKE_RC_COMPILER i686-w64-mingw32-windres)
|
|
|
|
endif()
|
|
|
|
ENABLE_LANGUAGE(RC)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# CPack configuration
|
2021-02-14 12:57:42 +01:00
|
|
|
set(CPACK_STRIP_FILES TRUE)
|
2021-02-14 10:38:48 +01:00
|
|
|
set(CPACK_VERBATIM_VARIABLES TRUE)
|
2021-02-13 22:15:45 +01:00
|
|
|
string(TIMESTAMP TIME "%Y.%m+%d")
|
|
|
|
set(CPACK_PACKAGE_VERSION "${PROJECT_VERSION}-${TIME}")
|
2020-12-11 22:36:10 +01:00
|
|
|
set(CPACK_PACKAGE_VENDOR "Contributor(s)")
|
|
|
|
set(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/resources/Yerbacon.png")
|
|
|
|
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/desc.txt")
|
2021-02-15 19:14:35 +01:00
|
|
|
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Transpiler for the yerbacon language.")
|
2020-12-11 22:36:10 +01:00
|
|
|
set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
|
|
|
|
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.txt")
|
|
|
|
set(CPACK_PACKAGE_CONTACT "Username404 <w.iron.zombie@gmail.com>")
|
|
|
|
set(CPACK_PACKAGE_INSTALL_DIRECTORY "Yerbacon ${CMAKE_PROJECT_VERSION_MAJOR}.${CMAKE_PROJECT_VERSION_MINOR}")
|
2021-02-19 16:25:10 +01:00
|
|
|
set(CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${CMAKE_PROJECT_VERSION}-${TIME}")
|
2021-02-28 12:01:53 +01:00
|
|
|
set(CPACK_STRIP_FILES TRUE)
|
2020-12-11 22:36:10 +01:00
|
|
|
|
|
|
|
include_directories(${CMAKE_CURRENT_LIST_DIR})
|
|
|
|
add_executable(ybcon src/main.cpp resources/Yerbacon.rc src/parser/MainParse.cpp src/transpiler/MainTranspile.cpp src/etc/filefuncs.cpp src/etc/lexer.cpp src/headers/lex.hpp)
|
2021-02-26 20:28:53 +01:00
|
|
|
target_compile_definitions(ybcon PRIVATE YBCON_VERSION="${PROJECT_VERSION}")
|
2020-12-11 22:36:10 +01:00
|
|
|
|
|
|
|
# lpkg = linux package, wpkg = windows package
|
|
|
|
if (UNIX AND NOT MINGW)
|
2021-02-25 22:02:27 +01:00
|
|
|
include(GNUInstallDirs)
|
2021-02-25 17:57:49 +01:00
|
|
|
set(CPACK_PACKAGING_INSTALL_PREFIX "/opt")
|
2020-12-11 22:36:10 +01:00
|
|
|
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}_lpkg")
|
2021-02-14 14:17:16 +01:00
|
|
|
set(CPACK_SYSTEM_NAME "Linux-${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}")
|
|
|
|
set(CPACK_TOPLEVEL_TAG "Linux-${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}")
|
2021-02-25 17:57:49 +01:00
|
|
|
set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_SOURCE_DIR}/scripts/postinst.sh")
|
|
|
|
set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE ${CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA})
|
2021-03-01 12:18:56 +01:00
|
|
|
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.14), libstdc++6 (>= 9)")
|
2021-02-27 14:42:05 +01:00
|
|
|
set(CPACK_DEBIAN_COMPRESSION_TYPE lzma)
|
2021-02-27 14:40:52 +01:00
|
|
|
set(CPACK_RPM_COMPRESSION_TYPE lzma)
|
2021-02-13 22:36:04 +01:00
|
|
|
set(CPACK_RPM_PACKAGE_AUTOREQ YES)
|
2021-02-14 10:21:54 +01:00
|
|
|
set(CPACK_RPM_PACKAGE_LICENSE "MPL-2.0")
|
|
|
|
set(CPACK_RPM_PACKAGE_VERSION ${PROJECT_VERSION})
|
|
|
|
set(CPACK_RPM_PACKAGE_RELEASE ${TIME})
|
2021-02-27 12:07:07 +01:00
|
|
|
set(CPACK_RPM_PACKAGE_RELEASE_DIST ON)
|
2021-02-14 13:54:14 +01:00
|
|
|
if (NOT DEFINED CPACK_GENERATOR)
|
2021-02-25 18:55:40 +01:00
|
|
|
set(CPACK_GENERATOR TGZ;STGZ;RPM;DEB)
|
2021-02-14 13:54:14 +01:00
|
|
|
endif()
|
2021-02-28 19:30:52 +01:00
|
|
|
install(PROGRAMS
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/ybcon
|
2021-02-26 14:22:12 +01:00
|
|
|
DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/ybcon.d)
|
2021-02-28 19:30:52 +01:00
|
|
|
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/scripts/completions DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/ybcon.d)
|
|
|
|
install(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/scripts/ybcon
|
|
|
|
DESTINATION ${CMAKE_INSTALL_BINDIR})
|
2020-12-11 22:36:10 +01:00
|
|
|
elseif(MINGW OR MSVC)
|
2021-02-28 12:37:25 +01:00
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "-static -static-libstdc++ ${CMAKE_EXE_LINKER_FLAGS}")
|
2020-12-11 22:36:10 +01:00
|
|
|
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}_wpkg")
|
|
|
|
set(CPACK_NSIS_MUI_ICON "${CMAKE_CURRENT_SOURCE_DIR}/resources/Yerbacon.ico")
|
|
|
|
set(CPACK_NSIS_MUI_UNIICON "${CMAKE_CURRENT_SOURCE_DIR}/resources/Yerbacon.ico")
|
2021-02-12 21:45:49 +01:00
|
|
|
set(CPACK_NSIS_DEFINES "RequestExecutionLevel highest")
|
2021-02-14 14:17:16 +01:00
|
|
|
set(CPACK_SYSTEM_NAME "Win32-${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}")
|
|
|
|
set(CPACK_TOPLEVEL_TAG "Win32-${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}")
|
2020-12-11 22:36:10 +01:00
|
|
|
set(CPACK_NSIS_MODIFY_PATH ON)
|
|
|
|
set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL ON)
|
|
|
|
set(CPACK_GENERATOR ZIP;NSIS)
|
|
|
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/ybcon.exe DESTINATION bin)
|
|
|
|
endif()
|
|
|
|
include(CPack)
|