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 )
2021-03-24 11:49:20 +01:00
endif ( )
2021-03-12 21:24:28 +01:00
endif ( )
2021-03-17 15:32:24 +01:00
set ( EXEDESC "Transpiler for the yerbacon language." )
2021-07-07 17:02:49 +02:00
string ( TIMESTAMP SHORT_BUILD_TIMESTAMP "%Y%m" )
string ( SUBSTRING ${ SHORT_BUILD_TIMESTAMP } 2 4 SHORT_BUILD_TIMESTAMP )
2021-07-07 16:34:35 +02:00
string ( ASCII 169 CopyrightCharacter )
2022-02-14 22:42:00 +01:00
string ( TIMESTAMP LEGAL-COPYRIGHT "Copyright ${CopyrightCharacter} 2020-%Y. Available under the MPL-2.0 license." )
2021-03-17 15:32:24 +01:00
file ( COPY "resources/${PROJECT_NAME}.ico" DESTINATION "processed" )
configure_file ( "resources/${PROJECT_NAME}.manifest" "processed/${PROJECT_NAME}.manifest" @ONLY )
2021-03-13 18:53:11 +01:00
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-24 11:47:51 +01:00
set ( CMAKE_CXX_EXTENSIONS OFF )
2021-03-29 00:20:41 +02:00
include ( CheckPIESupported )
2021-11-12 21:24:43 +01:00
check_pie_supported ( LANGUAGES CXX )
if ( CMAKE_CXX_LINK_PIE_SUPPORTED )
2021-09-12 10:37:28 +02:00
set ( CMAKE_POSITION_INDEPENDENT_CODE TRUE )
2021-11-12 21:24:43 +01:00
else ( )
message ( NOTICE "Position-Independent Code (PIC) is not supported by the current toolchain" )
2021-03-27 11:10:08 +01:00
endif ( )
2021-03-29 00:20:41 +02:00
set ( CMAKE_CXX_FLAGS "-Wall" )
2021-09-18 22:51:04 +02:00
set ( CMAKE_CXX_FLAGS_RELEASE "-Os" )
2021-08-09 17:17:38 +02:00
set ( MINIMAL_GNU "11.0" )
2022-04-03 11:45:54 +02:00
set ( MINIMAL_CLANG "14.0.1" )
2022-03-27 16:14:57 +02:00
set ( MINIMAL_MSVC "19.30" )
2022-04-14 16:33:42 +02:00
option ( IGNORE_MINIMAL_COMPILER_VERSION "Whether or not to ignore the minimal compiler versions" )
2022-07-29 12:40:47 +02:00
set ( IS_GNU ( CMAKE_CXX_COMPILER_ID STREQUAL "GNU" ) )
set ( IS_CLANG ( CMAKE_CXX_COMPILER_ID STREQUAL "Clang" ) )
2021-03-27 11:10:08 +01:00
2021-09-23 10:57:39 +02:00
option ( NO_CCACHE "Disables CCache" )
if ( NOT NO_CCACHE )
2021-08-28 23:09:34 +02:00
find_program ( CCACHE_PRESENT ccache )
2021-09-23 10:57:39 +02:00
if ( CCACHE_PRESENT )
set_property ( GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache )
set_property ( GLOBAL PROPERTY RULE_LAUNCH_LINK ccache )
endif ( )
2021-08-28 23:09:34 +02:00
endif ( )
2021-08-27 12:08:56 +02:00
2021-12-21 19:47:53 +01:00
find_package ( Threads )
2021-09-12 12:31:02 +02:00
if ( ${ IS_GNU } OR ${ IS_CLANG } )
2021-12-21 19:47:53 +01:00
set ( THREADS_PREFER_PTHREAD_FLAG TRUE )
if ( Threads_FOUND AND NOT MINGW )
2022-06-11 16:11:56 +02:00
if ( NOT ( "${CMAKE_EXE_LINKER_FLAGS}" MATCHES -static ) )
2022-06-10 20:02:07 +02:00
include ( FindOpenMP )
if ( OpenMP_CXX_FOUND )
set ( CMAKE_CXX_FLAGS "${OpenMP_CXX_FLAGS} ${CMAKE_CXX_FLAGS}" )
add_definitions ( -D_GLIBCXX_PARALLEL )
endif ( )
2021-09-12 12:31:02 +02:00
endif ( )
endif ( )
2022-04-09 00:15:35 +02:00
if ( NOT DEFINED EMSCRIPTEN )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector-strong -fstack-clash-protection" )
2022-04-12 18:51:26 +02:00
else ( )
2022-07-25 12:33:54 +02:00
set ( CMAKE_EXE_LINKER_FLAGS "--closure 1 -sWASM=0 --memory-init-file 0 -sEXPORTED_FUNCTIONS=_main -sEXIT_RUNTIME=1 -sSINGLE_FILE=1 -sSAFE_HEAP=1 -sABORTING_MALLOC=0 -sJS_MATH=1 -sENVIRONMENT='web,webview,worker,node,shell' -sNODEJS_CATCH_EXIT=0 -sSTRICT=1 -sMINIMAL_RUNTIME=0 -sDISABLE_EXCEPTION_CATCHING=0 ${CMAKE_EXE_LINKER_FLAGS}" )
2022-04-12 22:18:03 +02:00
if ( CMAKE_USE_PTHREADS_INIT )
set ( CMAKE_CXX_FLAGS "-pthread ${CMAKE_CXX_FLAGS}" ) # Emscripten requires the -pthread flag
set ( CMAKE_EXE_LINKER_FLAGS "--closure-args=\" --compilation_level SIMPLE\ " -sPROXY_TO_PTHREAD=1 ${CMAKE_EXE_LINKER_FLAGS}" ) # See https://github.com/emscripten-core/emscripten/issues/16706
endif ( )
2022-04-09 00:15:35 +02:00
endif ( )
2022-08-03 11:37:33 +02:00
set ( CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -s" )
2022-04-09 00:15:35 +02:00
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstrict-enums -pipe -funwind-tables -fasynchronous-unwind-tables -frtti -fexceptions" )
2022-08-03 11:37:33 +02:00
set ( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -ffunction-sections -fdata-sections -fmerge-all-constants -ftree-vectorize -fno-math-errno" )
2021-03-20 21:20:21 +01:00
include ( CheckCXXCompilerFlag )
2021-08-22 17:03:53 +02:00
set ( CF_PROTECTION "-fcf-protection" )
2021-11-09 20:27:59 +01:00
check_cxx_compiler_flag ( "${CF_PROTECTION}" CF_PROTECTION_SUPPORTED )
2021-03-24 11:40:33 +01:00
if ( CF_PROTECTION_SUPPORTED )
2021-08-22 17:03:53 +02:00
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CF_PROTECTION}" )
2021-03-20 21:20:21 +01:00
endif ( )
2021-02-26 18:05:01 +01:00
endif ( )
2021-09-22 15:49:07 +02:00
include ( CheckIPOSupported )
check_ipo_supported ( RESULT CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE LANGUAGES CXX )
2021-09-12 12:31:02 +02:00
if ( ${ IS_GNU } )
2022-04-14 16:33:42 +02:00
if ( CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${ MINIMAL_GNU } AND NOT ${ IGNORE_MINIMAL_COMPILER_VERSION } )
2021-08-09 17:17:38 +02:00
message ( FATAL_ERROR "G++ ${MINIMAL_GNU} or higher is required." )
2021-08-09 10:55:59 +02:00
endif ( )
2021-12-21 19:47:53 +01:00
if ( Threads_FOUND )
set ( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -ftree-parallelize-loops=2" )
endif ( )
2022-07-30 00:01:04 +02:00
set ( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fvect-cost-model=unlimited -foptimize-strlen -fsched-pressure -flive-range-shrinkage -fpredictive-commoning -ftree-partial-pre -fzero-call-used-regs=used-gpr-arg -fira-loop-pressure -ftree-loop-distribution -floop-interchange -fsplit-paths -fgcse-las -fgcse-sm -fipa-pta -fstdarg-opt -fivopts -fweb" )
2021-09-22 15:49:07 +02:00
if ( ${ CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE } )
2022-05-14 16:22:58 +02:00
set ( CMAKE_CXX_FLAGS_RELEASE "-fwhole-program -flto-partition=none ${CMAKE_CXX_FLAGS_RELEASE}" )
2021-09-22 15:49:07 +02:00
endif ( )
2021-09-12 12:31:02 +02:00
elseif ( ${ IS_CLANG } )
2022-04-14 16:33:42 +02:00
if ( CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${ MINIMAL_CLANG } AND NOT ${ IGNORE_MINIMAL_COMPILER_VERSION } )
2021-08-09 17:17:38 +02:00
message ( FATAL_ERROR "Clang ${MINIMAL_CLANG} or higher is required." )
2021-08-09 10:55:59 +02:00
endif ( )
2021-11-12 21:18:11 +01:00
if ( ${ CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE } OR MINGW ) # CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE is false on llvm-mingw toolchains even though it is supported
2022-04-09 00:15:35 +02:00
set ( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -flto=full" )
if ( NOT DEFINED EMSCRIPTEN )
set ( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fwhole-program-vtables" )
endif ( )
2021-11-12 21:18:11 +01:00
endif ( )
2022-05-18 18:56:54 +02:00
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unknown-warning-option -Wno-unqualified-std-cast-call -Wno-reinterpret-base-class" )
2021-11-12 21:18:11 +01:00
set ( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fstrict-vtable-pointers" )
2021-12-15 16:29:52 +01:00
elseif ( MSVC )
2022-04-14 16:33:42 +02:00
if ( CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${ MINIMAL_MSVC } AND NOT ${ IGNORE_MINIMAL_COMPILER_VERSION } )
2022-01-08 13:14:33 +01:00
message ( FATAL_ERROR "MSVC ${MINIMAL_MSVC} or higher is required" )
endif ( )
2022-05-20 17:14:09 +02:00
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /permissive- /Zc:twoPhase- /EHsc /GR /W3 /Zc:__cplusplus /Zc:preprocessor /Zc:throwingNew /Zc:inline" )
2021-12-16 13:06:01 +01:00
set ( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MANIFEST:NO" )
2020-12-11 22:36:10 +01:00
endif ( )
2021-12-15 13:20:46 +01:00
string ( TOUPPER "${CMAKE_BUILD_TYPE}" UPPERCASE_BUILD_TYPE )
2022-07-29 12:40:47 +02:00
if ( UPPERCASE_BUILD_TYPE STREQUAL "RELEASE" )
2021-10-20 19:16:45 +02:00
add_definitions ( -DYBCON_FLAGS= "${CMAKE_CXX_FLAGS_RELEASE}" )
endif ( )
add_definitions ( -DYBCON_COMPILER= "${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}" )
2020-12-11 22:36:10 +01:00
2021-03-25 19:16:38 +01:00
if ( MINGW OR MSVC )
2020-12-11 22:36:10 +01:00
if ( UNIX )
SET ( CMAKE_RC_COMPILE_OBJECT
" < C M A K E _ R C _ C O M P I L E R > < F L A G S > - O c o f f < D E F I N E S > - i < S O U R C E > - o < O B J E C T > " )
2021-08-10 12:22:28 +02:00
if ( NOT DEFINED CMAKE_RC_COMPILER )
SET ( CMAKE_RC_COMPILER i686-w64-mingw32-windres )
endif ( )
2020-12-11 22:36:10 +01:00
endif ( )
ENABLE_LANGUAGE ( RC )
endif ( )
# CPack configuration
2021-03-25 13:36:42 +01:00
set ( CPACK_THREADS 0 ) # Used by CMake 3.20+
set ( CPACK_ARCHIVE_THREADS ${ CPACK_THREADS } )
2022-06-18 14:45:53 +02: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)" )
2022-06-23 22:49:06 +02:00
set ( CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/resources/${PROJECT_NAME}.png" )
2021-03-12 21:24:28 +01:00
set ( CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/misc/desc.txt" )
2021-03-17 15:32:24 +01:00
set ( CPACK_PACKAGE_DESCRIPTION_SUMMARY "${EXEDESC}" )
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>" )
2022-06-23 22:49:06 +02:00
set ( CPACK_PACKAGE_INSTALL_DIRECTORY "${PROJECT_NAME} ${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}" )
2020-12-11 22:36:10 +01:00
include_directories ( ${ CMAKE_CURRENT_LIST_DIR } )
2022-07-06 15:35:16 +02:00
add_executable ( ${ EXENAME } src/main.cpp ${ CMAKE_CURRENT_BINARY_DIR } /processed/ ${ PROJECT_NAME } .rc src/etc/filefuncs.cpp src/etc/lexer.cpp src/headers/lex.hpp src/headers/misc.hpp src/headers/parsing/ParseComponents.hpp src/headers/transpiler/Target.hpp src/headers/transpiler/implementations/Lua.hpp src/headers/transpiler/implementations/Js.hpp src/headers/transpiler/implementations/Py.hpp src/headers/parsing/Parser.hpp src/headers/arguments.hpp src/headers/parsing/ReservedIdentifiers.hpp )
2021-12-21 19:47:53 +01:00
target_compile_definitions ( ${ EXENAME } PRIVATE YBCON_VERSION= "${CODENAME} ${PROJECT_VERSION}" )
2021-09-23 11:31:54 +02:00
target_precompile_headers ( ${ EXENAME } PRIVATE src/headers/Yerbacon.hpp )
2021-12-21 19:47:53 +01:00
if ( Threads_FOUND )
target_link_libraries ( ${ EXENAME } PRIVATE Threads::Threads )
endif ( )
2020-12-11 22:36:10 +01:00
2022-06-11 16:11:06 +02:00
option ( NO_SELF_PACKER "Disables usage of a self-packer" )
2022-07-29 12:47:07 +02:00
if ( NOT ( UPPERCASE_BUILD_TYPE STREQUAL "DEBUG" OR UPPERCASE_BUILD_TYPE STREQUAL "RELWITHDEBINFO" OR NO_SELF_PACKER OR DEFINED EMSCRIPTEN OR MINGW ) )
2022-06-11 16:11:06 +02:00
include ( FindSelfPackers )
2022-08-02 18:36:14 +02:00
if ( SELF_PACKER_FOR_EXECUTABLE MATCHES upx ) # UPX version d61edc9 or higher is required when using a cross-compiler to target the musl C library
2022-06-11 16:26:44 +02:00
set ( SELF_PACKER_FOR_EXECUTABLE_FLAGS ${ SELF_PACKER_FOR_EXECUTABLE_FLAGS } --ultra-brute --best )
2022-06-11 16:11:06 +02:00
endif ( )
2022-07-29 12:22:29 +02:00
if ( NOT SELF_PACKER_FOR_EXECUTABLE STREQUAL "SELF_PACKER_FOR_EXECUTABLE-NOTFOUND" )
2022-06-11 16:11:06 +02:00
add_custom_command ( TARGET ${ EXENAME } POST_BUILD COMMAND "${SELF_PACKER_FOR_EXECUTABLE}" ${ SELF_PACKER_FOR_EXECUTABLE_FLAGS } $< TARGET_FILE:${EXENAME} > VERBATIM )
endif ( )
endif ( )
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 } )
2021-12-14 13:31:24 +01:00
if ( UNIX AND NOT ( MINGW OR CMAKE_HOST_WIN32 ) )
2021-02-25 22:02:27 +01:00
include ( GNUInstallDirs )
2021-03-24 13:18:17 +01:00
set ( CMAKE_INSTALL_PREFIX "/usr" )
2021-03-11 20:20:51 +01:00
set ( CPACK_PACKAGING_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}" )
2021-03-12 22:16:11 +01:00
set ( CPACK_PACKAGE_FILE_NAME "${PNAME}_lpkg" )
2021-03-18 14:39:26 +01:00
set ( CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION TRUE )
2021-03-24 13:18:17 +01:00
configure_file ( "${CMAKE_CURRENT_SOURCE_DIR}/scripts/postinst" "processed/postinst" @ONLY )
2022-07-30 00:01:04 +02:00
set ( CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/processed/postinst" )
2021-03-24 13:18:17 +01:00
set ( CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA ${ CPACK_RPM_POST_INSTALL_SCRIPT_FILE } )
2021-08-18 12:57:00 +02:00
set ( CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON )
2021-03-24 14:06:55 +01:00
set ( CPACK_DEBIAN_COMPRESSION_TYPE xz )
2021-03-25 13:43:32 +01:00
set ( CPACK_RPM_COMPRESSION_TYPE ${ CPACK_DEBIAN_COMPRESSION_TYPE } )
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-24 12:55:38 +01:00
set ( CPACK_RPM_CHANGELOG_FILE "${CMAKE_CURRENT_SOURCE_DIR}/changelog" )
2021-08-18 23:40:32 +02:00
if ( CMAKE_VERSION STREQUAL "3.21.1" )
2021-11-21 13:24:55 +01:00
message ( WARNING "CPack ${CMAKE_VERSION} has a bug which causes rpm scripts to be unusable; please update or downgrade" )
2021-08-18 23:40:32 +02:00
endif ( )
2021-03-24 15:50:29 +01:00
if ( NOT APPLE )
2021-03-25 14:28:03 +01:00
set ( GZNAME "changelog.Debian.gz" )
2021-03-24 15:50:29 +01:00
add_custom_command (
2021-03-25 14:28:03 +01:00
O U T P U T " $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / $ { G Z N A M E } "
2021-03-25 16:18:00 +01:00
C O M M A N D g z i p - c - k - n - 9 " $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / c h a n g e l o g " > $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / $ { G Z N A M E }
2021-03-24 15:50:29 +01:00
W O R K I N G _ D I R E C T O R Y " $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } "
D E P E N D S " $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / c h a n g e l o g "
C O M M E N T " C o m p r e s s i n g t h e c h a n g e l o g f i l e "
)
2021-03-25 14:28:03 +01:00
add_custom_target ( changelog ALL DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${GZNAME}" )
2021-12-21 19:47:53 +01:00
add_dependencies ( ${ EXENAME } changelog )
2021-03-24 15:50:29 +01:00
string ( TOLOWER "${CMAKE_INSTALL_DOCDIR}" DEB_CHANGELOG_DEST_DIR ) # Lowercase characters are needed because GNUInstallDirs uses the PROJECT_NAME variable.
install (
2021-03-25 14:28:03 +01:00
F I L E S " $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / $ { G Z N A M E } "
2021-03-24 15:50:29 +01:00
D E S T I N A T I O N $ { D E B _ C H A N G E L O G _ D E S T _ D I R }
)
endif ( )
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 )
2021-08-09 17:17:38 +02:00
set ( CPACK_RPM_BUILDREQUIRES "cmake >= ${CMAKE_MINIMUM_REQUIRED_VERSION}, clang >= ${MINIMAL_CLANG}.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-24 12:55:38 +01:00
install ( FILES CMakeLists.txt misc/desc.txt LICENSE.txt README.md changelog 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
2021-12-21 19:47:53 +01:00
$ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / $ { E X E N A M E }
2021-03-03 13:24:16 +01:00
D E S T I N A T I O N $ { C M A K E _ I N S T A L L _ L I B E X E C D I R } )
2021-12-21 19:47:53 +01:00
install ( DIRECTORY ${ CMAKE_CURRENT_SOURCE_DIR } /scripts/completions DESTINATION ${ CMAKE_INSTALL_DATAROOTDIR } / ${ EXENAME } .d )
install ( PROGRAMS ${ CMAKE_CURRENT_SOURCE_DIR } /scripts/ ${ EXENAME }
2021-03-24 13:18:17 +01:00
D E S T I N A T I O N $ { C M A K E _ I N S T A L L _ B I N D I R } )
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-04-02 13:53:55 +02:00
set ( CPACK_PACKAGE_INSTALL_DIRECTORY ${ CODENAME } )
2021-03-13 19:47:35 +01:00
set ( CPACK_NSIS_INSTALL_ROOT "${CMAKE_INSTALL_PREFIX}" )
2021-08-18 20:32:56 +02:00
if ( MINGW )
2022-05-14 16:54:23 +02:00
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-command-line-argument" )
2021-08-18 20:32:56 +02:00
set ( CMAKE_EXE_LINKER_FLAGS "-static -static-libstdc++ -static-libgcc ${CMAKE_EXE_LINKER_FLAGS}" )
endif ( )
2021-03-12 22:16:11 +01:00
set ( CPACK_PACKAGE_FILE_NAME "${PNAME}_wpkg" )
2021-04-02 12:53:52 +02:00
set ( CPACK_NSIS_COMPRESSOR "/SOLID lzma" )
2021-09-18 18:09:04 +02:00
set ( CPACK_NSIS_MANIFEST_DPI_AWARE TRUE )
2021-04-02 13:35:16 +02:00
set ( CPACK_NSIS_PACKAGE_NAME "${PROJECT_NAME} ${CODENAME}-${PROJECT_VERSION}" )
set ( CPACK_NSIS_WELCOME_TITLE_3LINES ON )
2022-06-23 22:49:06 +02:00
set ( CPACK_NSIS_URL_INFO_ABOUT "https://gits.username404.fr/Username404-59/${PROJECT_NAME}" )
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-09-19 21:37:53 +02:00
set ( CPACK_SYSTEM_NAME "Win32" )
set ( CPACK_TOPLEVEL_TAG "Win32" )
2020-12-11 22:36:10 +01:00
set ( CPACK_NSIS_MODIFY_PATH ON )
set ( CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL ON )
2021-12-03 16:54:23 +01:00
if ( CMAKE_HOST_WIN32 )
2021-09-18 18:29:53 +02:00
# The two following variables require CMake 3.20 or higher
2022-06-23 22:49:06 +02:00
set ( CPACK_NSIS_BRANDING_TEXT "NSIS Installer for ${PROJECT_NAME}" )
2021-09-18 18:29:53 +02:00
set ( CPACK_NSIS_BRANDING_TEXT_TRIM_POSITION CENTER )
endif ( )
2021-10-19 22:07:55 +02:00
# CMake 3.22+ is required to ignore the NSIS license page
set ( CPACK_NSIS_IGNORE_LICENSE_PAGE TRUE )
2021-03-10 18:00:50 +01:00
set ( CPACK_GENERATOR ZIP;NSIS )
2021-12-21 19:47:53 +01:00
install ( FILES ${ CMAKE_CURRENT_BINARY_DIR } / ${ EXENAME } .exe DESTINATION bin )
2020-12-11 22:36:10 +01:00
endif ( )
2021-08-15 16:43:35 +02:00
if ( NOT DEFINED CXX_TARGET )
set ( CXX_TARGET ${ CMAKE_HOST_SYSTEM_PROCESSOR } )
endif ( )
2021-08-15 17:17:11 +02:00
set ( CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}.${CXX_TARGET}" )
2020-12-11 22:36:10 +01:00
include ( CPack )