mirror of
https://github.com/GTAmodding/re3.git
synced 2025-01-18 00:16:36 +00:00
e38467ef3a
# Conflicts: # .github/workflows/reLCS_msvc_amd64.yml # .github/workflows/reLCS_msvc_x86.yml # README.md # gamefiles/TEXT/american.gxt # gamefiles/TEXT/french.gxt # gamefiles/TEXT/german.gxt # gamefiles/TEXT/italian.gxt # gamefiles/TEXT/spanish.gxt # premake5.lua # src/animation/AnimManager.cpp # src/animation/AnimationId.h # src/audio/MusicManager.cpp # src/audio/audio_enums.h # src/control/Script7.cpp # src/core/FileLoader.cpp # src/core/re3.cpp # src/extras/custompipes_d3d9.cpp # src/extras/custompipes_gl.cpp # src/extras/postfx.cpp # src/extras/shaders/colourfilterVC.frag # src/extras/shaders/colourfilterVC_PS.hlsl # src/extras/shaders/make_hlsl.cmd # src/extras/shaders/obj/colourfilterVC_PS.cso # src/extras/shaders/obj/colourfilterVC_PS.inc # src/extras/shaders/obj/colourfilterVC_frag.inc # src/peds/PedFight.cpp # src/render/Font.cpp # src/render/Hud.cpp # src/render/Particle.cpp # src/render/WaterCannon.cpp # src/skel/win/gtavc.ico # src/vehicles/Automobile.cpp # utils/gxt/american.txt # utils/gxt/french.txt # utils/gxt/german.txt # utils/gxt/italian.txt # utils/gxt/spanish.txt
143 lines
4.5 KiB
CMake
143 lines
4.5 KiB
CMake
find_package(Threads REQUIRED)
|
|
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
|
|
|
file(GLOB_RECURSE ${PROJECT}_SOURCES "*.cpp" "*.h" "*.rc")
|
|
|
|
function(header_directories RETURN_LIST)
|
|
file(GLOB_RECURSE ALL_SRCS *.h *.cpp *.c)
|
|
set(RELDIRS)
|
|
foreach(SRC ${ALL_SRCS})
|
|
file(RELATIVE_PATH RELSRC "${CMAKE_CURRENT_SOURCE_DIR}" "${SRC}")
|
|
get_filename_component(RELDIR "${RELSRC}" DIRECTORY)
|
|
list(APPEND RELDIRS ${RELDIR})
|
|
endforeach()
|
|
list(REMOVE_DUPLICATES RELDIRS)
|
|
set(${RETURN_LIST} ${RELDIRS} PARENT_SCOPE)
|
|
endfunction()
|
|
|
|
header_directories(${PROJECT}_INCLUDES)
|
|
|
|
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/extras/GitSHA1.cpp.in" "${CMAKE_CURRENT_BINARY_DIR}/extras/GitSHA1.cpp" @ONLY)
|
|
list(APPEND ${PROJECT}_SOURCES "${CMAKE_CURRENT_BINARY_DIR}/extras/GitSHA1.cpp")
|
|
|
|
add_executable(${EXECUTABLE} WIN32
|
|
${${PROJECT}_SOURCES}
|
|
)
|
|
|
|
target_link_libraries(${EXECUTABLE} PRIVATE
|
|
librw::librw
|
|
Threads::Threads
|
|
)
|
|
|
|
target_include_directories(${EXECUTABLE}
|
|
PRIVATE
|
|
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
|
|
$<BUILD_INTERFACE:${${PROJECT}_INCLUDES}>
|
|
)
|
|
|
|
target_compile_definitions(${EXECUTABLE}
|
|
PRIVATE
|
|
$<IF:$<CONFIG:DEBUG>,DEBUG,NDEBUG>
|
|
LIBRW
|
|
CMAKE_NO_AUTOLINK
|
|
)
|
|
|
|
if(LIBRW_PLATFORM_D3D9)
|
|
target_compile_definitions(${EXECUTABLE}
|
|
PUBLIC
|
|
USE_D3D9
|
|
)
|
|
endif()
|
|
|
|
target_compile_definitions(${EXECUTABLE} PRIVATE CMAKE_BUILD)
|
|
|
|
if(${PROJECT}_AUDIO STREQUAL "OAL")
|
|
find_package(OpenAL REQUIRED)
|
|
target_include_directories(${EXECUTABLE} PRIVATE ${OPENAL_INCLUDE_DIR})
|
|
target_link_libraries(${EXECUTABLE} PRIVATE ${OPENAL_LIBRARY})
|
|
target_compile_definitions(${EXECUTABLE} PRIVATE ${OPENAL_DEFINITIONS})
|
|
target_compile_definitions(${EXECUTABLE} PRIVATE AUDIO_OAL)
|
|
elseif(${PROJECT}_AUDIO STREQUAL "MSS")
|
|
find_package(MilesSDK REQUIRED)
|
|
target_compile_definitions(${EXECUTABLE} PRIVATE AUDIO_MSS)
|
|
target_link_libraries(${EXECUTABLE} PRIVATE MilesSDK::MilesSDK)
|
|
endif()
|
|
|
|
find_package(mpg123 REQUIRED)
|
|
target_link_libraries(${EXECUTABLE} PRIVATE
|
|
MPG123::libmpg123
|
|
)
|
|
if(${PROJECT}_WITH_OPUS)
|
|
find_package(opusfile REQUIRED)
|
|
target_link_libraries(${EXECUTABLE} PRIVATE
|
|
opusfile::opusfile
|
|
)
|
|
target_compile_definitions(${EXECUTABLE} PRIVATE AUDIO_OPUS)
|
|
endif()
|
|
if(${PROJECT}_WITH_LIBSNDFILE)
|
|
find_package(SndFile REQUIRED)
|
|
target_link_libraries(${EXECUTABLE} PRIVATE
|
|
SndFile::SndFile
|
|
)
|
|
target_compile_definitions(${EXECUTABLE} PRIVATE AUDIO_OAL_USE_SNDFILE)
|
|
endif()
|
|
|
|
target_compile_definitions(${EXECUTABLE} PRIVATE )
|
|
|
|
option(${PROJECT}_WITH_SANITIZERS "Use UB sanitizers (better crash log)" OFF)
|
|
option(${PROJECT}_WITH_ASAN "Use Address sanitizer (better crash log)" OFF)
|
|
|
|
if(${PROJECT}_WITH_SANITIZERS)
|
|
target_compile_options(${EXECUTABLE} PUBLIC
|
|
-fsanitize=undefined,float-divide-by-zero,integer,implicit-conversion,implicit-integer-truncation,implicit-integer-arithmetic-value-change,local-bounds,nullability
|
|
-g3 -fno-omit-frame-pointer)
|
|
target_link_options(${EXECUTABLE} PUBLIC -fsanitize=undefined,float-divide-by-zero,integer,implicit-conversion,implicit-integer-truncation,implicit-integer-arithmetic-value-change,local-bounds,nullability)
|
|
endif()
|
|
|
|
if(${PROJECT}_WITH_ASAN)
|
|
target_compile_options(${EXECUTABLE} PUBLIC -fsanitize=address -g3 -fno-omit-frame-pointer)
|
|
target_link_options(${EXECUTABLE} PUBLIC -fsanitize=address)
|
|
endif()
|
|
|
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
|
|
target_compile_options(${EXECUTABLE}
|
|
PRIVATE
|
|
"-Wall"
|
|
)
|
|
if (NOT LIBRW_PLATFORM_PS2)
|
|
target_compile_options(${EXECUTABLE}
|
|
PRIVATE
|
|
-fpermissive # for CVECTORHACK
|
|
-Wno-address-of-temporary # for CVECTORHACK
|
|
-Wextra
|
|
-Wdouble-promotion
|
|
-Wpedantic
|
|
)
|
|
endif()
|
|
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
|
target_compile_options(${EXECUTABLE}
|
|
PUBLIC
|
|
/Zc:sizedDealloc-
|
|
)
|
|
endif()
|
|
|
|
set_target_properties(${EXECUTABLE}
|
|
PROPERTIES
|
|
C_STANDARD 11
|
|
C_EXTENSIONS OFF
|
|
C_STANDARD_REQUIRED ON
|
|
CXX_STANDARD 11
|
|
CXX_EXTENSIONS OFF
|
|
CXX_STANDARD_REQUIRED ON
|
|
)
|
|
|
|
if(${PROJECT}_INSTALL)
|
|
install(
|
|
TARGETS ${EXECUTABLE}
|
|
EXPORT ${EXECUTABLE}-targets
|
|
RUNTIME DESTINATION "."
|
|
)
|
|
if(MSVC)
|
|
install(FILES $<TARGET_PDB_FILE:${EXECUTABLE}> DESTINATION "." OPTIONAL)
|
|
endif()
|
|
endif()
|