diff --git a/.gitignore b/.gitignore index 608b26f..1d3ed44 100644 --- a/.gitignore +++ b/.gitignore @@ -44,3 +44,76 @@ moonloader/lib/cheat-menu/json/config.json .vs/CheatMenu/v14/.suo ipch/CHEATMENU.VCXPROJ-daebb660/CHEATMENU-7e055069.ipch /ipch/CHEATMENU.VCXPROJ-daebb660/CHEATMENU-ac659b63.ipch +src/Ui.cpp +build/ALL_BUILD.vcxproj +build/ALL_BUILD.vcxproj.filters +build/CheatMenu.sln +build/cmake_install.cmake +build/CMakeCache.txt +build/ZERO_CHECK.vcxproj +build/ZERO_CHECK.vcxproj.filters +build/.cmake/api/v1/query/client-vscode/query.json +build/.cmake/api/v1/reply/cache-v2-621aa407f5a32d3094b6.json +build/.cmake/api/v1/reply/codemodel-v2-f7a5fa81fc81cd5e6d7f.json +build/.cmake/api/v1/reply/index-2020-12-16T22-01-22-0127.json +build/.cmake/api/v1/reply/target-ALL_BUILD-Debug-0d71923192ceb632dd4b.json +build/.cmake/api/v1/reply/target-ALL_BUILD-MinSizeRel-0d71923192ceb632dd4b.json +build/.cmake/api/v1/reply/target-ALL_BUILD-Release-0d71923192ceb632dd4b.json +build/.cmake/api/v1/reply/target-ALL_BUILD-RelWithDebInfo-0d71923192ceb632dd4b.json +build/.cmake/api/v1/reply/target-CheatMenu-Debug-7e8119111674b77129ba.json +build/.cmake/api/v1/reply/target-CheatMenu-MinSizeRel-b7352a84e5d23dc87a42.json +build/.cmake/api/v1/reply/target-CheatMenu-Release-e42c8f83e0380e371175.json +build/.cmake/api/v1/reply/target-CheatMenu-RelWithDebInfo-b44b3bfba044c30f6aee.json +build/.cmake/api/v1/reply/target-ZERO_CHECK-Debug-faba1ce8496925e096bf.json +build/.cmake/api/v1/reply/target-ZERO_CHECK-MinSizeRel-faba1ce8496925e096bf.json +build/.cmake/api/v1/reply/target-ZERO_CHECK-Release-faba1ce8496925e096bf.json +build/.cmake/api/v1/reply/target-ZERO_CHECK-RelWithDebInfo-faba1ce8496925e096bf.json +build/CMakeFiles/cmake.check_cache +build/CMakeFiles/CMakeOutput.log +build/CMakeFiles/feature_tests.bin +build/CMakeFiles/feature_tests.cxx +build/CMakeFiles/generate.stamp +build/CMakeFiles/generate.stamp.depend +build/CMakeFiles/generate.stamp.list +build/CMakeFiles/TargetDirectories.txt +build/CMakeFiles/3.19.1/CMakeCXXCompiler.cmake +build/CMakeFiles/3.19.1/CMakeDetermineCompilerABI_CXX.bin +build/CMakeFiles/3.19.1/CMakeRCCompiler.cmake +build/CMakeFiles/3.19.1/CMakeSystem.cmake +build/CMakeFiles/3.19.1/VCTargetsPath.txt +build/CMakeFiles/3.19.1/VCTargetsPath.vcxproj +build/CMakeFiles/3.19.1/CompilerIdCXX/CMakeCXXCompilerId.cpp +build/CMakeFiles/3.19.1/CompilerIdCXX/CompilerIdCXX.vcxproj +build/CMakeFiles/3.19.1/CompilerIdCXX/Debug/CompilerIdCXX.tlog/CL.command.1.tlog +build/CMakeFiles/3.19.1/CompilerIdCXX/Debug/CompilerIdCXX.tlog/CL.read.1.tlog +build/CMakeFiles/3.19.1/CompilerIdCXX/Debug/CompilerIdCXX.tlog/CL.write.1.tlog +build/CMakeFiles/3.19.1/CompilerIdCXX/Debug/CompilerIdCXX.tlog/CompilerIdCXX.lastbuildstate +build/CMakeFiles/3.19.1/CompilerIdCXX/Debug/CompilerIdCXX.tlog/link.command.1.tlog +build/CMakeFiles/3.19.1/CompilerIdCXX/Debug/CompilerIdCXX.tlog/link.read.1.tlog +build/CMakeFiles/3.19.1/CompilerIdCXX/Debug/CompilerIdCXX.tlog/link.write.1.tlog +build/CMakeFiles/3.19.1/Debug/VCTargetsPath.tlog/VCTargetsPath.lastbuildstate +build/CMakeFiles/a5324de20c91732f057c48e8dcb5bab6/generate.stamp.rule +build/src/CheatMenu.vcxproj +build/src/CheatMenu.vcxproj.filters +build/src/cmake_install.cmake +build/src/CMakeFiles/generate.stamp +build/src/CMakeFiles/generate.stamp.depend +build/src/CheatMenu.dir/Debug/vc140.pdb +build/src/CheatMenu.dir/Debug/CheatMenu.tlog/CheatMenu.lastbuildstate +build/src/CheatMenu.dir/Debug/CheatMenu.tlog/CL.command.1.tlog +build/src/CheatMenu.dir/Debug/CheatMenu.tlog/CL.read.1.tlog +build/src/CheatMenu.dir/Debug/CheatMenu.tlog/CL.write.1.tlog +build/src/CheatMenu.dir/Debug/CheatMenu.tlog/custombuild.command.1.tlog +build/src/CheatMenu.dir/Debug/CheatMenu.tlog/custombuild.read.1.tlog +build/src/CheatMenu.dir/Debug/CheatMenu.tlog/custombuild.write.1.tlog +build/src/CheatMenu.dir/Debug/CheatMenu.tlog/link.command.1.tlog +build/src/CheatMenu.dir/Debug/CheatMenu.tlog/link.read.1.tlog +build/src/CheatMenu.dir/Debug/CheatMenu.tlog/link.write.1.tlog +build/win32/Debug/ALL_BUILD/ALL_BUILD.tlog/ALL_BUILD.lastbuildstate +build/win32/Debug/ALL_BUILD/ALL_BUILD.tlog/custombuild.command.1.tlog +build/win32/Debug/ALL_BUILD/ALL_BUILD.tlog/custombuild.read.1.tlog +build/win32/Debug/ALL_BUILD/ALL_BUILD.tlog/custombuild.write.1.tlog +build/win32/Debug/ZERO_CHECK/ZERO_CHECK.tlog/custombuild.command.1.tlog +build/win32/Debug/ZERO_CHECK/ZERO_CHECK.tlog/custombuild.read.1.tlog +build/win32/Debug/ZERO_CHECK/ZERO_CHECK.tlog/custombuild.write.1.tlog +build/win32/Debug/ZERO_CHECK/ZERO_CHECK.tlog/ZERO_CHECK.lastbuildstate diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..395950b --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,274 @@ +cmake_minimum_required(VERSION 3.16 FATAL_ERROR) +project(CheatMenu CXX) +set(PROJECT_NAME CheatMenu) + +################################################################################ +# This contains the utility functions needed for sub project, src/CMakeLists.txt +# Need to clean things up later, maybe switch to original cmake alternatives +# CMake-Converter https://github.com/pavelliavonau/cmakeconverter +################################################################################ + +################################################################################ +# Wrap each token of the command with condition +################################################################################ +cmake_policy(PUSH) +cmake_policy(SET CMP0054 NEW) +macro(prepare_commands) + unset(TOKEN_ROLE) + unset(COMMANDS) + foreach(TOKEN ${ARG_COMMANDS}) + if("${TOKEN}" STREQUAL "COMMAND") + set(TOKEN_ROLE "KEYWORD") + elseif("${TOKEN_ROLE}" STREQUAL "KEYWORD") + set(TOKEN_ROLE "CONDITION") + elseif("${TOKEN_ROLE}" STREQUAL "CONDITION") + set(TOKEN_ROLE "COMMAND") + elseif("${TOKEN_ROLE}" STREQUAL "COMMAND") + set(TOKEN_ROLE "ARG") + endif() + + if("${TOKEN_ROLE}" STREQUAL "KEYWORD") + list(APPEND COMMANDS "${TOKEN}") + elseif("${TOKEN_ROLE}" STREQUAL "CONDITION") + set(CONDITION ${TOKEN}) + elseif("${TOKEN_ROLE}" STREQUAL "COMMAND") + list(APPEND COMMANDS "$<$:${DUMMY}>$<${CONDITION}:${TOKEN}>") + elseif("${TOKEN_ROLE}" STREQUAL "ARG") + list(APPEND COMMANDS "$<${CONDITION}:${TOKEN}>") + endif() + endforeach() +endmacro() +cmake_policy(POP) + +################################################################################ +# Transform all the tokens to absolute paths +################################################################################ +macro(prepare_output) + unset(OUTPUT) + foreach(TOKEN ${ARG_OUTPUT}) + if(IS_ABSOLUTE ${TOKEN}) + list(APPEND OUTPUT "${TOKEN}") + else() + list(APPEND OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/${TOKEN}") + endif() + endforeach() +endmacro() + +################################################################################ +# Parse add_custom_command_if args. +# +# Input: +# PRE_BUILD - Pre build event option +# PRE_LINK - Pre link event option +# POST_BUILD - Post build event option +# TARGET - Target +# OUTPUT - List of output files +# DEPENDS - List of files on which the command depends +# COMMANDS - List of commands(COMMAND condition1 commannd1 args1 COMMAND +# condition2 commannd2 args2 ...) +# Output: +# OUTPUT - Output files +# DEPENDS - Files on which the command depends +# COMMENT - Comment +# PRE_BUILD - TRUE/FALSE +# PRE_LINK - TRUE/FALSE +# POST_BUILD - TRUE/FALSE +# TARGET - Target name +# COMMANDS - Prepared commands(every token is wrapped in CONDITION) +# NAME - Unique name for custom target +# STEP - PRE_BUILD/PRE_LINK/POST_BUILD +################################################################################ +function(add_custom_command_if_parse_arguments) + cmake_parse_arguments("ARG" "PRE_BUILD;PRE_LINK;POST_BUILD" "TARGET;COMMENT" "DEPENDS;OUTPUT;COMMANDS" ${ARGN}) + + if(WIN32) + set(DUMMY "cd.") + elseif(UNIX) + set(DUMMY "true") + endif() + + prepare_commands() + prepare_output() + + set(DEPENDS "${ARG_DEPENDS}") + set(COMMENT "${ARG_COMMENT}") + set(PRE_BUILD "${ARG_PRE_BUILD}") + set(PRE_LINK "${ARG_PRE_LINK}") + set(POST_BUILD "${ARG_POST_BUILD}") + set(TARGET "${ARG_TARGET}") + if(PRE_BUILD) + set(STEP "PRE_BUILD") + elseif(PRE_LINK) + set(STEP "PRE_LINK") + elseif(POST_BUILD) + set(STEP "POST_BUILD") + endif() + set(NAME "${TARGET}_${STEP}") + + set(OUTPUT "${OUTPUT}" PARENT_SCOPE) + set(DEPENDS "${DEPENDS}" PARENT_SCOPE) + set(COMMENT "${COMMENT}" PARENT_SCOPE) + set(PRE_BUILD "${PRE_BUILD}" PARENT_SCOPE) + set(PRE_LINK "${PRE_LINK}" PARENT_SCOPE) + set(POST_BUILD "${POST_BUILD}" PARENT_SCOPE) + set(TARGET "${TARGET}" PARENT_SCOPE) + set(COMMANDS "${COMMANDS}" PARENT_SCOPE) + set(STEP "${STEP}" PARENT_SCOPE) + set(NAME "${NAME}" PARENT_SCOPE) +endfunction() + +################################################################################ +# Add conditional custom command +# +# Generating Files +# The first signature is for adding a custom command to produce an output: +# add_custom_command_if( +# +# +# +# [COMMAND condition command2 [args2...]] +# [DEPENDS [depends...]] +# [COMMENT comment] +# +# Build Events +# add_custom_command_if( +# +# +# +# [COMMAND condition command2 [args2...]] +# [COMMENT comment] +# +# Input: +# output - Output files the command is expected to produce +# condition - Generator expression for wrapping the command +# command - Command-line(s) to execute at build time. +# args - Command`s args +# depends - Files on which the command depends +# comment - Display the given message before the commands are executed at +# build time. +# PRE_BUILD - Run before any other rules are executed within the target +# PRE_LINK - Run after sources have been compiled but before linking the +# binary +# POST_BUILD - Run after all other rules within the target have been +# executed +################################################################################ +function(add_custom_command_if) + add_custom_command_if_parse_arguments(${ARGN}) + + if(OUTPUT AND TARGET) + message(FATAL_ERROR "Wrong syntax. A TARGET and OUTPUT can not both be specified.") + endif() + + if(OUTPUT) + add_custom_command(OUTPUT ${OUTPUT} + ${COMMANDS} + DEPENDS ${DEPENDS} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + COMMENT ${COMMENT}) + elseif(TARGET) + if(PRE_BUILD AND NOT ${CMAKE_GENERATOR} MATCHES "Visual Studio") + add_custom_target( + ${NAME} + ${COMMANDS} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + COMMENT ${COMMENT}) + add_dependencies(${TARGET} ${NAME}) + else() + add_custom_command( + TARGET ${TARGET} + ${STEP} + ${COMMANDS} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + COMMENT ${COMMENT}) + endif() + else() + message(FATAL_ERROR "Wrong syntax. A TARGET or OUTPUT must be specified.") + endif() +endfunction() + +################################################################################ +# Use props file for a target and configs +# use_props( ) +# Inside there are following variables: +# PROPS_TARGET - +# PROPS_CONFIG - One of +# PROPS_CONFIG_U - Uppercase PROPS_CONFIG +# Input: +# target - Target to apply props file +# configs - Build configurations to apply props file +# props_file - CMake script +################################################################################ +macro(use_props TARGET CONFIGS PROPS_FILE) + set(PROPS_TARGET "${TARGET}") + foreach(PROPS_CONFIG ${CONFIGS}) + string(TOUPPER "${PROPS_CONFIG}" PROPS_CONFIG_U) + + get_filename_component(ABSOLUTE_PROPS_FILE "${PROPS_FILE}" ABSOLUTE BASE_DIR "${CMAKE_CURRENT_LIST_DIR}") + if(EXISTS "${ABSOLUTE_PROPS_FILE}") + include("${ABSOLUTE_PROPS_FILE}") + else() + message(WARNING "Corresponding cmake file from props \"${ABSOLUTE_PROPS_FILE}\" doesn't exist") + endif() + endforeach() +endmacro() + +################################################################################ +# Function for MSVC precompiled headers +# add_precompiled_header( ) +# Input: +# target - Target to which add precompiled header +# precompiled_header - Name of precompiled header +# precompiled_source - Name of precompiled source file +################################################################################ +function(add_precompiled_header TARGET PRECOMPILED_HEADER PRECOMPILED_SOURCE) + get_target_property(SOURCES "${TARGET}" SOURCES) + list(REMOVE_ITEM SOURCES "${PRECOMPILED_SOURCE}") + + if(MSVC) + set(PRECOMPILED_BINARY "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${PROJECT_NAME}.pch") + + set_source_files_properties( + "${PRECOMPILED_SOURCE}" + PROPERTIES + COMPILE_OPTIONS "/Yc${PRECOMPILED_HEADER};/Fp${PRECOMPILED_BINARY}" + OBJECT_OUTPUTS "${PRECOMPILED_BINARY}") + + set_source_files_properties( + ${SOURCES} + PROPERTIES + COMPILE_OPTIONS "$<$,$>:/Yu${PRECOMPILED_HEADER};/Fp${PRECOMPILED_BINARY}>" + OBJECT_DEPENDS "${PRECOMPILED_BINARY}") + endif() + + list(INSERT SOURCES 0 "${PRECOMPILED_SOURCE}") + set_target_properties("${TARGET}" PROPERTIES SOURCES "${SOURCES}") +endfunction() + +################################################################################ +# Add compile options to source file +# source_file_compile_options( [compile_options...]) +# Input: +# source_file - Source file +# compile_options - Options to add to COMPILE_FLAGS property +################################################################################ +function(source_file_compile_options SOURCE_FILE) + if("${ARGC}" LESS_EQUAL "1") + return() + endif() + + get_source_file_property(COMPILE_OPTIONS "${SOURCE_FILE}" COMPILE_OPTIONS) + + if(COMPILE_OPTIONS) + list(APPEND COMPILE_OPTIONS ${ARGN}) + else() + set(COMPILE_OPTIONS "${ARGN}") + endif() + + set_source_files_properties("${SOURCE_FILE}" PROPERTIES COMPILE_OPTIONS "${COMPILE_OPTIONS}") +endfunction() + +################################################################################ +# Sub-projects +################################################################################ +add_subdirectory(src) +