Skip to content

Commit

Permalink
cmake: Fix handling of debug wrapper libraries
Browse files Browse the repository at this point in the history
Specifying separate targets for debug configuration (as well as using
"debug" and "optimized" keywords) is legacy behavior.

The correct way is to specify `_DEBUG` variants of the imported target
properties, which CMake will pick up automatically if the project is
built with debug configuration.

This commit forward-fixes the update on obs-studio, by still using
the legacy behavior if the legacy target is present.
  • Loading branch information
PatTheMav authored and RytoEX committed May 3, 2022
1 parent de0c30d commit a6df681
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,12 @@ if(NOT OS_MACOS OR ENABLE_BROWSER_LEGACY)
target_compile_features(obs-browser-page PRIVATE cxx_std_17)

if(OS_WINDOWS)
target_link_libraries(obs-browser-page PRIVATE optimized CEF::Wrapper)

if(TARGET CEF::Wrapper_Debug)
target_link_libraries(obs-browser-page PRIVATE optimized CEF::Wrapper)
target_link_libraries(obs-browser-page PRIVATE debug CEF::Wrapper_Debug)
else()
target_link_libraries(obs-browser-page PRIVATE CEF::Wrapper)
endif()

target_sources(obs-browser-page PRIVATE obs-browser-page.manifest)
Expand Down Expand Up @@ -200,11 +202,13 @@ if(OS_WINDOWS)
PRIVATE $<IF:$<CONFIG:DEBUG>,/MTd,/MT>)
endif()

target_link_libraries(obs-browser PRIVATE optimized CEF::Wrapper CEF::Library
d3d11 dxgi)
target_link_libraries(obs-browser PRIVATE CEF::Library d3d11 dxgi)

if(TARGET CEF::Wrapper_Debug)
target_link_libraries(obs-browser PRIVATE optimized CEF::Wrapper)
target_link_libraries(obs-browser PRIVATE debug CEF::Wrapper_Debug)
else()
target_link_libraries(obs-browser PRIVATE CEF::Wrapper)
endif()

target_link_options(obs-browser PRIVATE "LINKER:/IGNORE:4099")
Expand Down

0 comments on commit a6df681

Please sign in to comment.