2022-11-09 05:08:58 +08:00
cmake_minimum_required ( VERSION 3.20 )
2024-07-04 21:59:52 +08:00
set ( CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>" )
2022-11-09 05:08:58 +08:00
project ( YimMenu CXX ASM_MASM )
2024-03-12 16:35:36 +08:00
if ( NOT MSVC )
message ( FATAL_ERROR "Unsupported compiler used '${CMAKE_CXX_COMPILER_ID}', YimMenu only supports MSVC." )
endif ( )
2022-11-09 05:08:58 +08:00
set ( SRC_DIR "${PROJECT_SOURCE_DIR}/src" )
2022-11-29 01:19:03 +08:00
# Git commit embed
2023-12-30 23:05:18 +08:00
include ( cmake/git.cmake )
2022-11-09 05:08:58 +08:00
# Fetch modules
message ( "\nFetching modules" )
2024-07-08 20:15:18 +08:00
include ( cmake/asmjit.cmake )
2023-12-30 23:05:18 +08:00
include ( cmake/minhook.cmake )
include ( cmake/async-logger.cmake )
include ( cmake/pugixml.cmake )
include ( cmake/json.cmake )
include ( cmake/cpr.cmake )
include ( cmake/lua.cmake )
include ( cmake/imgui.cmake )
2023-07-24 00:51:57 +08:00
message ( "\nFetching custom modules" )
2023-12-30 23:05:18 +08:00
include ( cmake/gtav-classes.cmake )
2022-11-09 05:08:58 +08:00
# YimMenu
message ( STATUS "YimMenu" )
file ( GLOB_RECURSE SRC_MAIN
" $ { S R C _ D I R } / * * . h p p "
" $ { S R C _ D I R } / * * . h "
" $ { S R C _ D I R } / * * . c p p "
" $ { S R C _ D I R } / * * . c c "
" $ { S R C _ D I R } / * * . c x x "
" $ { S R C _ D I R } / * * . a s m "
)
2023-06-28 02:13:05 +08:00
if ( MSVC )
add_compile_options ( /bigobj )
2023-09-13 02:20:29 +08:00
add_compile_options ( "$<$<C_COMPILER_ID:MSVC>:/utf-8>" )
add_compile_options ( "$<$<CXX_COMPILER_ID:MSVC>:/utf-8>" )
2023-06-28 02:13:05 +08:00
else ( )
add_compile_options ( -Wa,-mbig-obj )
endif ( )
2022-11-09 05:08:58 +08:00
add_library ( YimMenu MODULE "${SRC_MAIN}" )
set_property ( GLOBAL PROPERTY USE_FOLDERS ON )
set_property ( TARGET YimMenu PROPERTY CXX_STANDARD 23 ) # 23 Because std::format is not avalible in std:c++20 for some reason. Maybe it's because i use v142 toolset.
2022-11-16 21:15:18 +08:00
source_group ( TREE ${ SRC_DIR } PREFIX "src" FILES ${ SRC_MAIN } )
2022-11-09 05:08:58 +08:00
target_include_directories ( YimMenu PRIVATE
" $ { S R C _ D I R } "
" $ { j s o n _ S O U R C E _ D I R } / s i n g l e _ i n c l u d e "
" $ { g t a v _ c l a s s e s _ S O U R C E _ D I R } "
" $ { i m g u i _ S O U R C E _ D I R } "
2023-12-30 00:07:00 +08:00
" $ { m i n h o o k _ S O U R C E _ D I R } / s r c / h d e "
2024-07-08 20:15:18 +08:00
" $ { a s m j i t _ S O U R C E _ D I R } / s r c "
2022-11-09 05:08:58 +08:00
)
target_precompile_headers ( YimMenu PRIVATE "${SRC_DIR}/common.hpp" )
2024-07-08 20:15:18 +08:00
target_link_libraries ( YimMenu PRIVATE pugixml minhook AsyncLogger dbghelp imgui cpr lua_static asmjit::asmjit )
2022-11-09 05:08:58 +08:00
# Warnings as errors
set_property ( TARGET YimMenu PROPERTY COMPILE_WARNING_AS_ERROR ON )
add_compile_definitions ( YimMenu
" _ C R T _ S E C U R E _ N O _ W A R N I N G S "
" N O M I N M A X "
" W I N 3 2 _ L E A N _ A N D _ M E A N "
2023-06-28 02:13:05 +08:00
)
2023-12-30 00:07:00 +08:00
# Optimizations
if ( MSVC )
2024-01-11 18:52:31 +08:00
if ( OPTIMIZE )
set ( CMAKE_MODULE_LINKER_FLAGS
" $ { C M A K E _ M O D U L E _ L I N K E R _ F L A G S } / L T C G / O P T : R E F , I C F / G U A R D : N O " )
set ( CMAKE_CXX_FLAGS_RELWITHDEBINFO
" $ { C M A K E _ C X X _ F L A G S _ R E L W I T H D E B I N F O } / O 2 / O i / O t / O y / O b 3 / s d l - / G L / G F / G S - / G w " )
string ( REPLACE "/Ob1" "/Ob3" CMAKE_CXX_FLAGS_RELWITHDEBINFO ${ CMAKE_CXX_FLAGS_RELWITHDEBINFO } )
2024-07-04 05:04:06 +08:00
else ( )
add_compile_definitions ( YIM_DEV )
2024-01-11 18:52:31 +08:00
endif ( )
2023-12-30 00:07:00 +08:00
endif ( )