libdshowcapture icon indicating copy to clipboard operation
libdshowcapture copied to clipboard

Update CMake

Open RytoEX opened this issue 10 months ago • 1 comments

Description

This PR consists of three commits to make it easier to differentiate between the intended changes. The commits will be squashed, or the second commit can be dropped if we intend to keep support for non-MSVC compilers/toolchains.

Modernize the project's CMake:

  • Update to C/C++17
  • Use targets instead of global set and add calls
  • Assume WIN32 is always the target platform
  • Replace CMake 2.x with CMake 3.x compile language and ID checks
  • Remove unnecessary FindCXX11 module

Updating to C/C++17 is required due to code in the capture-device-support submodule using C++17 features.

Remove support for non-MSVC compilers. Since libdshowcapture is a Windows-only library, supporting GCC, Clang, and MinGW adds extra complication that we otherwise would not have to handle if we only support MSVC. This could be added back in the future if there is a reasonable justification for it.

Reformat CMake with gersemi This matches the CMake formatting preferences in obs-studio.

Motivation and Context

The CMake currently in the repo fails to configure. I figured this was a good opportunity to do some cleanups. This could probably go further, and I do additionally intend to remove the vs folder containing the solution and project files. For now, I wanted to get this off of my local machine and placed here for public comment/review.

How Has This Been Tested?

Tested locally on Windows 11. The CMake configures, generates a solution, and the solution can be built with VS2022.

You should be able to configure and generate a solution with:

cmake -S <libdshowcapture-repo-directory> -B <build-directory>

Then you should be able to open the solution and build it with Visual Studio, or build it via CLI with CMake:

cmake --build <build-directory>

As far as I know, obs-studio itself does not use this repo's CMake, so these changes should not affect usage there.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • Code cleanup (non-breaking change which makes code smaller or more readable)

Checklist:

  • [x] My code has been run through clang-format.
  • [x] I have read the contributing document.
  • [x] My code is not on the master branch.
  • [x] The code has been tested.
  • [x] All commit messages are properly formatted and commits squashed where appropriate.
  • [x] I have included updates to all appropriate documentation.

RytoEX avatar Feb 19 '25 20:02 RytoEX

Looks fine apart from the more specific comments. If this indeed is supposed to require MSVC, then maybe we should provide a FATAL_ERROR message if the MSVC generator is not used.

Done.

RytoEX avatar Mar 04 '25 00:03 RytoEX