mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-06 14:27:16 +00:00
Codefix: [CMake] Debug libs of Ogg, Opus and OpusFile were used for release with multi-config generators (#13539)
This commit is contained in:
parent
3bbc80f1d9
commit
ad24779661
@ -43,29 +43,8 @@ find_library(LZO_LIBRARY
|
||||
PATHS ${PC_LZO_LIBRARY_DIRS}
|
||||
)
|
||||
|
||||
# With vcpkg, the library path should contain both 'debug' and 'optimized'
|
||||
# entries (see target_link_libraries() documentation for more information)
|
||||
#
|
||||
# NOTE: we only patch up when using vcpkg; the same issue might happen
|
||||
# when not using vcpkg, but this is non-trivial to fix, as we have no idea
|
||||
# what the paths are. With vcpkg we do. And we only official support vcpkg
|
||||
# with Windows.
|
||||
#
|
||||
# NOTE: this is based on the assumption that the debug file has the same
|
||||
# name as the optimized file. This is not always the case, but so far
|
||||
# experiences has shown that in those case vcpkg CMake files do the right
|
||||
# thing.
|
||||
if(VCPKG_TOOLCHAIN AND LZO_LIBRARY AND LZO_LIBRARY MATCHES "${VCPKG_INSTALLED_DIR}")
|
||||
if(LZO_LIBRARY MATCHES "/debug/")
|
||||
set(LZO_LIBRARY_DEBUG ${LZO_LIBRARY})
|
||||
string(REPLACE "/debug/lib/" "/lib/" LZO_LIBRARY_RELEASE ${LZO_LIBRARY})
|
||||
else()
|
||||
set(LZO_LIBRARY_RELEASE ${LZO_LIBRARY})
|
||||
string(REPLACE "/lib/" "/debug/lib/" LZO_LIBRARY_DEBUG ${LZO_LIBRARY})
|
||||
endif()
|
||||
include(SelectLibraryConfigurations)
|
||||
select_library_configurations(LZO)
|
||||
endif()
|
||||
include(FixVcpkgLibrary)
|
||||
FixVcpkgLibrary(LZO)
|
||||
|
||||
set(LZO_VERSION ${PC_LZO_VERSION})
|
||||
|
||||
|
@ -4,6 +4,9 @@ find_library(Ogg_LIBRARY
|
||||
NAMES ogg
|
||||
)
|
||||
|
||||
include(FixVcpkgLibrary)
|
||||
FixVcpkgLibrary(Ogg)
|
||||
|
||||
set(Ogg_COMPILE_OPTIONS "" CACHE STRING "Extra compile options of ogg")
|
||||
|
||||
set(Ogg_LINK_LIBRARIES "" CACHE STRING "Extra link libraries of ogg")
|
||||
@ -33,5 +36,6 @@ if (Ogg_FOUND)
|
||||
INTERFACE_LINK_LIBRARIES "${Ogg_LINK_LIBRARIES}"
|
||||
INTERFACE_LINK_FLAGS "${Ogg_LINK_FLAGS}"
|
||||
)
|
||||
FixVcpkgTarget(Ogg Ogg::ogg)
|
||||
endif()
|
||||
endif()
|
||||
|
@ -4,6 +4,9 @@ find_library(Opus_LIBRARY
|
||||
NAMES opus
|
||||
)
|
||||
|
||||
include(FixVcpkgLibrary)
|
||||
FixVcpkgLibrary(Opus)
|
||||
|
||||
set(Opus_COMPILE_OPTIONS "" CACHE STRING "Extra compile options of opus")
|
||||
|
||||
set(Opus_LINK_LIBRARIES "" CACHE STRING "Extra link libraries of opus")
|
||||
@ -33,5 +36,6 @@ if (Opus_FOUND)
|
||||
INTERFACE_LINK_LIBRARIES "${Opus_LINK_LIBRARIES}"
|
||||
INTERFACE_LINK_FLAGS "${Opus_LINK_FLAGS}"
|
||||
)
|
||||
FixVcpkgTarget(Opus Opus::opus)
|
||||
endif()
|
||||
endif()
|
||||
|
@ -4,6 +4,9 @@ find_library(OpusFile_LIBRARY
|
||||
NAMES opusfile
|
||||
)
|
||||
|
||||
include(FixVcpkgLibrary)
|
||||
FixVcpkgLibrary(OpusFile)
|
||||
|
||||
set(OpusFile_COMPILE_OPTIONS "" CACHE STRING "Extra compile options of opusfile")
|
||||
|
||||
set(OpusFile_LINK_LIBRARIES "" CACHE STRING "Extra link libraries of opusfile")
|
||||
@ -36,5 +39,6 @@ if (OpusFile_FOUND)
|
||||
INTERFACE_LINK_LIBRARIES "Ogg::ogg;Opus::opus;${OpusFile_LINK_LIBRARIES}"
|
||||
INTERFACE_LINK_FLAGS "${OpusFile_LINK_FLAGS}"
|
||||
)
|
||||
FixVcpkgTarget(OpusFile OpusFile::opusfile)
|
||||
endif()
|
||||
endif()
|
||||
|
40
cmake/FixVcpkgLibrary.cmake
Normal file
40
cmake/FixVcpkgLibrary.cmake
Normal file
@ -0,0 +1,40 @@
|
||||
macro(FixVcpkgLibrary NAME)
|
||||
# With vcpkg, the library path should contain both 'debug' and 'optimized'
|
||||
# entries (see target_link_libraries() documentation for more information)
|
||||
#
|
||||
# NOTE: we only patch up when using vcpkg; the same issue might happen
|
||||
# when not using vcpkg, but this is non-trivial to fix, as we have no idea
|
||||
# what the paths are. With vcpkg we do. And we only official support vcpkg
|
||||
# with Windows.
|
||||
#
|
||||
# NOTE: this is based on the assumption that the debug file has the same
|
||||
# name as the optimized file. This is not always the case, but so far
|
||||
# experiences has shown that in those case vcpkg CMake files do the right
|
||||
# thing.
|
||||
if(VCPKG_TOOLCHAIN AND ${NAME}_LIBRARY AND ${NAME}_LIBRARY MATCHES "${VCPKG_INSTALLED_DIR}")
|
||||
if(${NAME}_LIBRARY MATCHES "/debug/")
|
||||
set(${NAME}_LIBRARY_DEBUG ${${NAME}_LIBRARY})
|
||||
string(REPLACE "/debug/lib/" "/lib/" ${NAME}_LIBRARY_RELEASE ${${NAME}_LIBRARY})
|
||||
else()
|
||||
set(${NAME}_LIBRARY_RELEASE ${${NAME}_LIBRARY})
|
||||
string(REPLACE "/lib/" "/debug/lib/" ${NAME}_LIBRARY_DEBUG ${${NAME}_LIBRARY})
|
||||
endif()
|
||||
include(SelectLibraryConfigurations)
|
||||
select_library_configurations(${NAME})
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
function(FixVcpkgTarget NAME TARGET)
|
||||
if(EXISTS "${${NAME}_LIBRARY_RELEASE}")
|
||||
set_property(TARGET ${TARGET} APPEND PROPERTY
|
||||
IMPORTED_CONFIGURATIONS RELEASE)
|
||||
set_target_properties(${TARGET} PROPERTIES
|
||||
IMPORTED_LOCATION_RELEASE "${${NAME}_LIBRARY_RELEASE}")
|
||||
endif()
|
||||
if(EXISTS "${${NAME}_LIBRARY_DEBUG}")
|
||||
set_property(TARGET ${TARGET} APPEND PROPERTY
|
||||
IMPORTED_CONFIGURATIONS DEBUG)
|
||||
set_target_properties(${TARGET} PROPERTIES
|
||||
IMPORTED_LOCATION_DEBUG "${${NAME}_LIBRARY_DEBUG}")
|
||||
endif()
|
||||
endfunction()
|
Loading…
Reference in New Issue
Block a user