OpenShot / libopenshot-audio

OpenShot Audio Library (libopenshot-audio) is a free, open-source project that enables high-quality editing and playback of audio, and is based on the amazing JUCE library.
http://www.openshot.org
GNU General Public License v3.0
253 stars 100 forks source link

CMake: Create and install EXPORTED configuration #118

Closed ferdnyc closed 3 years ago

ferdnyc commented 3 years ago

This PR changes the build system in several ways:

  1. The CMake Project is renamed to "OpenShotAudio", which better conforms to CMake naming conventions. (The openshot-audio library target name and libopenshot-audio library name are unchanged, internally.)
  2. The main installed header file has been renamed from JuceHeader.h to OpenShotAudio.h. A copy (or symlink, depending on CMake version and OS capabilities) under the old name is still installed for compatibility, but should be considered legacy. Any references to JuceHeader.h in downstream code (including libopenshot) should be changed to OpenShotAudio.h at the earliest convenience.
  3. The build now creates a standard CMake EXPORTED configuration which defines all relevant parameters for the build output, both in the build tree and in any subsequent install tree. This makes the FindOpenShotAudio.cmake file in libopenshot's build unnecessary, and represents a more complete and robust method of establishing a dependency relationship with library consumers. All of the information needed to build projects that link with libopenshot-audio are written to the new OpenShotAudio-Config.cmake and OpenShotAudioTargets.cmake output files.
  4. Externally, in keeping with CMake conventions, the library target is EXPORTED as OpenShot::Audio, and should be referred to that way by consumers:
    find_package(OpenShotAudio)
    target_link_libraries(openshot PUBLIC OpenShot::Audio)
  5. ASIO SDK discovery on Windows platforms is moved from inline code to a FindASIO.cmake module, which is also included in the EXPORTED configuration for use by downstream library consumers.
  6. The simple openshot-audio-test-sound program has been renamed to openshot-audio-demo, and is completely rewritten in a more modern code style, making better use of C++11 STL classes and idioms. The function of the tool has also been enhanced to make better use of the JUCE capabilities required by libopenshot: A list of all discovered audio devices present on the system is first generated and displayed, before a test tone plays on the default output. (Actually, 5 test tones, precisely 2 seconds apart. deviceManager.playTestSound() in recent JUCE releases triggers only a brief "beep" on each call, rather than playing a continuous tone, so I took the opportunity to demonstrate std::this_thread::sleep_until and the std::chrono timer classes.) The binary's configuration is also included in the EXPORTED data, and may be referenced downstream as the OpenShot::openshot-audio-demo target.
ferdnyc commented 3 years ago

Merging this, as it's needed to get builds back on track. It should be fully backwards-compatible with older configs, anyway. (The FindOpenShotAudio.cmake module will still work to discover it...)