2020-10-31 22:14:28 +00:00
|
|
|
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
|
|
|
find_package(Threads REQUIRED)
|
|
|
|
|
2021-01-13 11:15:22 +00:00
|
|
|
file(GLOB_RECURSE ${PROJECT}_SOURCES "*.cpp" "*.h" "*.rc")
|
2020-10-31 22:14:28 +00:00
|
|
|
|
2020-12-06 12:54:06 +00:00
|
|
|
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()
|
2020-10-31 22:14:28 +00:00
|
|
|
|
2021-01-13 11:15:22 +00:00
|
|
|
header_directories(${PROJECT}_INCLUDES)
|
2020-10-31 22:14:28 +00:00
|
|
|
|
2021-01-13 11:15:22 +00:00
|
|
|
add_executable(${EXECUTABLE} WIN32
|
|
|
|
${${PROJECT}_SOURCES}
|
2021-01-03 18:08:59 +00:00
|
|
|
)
|
|
|
|
|
2021-01-13 11:15:22 +00:00
|
|
|
target_link_libraries(${EXECUTABLE} PRIVATE
|
2020-12-06 12:54:06 +00:00
|
|
|
librw::librw
|
|
|
|
Threads::Threads
|
|
|
|
)
|
2020-10-31 22:14:28 +00:00
|
|
|
|
2021-01-13 11:15:22 +00:00
|
|
|
target_include_directories(${EXECUTABLE}
|
2020-12-06 14:42:15 +00:00
|
|
|
PRIVATE
|
2020-10-31 22:14:28 +00:00
|
|
|
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
|
2021-01-13 11:15:22 +00:00
|
|
|
$<BUILD_INTERFACE:${${PROJECT}_INCLUDES}>
|
2020-12-06 14:42:15 +00:00
|
|
|
)
|
2020-10-31 22:14:28 +00:00
|
|
|
|
2021-01-13 11:15:22 +00:00
|
|
|
target_compile_definitions(${EXECUTABLE}
|
2020-10-31 22:14:28 +00:00
|
|
|
PRIVATE
|
2020-12-06 14:42:15 +00:00
|
|
|
$<IF:$<CONFIG:DEBUG>,DEBUG,NDEBUG>
|
|
|
|
LIBRW
|
2021-01-13 11:15:22 +00:00
|
|
|
${PROJECT}_NO_AUTOLINK
|
2020-12-06 14:42:15 +00:00
|
|
|
)
|
|
|
|
|
2021-01-03 15:30:45 +00:00
|
|
|
if(LIBRW_PLATFORM_D3D9)
|
2021-01-13 11:15:22 +00:00
|
|
|
target_compile_definitions(${EXECUTABLE}
|
2021-01-03 15:30:45 +00:00
|
|
|
PUBLIC
|
|
|
|
USE_D3D9
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2021-01-13 11:15:22 +00:00
|
|
|
if(${PROJECT}_AUDIO STREQUAL "OAL")
|
2020-12-06 14:42:15 +00:00
|
|
|
find_package(OpenAL REQUIRED)
|
2021-01-13 11:15:22 +00:00
|
|
|
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")
|
2021-01-03 15:30:45 +00:00
|
|
|
find_package(MilesSDK REQUIRED)
|
2021-01-13 11:15:22 +00:00
|
|
|
target_compile_definitions(${EXECUTABLE} PRIVATE AUDIO_MSS)
|
|
|
|
target_link_libraries(${EXECUTABLE} PRIVATE MilesSDK::MilesSDK)
|
2020-12-06 14:42:15 +00:00
|
|
|
endif()
|
|
|
|
|
2021-01-11 00:29:43 +00:00
|
|
|
find_package(mpg123 REQUIRED)
|
2021-01-13 11:15:22 +00:00
|
|
|
target_link_libraries(${EXECUTABLE} PRIVATE
|
2021-01-11 00:29:43 +00:00
|
|
|
MPG123::libmpg123
|
|
|
|
)
|
2021-01-13 11:15:22 +00:00
|
|
|
if(${PROJECT}_WITH_OPUS)
|
2020-12-06 18:12:35 +00:00
|
|
|
find_package(opusfile REQUIRED)
|
2021-01-13 11:15:22 +00:00
|
|
|
target_link_libraries(${EXECUTABLE} PRIVATE
|
2020-12-06 18:12:35 +00:00
|
|
|
opusfile::opusfile
|
|
|
|
)
|
2021-01-13 11:15:22 +00:00
|
|
|
target_compile_definitions(${EXECUTABLE} PRIVATE AUDIO_OPUS)
|
2021-01-11 00:29:43 +00:00
|
|
|
endif()
|
2021-01-13 11:15:22 +00:00
|
|
|
if(${PROJECT}_WITH_LIBSNDFILE)
|
2020-12-06 14:42:15 +00:00
|
|
|
find_package(SndFile REQUIRED)
|
2021-01-13 11:15:22 +00:00
|
|
|
target_link_libraries(${EXECUTABLE} PRIVATE
|
2020-12-06 14:42:15 +00:00
|
|
|
SndFile::SndFile
|
2020-10-31 22:14:28 +00:00
|
|
|
)
|
2021-01-13 11:15:22 +00:00
|
|
|
target_compile_definitions(${EXECUTABLE} PRIVATE AUDIO_OAL_USE_SNDFILE)
|
2020-12-06 14:42:15 +00:00
|
|
|
endif()
|
2020-10-31 22:14:28 +00:00
|
|
|
|
2021-01-13 11:15:22 +00:00
|
|
|
target_compile_definitions(${EXECUTABLE} PRIVATE )
|
2020-10-31 22:14:28 +00:00
|
|
|
|
|
|
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
|
2021-01-13 11:15:22 +00:00
|
|
|
target_compile_options(${EXECUTABLE}
|
2020-10-31 22:14:28 +00:00
|
|
|
PRIVATE
|
|
|
|
"-Wall"
|
2021-01-03 19:38:53 +00:00
|
|
|
)
|
2020-12-06 12:54:06 +00:00
|
|
|
if (NOT LIBRW_PLATFORM_PS2)
|
2021-01-13 11:15:22 +00:00
|
|
|
target_compile_options(${EXECUTABLE}
|
2020-10-31 22:14:28 +00:00
|
|
|
PRIVATE
|
2020-12-06 14:42:15 +00:00
|
|
|
-Wextra
|
|
|
|
-Wdouble-promotion
|
|
|
|
-Wpedantic
|
2021-01-03 19:38:53 +00:00
|
|
|
)
|
2020-10-31 22:14:28 +00:00
|
|
|
endif()
|
|
|
|
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
2021-01-13 11:15:22 +00:00
|
|
|
target_compile_options(${EXECUTABLE}
|
2020-10-31 22:14:28 +00:00
|
|
|
PUBLIC
|
2020-12-06 14:42:15 +00:00
|
|
|
/Zc:sizedDealloc-
|
2021-01-03 19:38:53 +00:00
|
|
|
)
|
2020-10-31 22:14:28 +00:00
|
|
|
endif()
|
|
|
|
|
2021-01-13 11:15:22 +00:00
|
|
|
set_target_properties(${EXECUTABLE}
|
2020-10-31 22:14:28 +00:00
|
|
|
PROPERTIES
|
|
|
|
C_STANDARD 11
|
|
|
|
C_EXTENSIONS OFF
|
|
|
|
C_STANDARD_REQUIRED ON
|
|
|
|
CXX_STANDARD 11
|
|
|
|
CXX_EXTENSIONS OFF
|
|
|
|
CXX_STANDARD_REQUIRED ON
|
2021-01-03 19:38:53 +00:00
|
|
|
)
|
2020-10-31 22:14:28 +00:00
|
|
|
|
2021-01-13 11:15:22 +00:00
|
|
|
if(${PROJECT}_INSTALL)
|
2020-10-31 22:14:28 +00:00
|
|
|
install(
|
2021-01-13 11:15:22 +00:00
|
|
|
TARGETS ${EXECUTABLE}
|
|
|
|
EXPORT ${EXECUTABLE}-targets
|
2021-01-03 19:38:53 +00:00
|
|
|
RUNTIME DESTINATION "."
|
|
|
|
)
|
2021-01-03 19:50:35 +00:00
|
|
|
if(MSVC)
|
2021-01-13 11:15:22 +00:00
|
|
|
install(FILES $<TARGET_PDB_FILE:${EXECUTABLE}> DESTINATION "." OPTIONAL)
|
2021-01-03 19:50:35 +00:00
|
|
|
endif()
|
2020-10-31 22:14:28 +00:00
|
|
|
endif()
|