summaryrefslogtreecommitdiffstats
path: root/src/CMakeLists.txt
blob: 2f66306133c83e35293973daa2085bbe0ca41669 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)

file(GLOB_RECURSE RE3_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(RE3_INCLUDES)

add_executable(re3 WIN32
    ${RE3_SOURCES}
)

target_link_libraries(re3 PRIVATE
    librw::librw
    Threads::Threads
)

target_include_directories(re3
    PRIVATE
        $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
        $<BUILD_INTERFACE:${RE3_INCLUDES}>
)

target_compile_definitions(re3
    PRIVATE
        $<IF:$<CONFIG:DEBUG>,DEBUG,NDEBUG>
        LIBRW
        RE3_NO_AUTOLINK
)

if(LIBRW_PLATFORM_D3D9)
    target_compile_definitions(re3
        PUBLIC
            USE_D3D9
    )
endif()

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 LIBRW_PLATFORM_PS2)
        target_compile_options(re3
            PRIVATE
                -Wextra
                -Wdouble-promotion
                -Wpedantic
        )
    endif()
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
    target_compile_options(re3
        PUBLIC
            /Zc:sizedDealloc-
    )
endif()

set_target_properties(re3
    PROPERTIES
        C_STANDARD 11
        C_EXTENSIONS OFF
        C_STANDARD_REQUIRED ON
        CXX_STANDARD 11
        CXX_EXTENSIONS OFF
        CXX_STANDARD_REQUIRED ON
)

if(RE3_INSTALL)
    install(
        TARGETS re3
        EXPORT re3-targets
        RUNTIME DESTINATION "."
    )
    if(MSVC)
        install(FILES $<TARGET_PDB_FILE:re3> DESTINATION "." OPTIONAL)
    endif()
endif()