2020-12-11 22:36:10 +01:00
|
|
|
cmake_minimum_required(VERSION 3.18)
|
2021-03-01 19:01:15 +01:00
|
|
|
project(Yerbacon VERSION 0.0.1 LANGUAGES C CXX)
|
2021-03-13 18:49:53 +01:00
|
|
|
set(EXENAME "ybcon")
|
2020-12-11 22:24:44 +01:00
|
|
|
|
2021-03-12 21:24:28 +01:00
|
|
|
if (NOT DEFINED CODENAME)
|
|
|
|
set(CODENAME "Unknown")
|
|
|
|
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/misc/codename.txt")
|
|
|
|
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/misc/codename.txt" CODENAME)
|
|
|
|
endif ()
|
|
|
|
endif()
|
|
|
|
|
2021-03-13 18:53:11 +01:00
|
|
|
file(COPY "resources/${PROJECT_NAME}.manifest" "resources/${PROJECT_NAME}.ico" DESTINATION "processed")
|
|
|
|
configure_file("resources/${PROJECT_NAME}.rc" "processed/${PROJECT_NAME}.rc" @ONLY)
|
2021-03-12 21:24:28 +01:00
|
|
|
|
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-03-17 14:20:39 +01:00
|
|
|
set(CXX_EXTENSIONS OFF)
|
2021-03-09 21:32:38 +01:00
|
|
|
set(CMAKE_CXX_FLAGS "-Wall")
|
|
|
|
if (NOT MSVC)
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
|
|
|
|
endif()
|
2021-03-10 14:27:24 +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-03-16 16:42:28 +01:00
|
|
|
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 11.0)
|
|
|
|
message(WARNING "A ${CMAKE_CXX_COMPILER_ID} compiler version of preferably 11 or higher should be used.")
|
|
|
|
endif()
|
2021-03-01 20:42:06 +01:00
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc")
|
2021-03-09 22:29:46 +01:00
|
|
|
set(CMAKE_CXX_FLAGS "-flto ${CMAKE_CXX_FLAGS} -fpie -pipe -fstack-protector-strong -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-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")
|
2021-03-10 14:27:24 +01:00
|
|
|
set(CMAKE_CXX_FLAGS "-fno-use-linker-plugin -fwhole-program ${CMAKE_CXX_FLAGS}")
|
2021-03-01 20:19:16 +01:00
|
|
|
elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL Clang)
|
|
|
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -ftree-vectorize")
|
2021-03-10 14:27:24 +01:00
|
|
|
set(CMAKE_CXX_FLAGS "-fwhole-program-vtables ${CMAKE_CXX_FLAGS}")
|
2020-12-11 22:36:10 +01:00
|
|
|
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")
|
2021-03-12 21:24:28 +01:00
|
|
|
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/misc/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-03-13 17:34:31 +01:00
|
|
|
set(CPACK_PACKAGE_FILE_NAME "${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})
|
2021-03-13 18:53:11 +01:00
|
|
|
add_executable(${EXENAME} src/main.cpp ${CMAKE_CURRENT_BINARY_DIR}/processed/${PROJECT_NAME}.rc src/parser/MainParse.cpp src/transpiler/MainTranspile.cpp src/etc/filefuncs.cpp src/etc/lexer.cpp src/headers/lex.hpp src/headers/misc.hpp src/headers/parsing/ParseComponents.hpp src/headers/parsing/StandardComponents.hpp)
|
2021-03-12 22:07:37 +01:00
|
|
|
target_compile_definitions(ybcon PRIVATE YBCON_VERSION="${CODENAME} ${PROJECT_VERSION}")
|
2020-12-11 22:36:10 +01:00
|
|
|
|
|
|
|
# lpkg = linux package, wpkg = windows package
|
2021-03-12 22:16:11 +01:00
|
|
|
set(PNAME ${PROJECT_NAME}-${CODENAME}-${TIME})
|
2020-12-11 22:36:10 +01:00
|
|
|
if (UNIX AND NOT MINGW)
|
2021-02-25 22:02:27 +01:00
|
|
|
include(GNUInstallDirs)
|
2021-03-11 20:20:51 +01:00
|
|
|
set(CMAKE_INSTALL_PREFIX "/opt")
|
|
|
|
set(CPACK_PACKAGING_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
|
2021-03-12 22:16:11 +01:00
|
|
|
set(CPACK_PACKAGE_FILE_NAME "${PNAME}_lpkg")
|
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")
|
2021-03-01 19:01:15 +01:00
|
|
|
set(CPACK_RPM_CHANGELOG_FILE "${CMAKE_CURRENT_SOURCE_DIR}/changelog.txt")
|
2021-02-14 10:21:54 +01:00
|
|
|
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-03-01 19:01:15 +01:00
|
|
|
if (CPACK_RPM_PACKAGE_SOURCES)
|
2021-03-01 19:28:17 +01:00
|
|
|
set(CPACK_RPM_SOURCE_PKG_PACKAGING_INSTALL_PREFIX "/")
|
2021-03-01 19:01:15 +01:00
|
|
|
set(CPACK_GENERATOR RPM)
|
|
|
|
set(CPACK_RPM_BUILDREQUIRES "cmake >= 3.18, clang >= 11.0.0")
|
2021-03-01 19:28:17 +01:00
|
|
|
install(DIRECTORY src DESTINATION ${CPACK_RPM_SOURCE_PKG_PACKAGING_INSTALL_PREFIX})
|
|
|
|
install(DIRECTORY resources DESTINATION ${CPACK_RPM_SOURCE_PKG_PACKAGING_INSTALL_PREFIX})
|
|
|
|
install(DIRECTORY scripts DESTINATION ${CPACK_RPM_SOURCE_PKG_PACKAGING_INSTALL_PREFIX})
|
2021-03-12 21:24:28 +01:00
|
|
|
install(FILES CMakeLists.txt misc/desc.txt LICENSE.txt README.md changelog.txt DESTINATION ${CPACK_RPM_SOURCE_PKG_PACKAGING_INSTALL_PREFIX})
|
2021-03-01 19:28:17 +01:00
|
|
|
else()
|
|
|
|
if (NOT DEFINED CPACK_GENERATOR)
|
2021-03-10 20:20:52 +01:00
|
|
|
set(CPACK_GENERATOR TGZ;STGZ;RPM;DEB)
|
2021-03-01 19:28:17 +01:00
|
|
|
endif()
|
|
|
|
install(PROGRAMS
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/ybcon
|
2021-03-03 13:24:16 +01:00
|
|
|
DESTINATION ${CMAKE_INSTALL_LIBEXECDIR})
|
|
|
|
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/scripts/completions DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/ybcon.d)
|
2021-03-01 19:28:17 +01:00
|
|
|
install(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/scripts/ybcon
|
2021-03-03 13:24:16 +01:00
|
|
|
DESTINATION yerbacon/${CMAKE_INSTALL_BINDIR})
|
2021-03-01 19:01:15 +01:00
|
|
|
endif()
|
2020-12-11 22:36:10 +01:00
|
|
|
elseif(MINGW OR MSVC)
|
2021-03-17 14:01:14 +01:00
|
|
|
set(CMAKE_INSTALL_PREFIX "C:\\progs\\${PROJECT_NAME}")
|
2021-03-13 19:47:35 +01:00
|
|
|
set(CPACK_NSIS_INSTALL_ROOT "${CMAKE_INSTALL_PREFIX}")
|
2021-02-28 12:37:25 +01:00
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "-static -static-libstdc++ ${CMAKE_EXE_LINKER_FLAGS}")
|
2021-03-12 22:16:11 +01:00
|
|
|
set(CPACK_PACKAGE_FILE_NAME "${PNAME}_wpkg")
|
2021-03-13 18:53:11 +01:00
|
|
|
set(CPACK_NSIS_MUI_ICON "${CMAKE_CURRENT_SOURCE_DIR}/resources/${PROJECT_NAME}.ico")
|
|
|
|
set(CPACK_NSIS_MUI_UNIICON "${CMAKE_CURRENT_SOURCE_DIR}/resources/${PROJECT_NAME}.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)
|
2021-03-10 18:00:50 +01:00
|
|
|
set(CPACK_GENERATOR ZIP;NSIS)
|
2020-12-11 22:36:10 +01:00
|
|
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/ybcon.exe DESTINATION bin)
|
|
|
|
endif()
|
|
|
|
include(CPack)
|