obs-studio/UI/cmake/os-windows.cmake
PatTheMav 2966c4030e libobs: Use static library for version string information
Switching to a static library that contains version information as
const char strings has multiple benefits:

* The version information provided externally via compiler definitions
  will fail compilation early if malformed
* An updated version string (which will happen with every commit) will
  not invalidate existing compilation units, because only the static
  library is affected by the change
* An update of the version change just requires a recompilation of the
  static library and a linker update
* An update of the version will _not_ infect the rest of the codebase
  (as it does currently, because everything includes obsconfig.h one
  way or another)
* Other modules which used the macro definition directly have been
  updated as much as possible to use the proper getter method from
  `libobs` instead (some Windows-specific modules use preprocessor
  string composition, the value has been added as a compiler definition
  directly in those cases)
* Because the impact of a version change due to a commit hash change
  is limited to the static library, ccache hit rates should be
  improved considerably
2023-05-27 16:48:24 -07:00

56 lines
2 KiB
CMake

if(NOT TARGET OBS::blake2)
add_subdirectory("${CMAKE_SOURCE_DIR}/deps/blake2" "${CMAKE_BINARY_DIR}/deps/blake2")
endif()
if(NOT TARGET OBS::w32-pthreads)
add_subdirectory("${CMAKE_SOURCE_DIR}/deps/w32-pthreads" "${CMAKE_BINARY_DIR}/deps/w32-pthreads")
endif()
find_package(MbedTLS)
find_package(Detours REQUIRED)
configure_file(cmake/windows/obs.rc.in obs.rc)
target_sources(
obs-studio
PRIVATE obs.rc
platform-windows.cpp
win-dll-blocklist.c
cmake/windows/obs.manifest
update/crypto-helpers-mbedtls.cpp
update/crypto-helpers.hpp
update/shared-update.cpp
update/shared-update.hpp
update/update-helpers.cpp
update/update-helpers.hpp
update/update-window.cpp
update/update-window.hpp
update/win-update.cpp
update/win-update.hpp)
target_link_libraries(obs-studio PRIVATE crypt32 OBS::blake2 OBS::w32-pthreads MbedTLS::MbedTLS Detours::Detours)
target_compile_options(obs-studio PRIVATE PSAPI_VERSION=2)
target_link_options(obs-studio PRIVATE /IGNORE:4098 /IGNORE:4099)
add_library(obs-update-helpers INTERFACE)
add_library(OBS::update-helpers ALIAS obs-update-helpers)
target_sources(obs-update-helpers INTERFACE win-update/win-update-helpers.cpp win-update/win-update-helpers.hpp)
target_include_directories(obs-update-helpers INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/win-update")
set_source_files_properties(update/win-update.cpp PROPERTIES COMPILE_DEFINITIONS OBS_COMMIT="${OBS_COMMIT}")
add_subdirectory(win-update/updater)
set_property(
TARGET obs-studio
APPEND
PROPERTY AUTORCC_OPTIONS --format-version 1)
set_property(DIRECTORY ${CMAKE_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT obs-studio)
set_target_properties(
obs-studio
PROPERTIES
WIN32_EXECUTABLE TRUE
VS_DEBUGGER_COMMAND
"${CMAKE_BINARY_DIR}/rundir/$<CONFIG>/$<$<BOOL:${OBS_WINDOWS_LEGACY_DIRS}>:bin/>$<TARGET_FILE_NAME:obs-studio>"
VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/rundir/$<CONFIG>$<$<BOOL:${OBS_WINDOWS_LEGACY_DIRS}>:/bin>")