fix cmake cache var override

This commit is contained in:
Lukas Cone 2021-07-22 14:58:04 +02:00
parent f76b0af9cd
commit 0bdc09f56e
2 changed files with 31 additions and 10 deletions

View File

@ -12,10 +12,31 @@ set(VGM_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
set(CMAKE_MODULE_PATH ${VGM_SOURCE_DIR}/cmake;${CMAKE_MODULE_PATH})
include(vgmstream)
function(set_mpeg onoff useForce)
if(useForce)
set(USE_FORCE_ FORCE)
endif()
set(USE_MPEG ${onoff} CACHE BOOL "Use libmpg123 for support of MPEG (MP1/MP2/MP3)" ${USE_FORCE_})
endfunction()
function(set_vorbis onoff useForce)
if(useForce)
set(USE_FORCE_ FORCE)
endif()
set(USE_VORBIS ${onoff} CACHE BOOL "Use libvorbis for support of Vorbis" ${USE_FORCE_})
endfunction()
function(set_ffmpeg onoff useForce)
if(useForce)
set(USE_FORCE_ FORCE)
endif()
set(USE_FFMPEG ${onoff} CACHE BOOL "Use FFmpeg for support of many codecs" ${USE_FORCE_})
endfunction()
# Options
option(USE_MPEG "Use libmpg123 for support of MPEG (MP1/MP2/MP3)" ON)
option(USE_VORBIS "Use libvorbis for support of Vorbis" ON)
option(USE_FFMPEG "Use FFmpeg for support of many codecs" ON)
set_mpeg(ON FALSE)
set_vorbis(ON FALSE)
set_ffmpeg(ON FALSE)
option(USE_MAIATRAC3PLUS "Use MAIATRAC3+ for support of ATRAC3+" OFF)
set(MAIATRAC3PLUS_PATH CACHE PATH "Path to MAIATRAC3+")
option(USE_G7221 "Use G7221 for support of ITU-T G.722.1 annex C" ON)
@ -45,16 +66,16 @@ endif()
if(USE_FFMPEG)
find_package(FFmpeg)
if(NOT FFMPEG_LIBRARIES)
set(USE_FFMPEG OFF)
set_ffmpeg(OFF TRUE)
else()
if(${AVCODEC_VERSION} VERSION_LESS 57)
set(USE_FFMPEG OFF)
set_ffmpeg(OFF TRUE)
message("libavcodec version mismatch ${AVCODEC_VERSION} expected >=57")
elseif(${AVUTIL_VERSION} VERSION_LESS 55)
set(USE_FFMPEG OFF)
set_ffmpeg(OFF TRUE)
message("libavutil version mismatch ${AVUTIL_VERSION} expected >=55")
elseif(${SWRESAMPLE_VERSION} VERSION_LESS 2)
set(USE_FFMPEG OFF)
set_ffmpeg(OFF TRUE)
message("libswresample version mismatch ${SWRESAMPLE_VERSION} expected >=2")
endif()
endif()
@ -100,13 +121,13 @@ else()
if(USE_MPEG)
find_package(MPG123)
if(NOT MPG123_FOUND)
set(USE_MPEG OFF)
set_mpeg(OFF TRUE)
endif()
endif()
if(USE_VORBIS)
find_package(VorbisFile)
if(NOT VORBISFILE_FOUND)
set(USE_VORBIS OFF)
set_vorbis(OFF TRUE)
endif()
endif()

View File

@ -84,7 +84,7 @@ macro(find_component _component _pkgconfig _library _header)
set(${_component}_DEFINITIONS ${PC_${_component}_CFLAGS_OTHER} CACHE STRING "The ${_component} CFLAGS.")
set(${_component}_VERSION ${PC_${_component}_VERSION} CACHE STRING "The ${_component} version number.")
if(WIN32 AND NOT ${_component}_VERSION)
if(WIN32 AND FFMPEG_PATH AND NOT ${_component}_VERSION)
file(GLOB FOUND_DLL_ ${FFMPEG_PATH}/bin/${_library}*.dll)
string(REGEX MATCH ".*${_library}-(.+).dll" FOUND_DLL_ ${FOUND_DLL_})
set(${_component}_VERSION ${CMAKE_MATCH_1} CACHE STRING "The ${_component} version number." FORCE)