From c0bd8f80e7d3ca4b4fa0623953d3861a53487f46 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Tue, 28 Jan 2020 11:04:48 +0200 Subject: [PATCH] - configured use of libvpx for all platforms MSVC uses libvpx stored in the repository if lookup for external headers and libraries failed --- CMakeLists.txt | 5 +++-- cmake/FindVPX.cmake | 8 ++++++++ source/CMakeLists.txt | 37 +++++++++++++++++++++++++++---------- 3 files changed, 38 insertions(+), 12 deletions(-) create mode 100644 cmake/FindVPX.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index eacf4067a..61298a91c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -172,6 +172,7 @@ option( NO_OPENAL "Disable OpenAL sound support" OFF ) find_package( BZip2 ) find_package( JPEG ) +find_package( VPX ) find_package( ZLIB ) include( TargetArch ) @@ -228,7 +229,7 @@ if( MSVC ) # Most of these need to be cleaned out. The source is currently infested with far too much conditional compilation which is a constant source of problems. - set( ALL_C_FLAGS "${ALL_C_FLAGS} /DUSE_OPENGL=1 /DUSE_LIBVPX /DNOASM=1 /DWIN32" ) + set( ALL_C_FLAGS "${ALL_C_FLAGS} /DUSE_OPENGL=1 /DNOASM=1 /DWIN32" ) # The CMake configurations set /GR and /MD by default, which conflict with our settings. string(REPLACE "/MD " " " CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE} ) @@ -248,7 +249,7 @@ else() else() set( ALL_C_FLAGS "-ffp-contract=off" ) endif() - set( ALL_C_FLAGS "${ALL_C_FLAGS} -DUSE_OPENGL=1 -DNOASM=1" ) # /DUSE_LIBVPX fixme: Set up libvpx + set( ALL_C_FLAGS "${ALL_C_FLAGS} -DUSE_OPENGL=1 -DNOASM=1" ) if ( UNIX ) include(CheckSymbolExists) diff --git a/cmake/FindVPX.cmake b/cmake/FindVPX.cmake new file mode 100644 index 000000000..160ff0618 --- /dev/null +++ b/cmake/FindVPX.cmake @@ -0,0 +1,8 @@ + +find_path(VPX_INCLUDE_DIR NAMES vpx/vp8dx.h vpx/vpx_decoder.h) +find_library(VPX_LIBRARIES NAMES vpx) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(VPX DEFAULT_MSG VPX_LIBRARIES VPX_INCLUDE_DIR) + +mark_as_advanced(VPX_INCLUDE_DIR VPX_LIBRARIES) diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index eafccce39..7dcf888b6 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -69,12 +69,6 @@ if( WIN32 ) set( DX_dinput8_LIBRARY dinput8 ) - if( X64 ) - link_directories(${CMAKE_CURRENT_SOURCE_DIR}/../platform/Windows/lib/64) - else() - link_directories(${CMAKE_CURRENT_SOURCE_DIR}/../platform/Windows/lib/32) - endif() - set( PROJECT_LIBRARIES opengl32 wsock32 @@ -433,11 +427,34 @@ if (HAVE_VULKAN) set( PROJECT_LIBRARIES ${PROJECT_LIBRARIES} "glslang" "SPIRV" "OGLCompiler") endif() -# Ugh... These precompiled dependencies need to go. +# VPX + +if( MSVC AND NOT VPX_FOUND ) + # Use prebuilt library + set( VPX_ROOT_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../platform/Windows" ) + set( VPX_INCLUDE_DIR ${VPX_ROOT_PATH}/include ) + set( VPX_LIBRARIES libvpx libcompat-to-msvc ) + if( X64 ) + link_directories( ${VPX_ROOT_PATH}/lib/64 ) + else() + link_directories( ${VPX_ROOT_PATH}/lib/32 ) + # Workaround for "error LNK2026: module unsafe for SAFESEH image." + set( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH:NO" ) + endif() + set( VPX_FOUND TRUE ) +endif() + +if( VPX_FOUND ) + add_definitions( "-DUSE_LIBVPX=1" ) + include_directories( "${VPX_INCLUDE_DIR}" ) + set( PROJECT_LIBRARIES ${PROJECT_LIBRARIES} ${VPX_LIBRARIES} ) +endif() + + +include_directories( "${ZLIB_INCLUDE_DIR}" "${ZMUSIC_INCLUDE_DIR}" "${BZIP2_INCLUDE_DIR}" "${LZMA_INCLUDE_DIR}" "${JPEG_INCLUDE_DIR}" "${GDTOA_INCLUDE_DIR}" ) + if (WIN32) - include_directories( "platform/win32" "${ZLIB_INCLUDE_DIR}" "${ZMUSIC_INCLUDE_DIR}" "${BZIP2_INCLUDE_DIR}" "${LZMA_INCLUDE_DIR}" "${JPEG_INCLUDE_DIR}" "${GDTOA_INCLUDE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/../platform/windows/include" "${CMAKE_CURRENT_SOURCE_DIR}/../platform/windows/include/vpx") -else () - include_directories( "${ZLIB_INCLUDE_DIR}" "${ZMUSIC_INCLUDE_DIR}" "${BZIP2_INCLUDE_DIR}" "${LZMA_INCLUDE_DIR}" "${JPEG_INCLUDE_DIR}" "${GDTOA_INCLUDE_DIR}") + include_directories( "platform/win32" ) endif()