cmake_minimum_required(VERSION 3.18) project(Yerbacon VERSION 0.0.1 LANGUAGES "CXX") set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_FLAGS "-pthread") set(CMAKE_CXX_FLAGS_RELEASE "-Os") if (${CMAKE_CXX_COMPILER_ID} STREQUAL GNU) set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fira-loop-pressure -ftree-loop-distribution -floop-interchange -ftree-vectorize -fipa-pta -s") 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 " -O coff -i -o ") SET(CMAKE_RC_COMPILER i686-w64-mingw32-windres) endif() ENABLE_LANGUAGE(RC) endif() # CPack configuration set(CPACK_STRIP_FILES TRUE) set(CPACK_VERBATIM_VARIABLES TRUE) string(TIMESTAMP TIME "%Y.%m+%d") set(CPACK_PACKAGE_VERSION "${PROJECT_VERSION}-${TIME}") 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") set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Transpiler for the yerbacon language.") 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 ") set(CPACK_PACKAGE_INSTALL_DIRECTORY "Yerbacon ${CMAKE_PROJECT_VERSION_MAJOR}.${CMAKE_PROJECT_VERSION_MINOR}") set(CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${CMAKE_PROJECT_VERSION}-${TIME}") 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) # lpkg = linux package, wpkg = windows package if (UNIX AND NOT MINGW) set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}_lpkg") set(CPACK_SYSTEM_NAME "Linux-${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}") set(CPACK_TOPLEVEL_TAG "Linux-${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}") set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON) set(CPACK_RPM_PACKAGE_AUTOREQ YES) set(CPACK_RPM_PACKAGE_LICENSE "MPL-2.0") set(CPACK_RPM_PACKAGE_VERSION ${PROJECT_VERSION}) set(CPACK_RPM_PACKAGE_RELEASE ${TIME}) if (NOT DEFINED CPACK_GENERATOR) set(CPACK_GENERATOR TGZ;STGZ;DEB;RPM) endif() install(FILES ${CMAKE_CURRENT_BINARY_DIR}/ybcon PERMISSIONS OWNER_WRITE OWNER_EXECUTE OWNER_READ WORLD_READ WORLD_EXECUTE DESTINATION bin) elseif(MINGW OR MSVC) set(CMAKE_EXE_LINKER_FLAGS "-static -static-libstdc++ -static-libgcc") 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") set(CPACK_NSIS_DEFINES "RequestExecutionLevel highest") set(CPACK_SYSTEM_NAME "Win32-${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}") set(CPACK_TOPLEVEL_TAG "Win32-${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}") 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)