diff options
Diffstat (limited to 'src/CMakeLists.txt')
-rw-r--r-- | src/CMakeLists.txt | 150 |
1 files changed, 79 insertions, 71 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ef322a9a..2f663061 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,89 +1,102 @@ set(THREADS_PREFER_PTHREAD_FLAG ON) find_package(Threads REQUIRED) -if(${RE3_AUDIO} STREQUAL "OAL") - find_package(OpenAL REQUIRED) - find_package(MPG123 REQUIRED) - find_package(SndFile REQUIRED) -endif() - -file(GLOB_RECURSE Sources "*.cpp" "*.h") +file(GLOB_RECURSE RE3_SOURCES "*.cpp" "*.h" "*.rc") -MACRO(HEADER_DIRECTORIES return_list) - FILE(GLOB_RECURSE new_list *.cpp) - SET(dir_list "animation" - "audio" - "collision" - "control" - "core" - "entities" - "extras" - "fakerw" - "math" - "modelinfo" - "objects" - "peds" - "render" - "rw" - "save" - "skel" - "text" - "vehicles" - "weapons") - FOREACH(file_path ${new_list}) - GET_FILENAME_COMPONENT(dir_path ${file_path} PATH) - SET(dir_list ${dir_list} ${dir_path}) - ENDFOREACH() - LIST(REMOVE_DUPLICATES dir_list) - SET(${return_list} ${dir_list}) -ENDMACRO() +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(header_list) -include_directories(${header_list}) +header_directories(RE3_INCLUDES) +add_executable(re3 WIN32 + ${RE3_SOURCES} +) -add_executable(re3 ${Sources}) -target_link_libraries(re3 librw) -target_link_libraries(re3 Threads::Threads) - -if(${RE3_AUDIO} STREQUAL "OAL") - target_link_libraries(re3 ${OPENAL_LIBRARY}) - target_link_libraries(re3 ${MPG123_LIBRARIES}) - target_link_libraries(re3 ${SNDFILE_LIBRARIES}) -endif() +target_link_libraries(re3 PRIVATE + librw::librw + Threads::Threads +) target_include_directories(re3 - INTERFACE + PRIVATE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}> - ) + $<BUILD_INTERFACE:${RE3_INCLUDES}> +) target_compile_definitions(re3 PRIVATE - "$<IF:$<CONFIG:DEBUG>,DEBUG,NDEBUG>" - PUBLIC - "RW_${RE3_PLATFORM}" + $<IF:$<CONFIG:DEBUG>,DEBUG,NDEBUG> + LIBRW + RE3_NO_AUTOLINK +) + +if(LIBRW_PLATFORM_D3D9) + target_compile_definitions(re3 + PUBLIC + USE_D3D9 ) +endif() -target_compile_definitions(re3 PRIVATE LIBRW=1 AUDIO_OAL=1) +if(RE3_AUDIO STREQUAL "OAL") + find_package(OpenAL REQUIRED) + target_include_directories(re3 PRIVATE ${OPENAL_INCLUDE_DIR}) + target_link_libraries(re3 PRIVATE ${OPENAL_LIBRARY}) + target_compile_definitions(re3 PRIVATE ${OPENAL_DEFINITIONS}) + target_compile_definitions(re3 PRIVATE AUDIO_OAL) +elseif(RE3_AUDIO STREQUAL "MSS") + find_package(MilesSDK REQUIRED) + target_compile_definitions(re3 PRIVATE AUDIO_MSS) + target_link_libraries(re3 PRIVATE MilesSDK::MilesSDK) +endif() + +find_package(mpg123 REQUIRED) +target_link_libraries(re3 PRIVATE + MPG123::libmpg123 +) +if(RE3_WITH_OPUS) + find_package(opusfile REQUIRED) + target_link_libraries(re3 PRIVATE + opusfile::opusfile + ) + target_compile_definitions(re3 PRIVATE AUDIO_OPUS) +endif() +if(RE3_WITH_LIBSNDFILE) + find_package(SndFile REQUIRED) + target_link_libraries(re3 PRIVATE + SndFile::SndFile + ) + target_compile_definitions(re3 PRIVATE AUDIO_OAL_USE_SNDFILE) +endif() + +target_compile_definitions(re3 PRIVATE ) if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") target_compile_options(re3 PRIVATE "-Wall" - ) - if (NOT RE3_PLATFORM_PS2) + ) + if (NOT LIBRW_PLATFORM_PS2) target_compile_options(re3 PRIVATE - "-Wextra" - "-Wdouble-promotion" - "-Wpedantic" - ) + -Wextra + -Wdouble-promotion + -Wpedantic + ) endif() elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") target_compile_options(re3 PUBLIC - /wd4996 /wd4244 - ) + /Zc:sizedDealloc- + ) endif() set_target_properties(re3 @@ -94,20 +107,15 @@ set_target_properties(re3 CXX_STANDARD 11 CXX_EXTENSIONS OFF CXX_STANDARD_REQUIRED ON - PREFIX "" - ) +) if(RE3_INSTALL) - target_include_directories(re3 - INTERFACE - $<INSTALL_INTERFACE:${RE3_INSTALL_INCLUDEDIR}> - ) - install( TARGETS re3 EXPORT re3-targets - RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" - LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" - ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" - ) + RUNTIME DESTINATION "." + ) + if(MSVC) + install(FILES $<TARGET_PDB_FILE:re3> DESTINATION "." OPTIONAL) + endif() endif() |