99 lines
2.7 KiB
CMake
99 lines
2.7 KiB
CMake
function(setup_target TARGET DBG_MODE)
|
|
add_executable(${TARGET}
|
|
r3/main.cxx
|
|
gh_global.cxx
|
|
)
|
|
|
|
target_compile_features(${TARGET} PUBLIC cxx_std_20)
|
|
target_include_directories(${TARGET} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
|
|
|
set_target_properties(
|
|
${TARGET} PROPERTIES
|
|
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
|
|
)
|
|
|
|
if(WIN32 AND R3_32BIT)
|
|
target_link_directories(${TARGET} PRIVATE ${CMAKE_CURRENT_LIST_DIR}/../third_party/bink)
|
|
target_link_libraries(${TARGET} PRIVATE
|
|
binkw32
|
|
d3d8
|
|
dinput8
|
|
)
|
|
endif()
|
|
|
|
target_compile_definitions(${TARGET} PRIVATE
|
|
R3_GAME_DATA_DIR=\"${GAME_DATA_DIR}\"
|
|
)
|
|
|
|
get_filename_component(R3_DATA_SEGMENT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/gh_datasegment.bin" ABSOLUTE)
|
|
target_compile_definitions(${TARGET} PRIVATE
|
|
R3_DATA_SEGMENT_FILE=\"${R3_DATA_SEGMENT_FILE}\"
|
|
)
|
|
|
|
target_compile_definitions(${TARGET} PRIVATE
|
|
_CRT_SECURE_NO_WARNINGS=1
|
|
_CRT_NONSTDC_NO_WARNINGS=1)
|
|
|
|
target_link_libraries(${TARGET} PRIVATE spdlog)
|
|
|
|
file(GLOB GH_AUTO_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/gh_auto/*.cxx)
|
|
file(GLOB GH_FIX_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/gh_fix/*.cxx)
|
|
file(GLOB GH_STUB_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/gh_stub/*.cxx)
|
|
|
|
target_sources(${TARGET} PRIVATE
|
|
${GH_AUTO_SOURCES}
|
|
${GH_FIX_SOURCES}
|
|
${GH_STUB_SOURCES}
|
|
)
|
|
|
|
# Ignore -Wformat-security
|
|
target_compile_options(${TARGET} PRIVATE -Wno-format-security)
|
|
|
|
# Ignore -Wmicrosoft-cast
|
|
target_compile_options(${TARGET} PRIVATE -Wno-microsoft-cast)
|
|
|
|
# Automatically re-run CMake if any gh_*.cxx files change
|
|
# due to ghidra script runs
|
|
set_property(
|
|
DIRECTORY
|
|
APPEND
|
|
PROPERTY CMAKE_CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/gh_cmake_timestamp
|
|
)
|
|
|
|
target_precompile_headers(${TARGET} PRIVATE
|
|
"$<$<COMPILE_LANGUAGE:CXX>:${CMAKE_CURRENT_SOURCE_DIR}/r3/binders/auto_pch.cxx>"
|
|
)
|
|
|
|
# Potentially might want 1/1 translation for code
|
|
# For now it has the following values:
|
|
# 0 = 100% original (as possible)
|
|
# 1 = Runtime QOL (no cd checks, windowed mode, etc.)
|
|
target_compile_definitions(${TARGET} PRIVATE
|
|
RE_AUTHENTIC=1
|
|
)
|
|
|
|
if(DBG_MODE)
|
|
target_sources(${TARGET} PRIVATE
|
|
r3/binders/dbg_mem.cxx
|
|
)
|
|
target_compile_definitions(game_dbg PRIVATE RE_DBG_INJECTED=1)
|
|
|
|
# We load the original binary at it's original location, so offset the base address
|
|
target_link_options(${TARGET} PRIVATE
|
|
-Wl,/BASE:0x20000000
|
|
-Wl,/DYNAMICBASE:NO
|
|
)
|
|
target_link_libraries(${TARGET} PRIVATE
|
|
DbgHelp
|
|
)
|
|
|
|
else()
|
|
target_sources(${TARGET} PRIVATE
|
|
r3/binders/static_mem.cxx
|
|
)
|
|
endif()
|
|
endfunction()
|
|
|
|
setup_target(game_re OFF)
|
|
setup_target(game_dbg ON)
|