From 5c688f1edfb9a39f9b89faf333e052d4a8ba01e2 Mon Sep 17 00:00:00 2001 From: "FeRD (Frank Dana)" Date: Thu, 7 May 2020 11:56:44 -0400 Subject: [PATCH] Add QT_VERSION_STR define to OpenShotVersion.h The CMake process will pick up Qt's Qt5Core_VERSION_STRING and stick it in a cache variable (with forced updating each run), and a new `#define` in the header exports it to the library and to the Python bindings so that it can be queried at runtime. --- CMakeLists.txt | 12 ++++++------ include/OpenShotVersion.h.in | 5 ++++- src/CMakeLists.txt | 4 ++++ 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bb3fe8cc..f50c575f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -91,12 +91,6 @@ if(DEFINED ENABLE_TESTS) set(ENABLE_TESTS ${ENABLE_TESTS} CACHE BOOL "Build unit tests (requires UnitTest++)" FORCE) endif() -########## Configure Version.h header ############## -configure_file(include/OpenShotVersion.h.in include/OpenShotVersion.h @ONLY) -# We'll want that installed later -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/include/OpenShotVersion.h - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/libopenshot) - #### Work around a GCC < 9 bug with handling of _Pragma() in macros #### See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55578 if ((${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") AND @@ -142,6 +136,12 @@ endif() ############## PROCESS src/ DIRECTORIES ############## add_subdirectory(src) +########## Configure Version.h header ############## +configure_file(include/OpenShotVersion.h.in include/OpenShotVersion.h @ONLY) +# We'll want that installed later +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/include/OpenShotVersion.h + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/libopenshot) + ################### DOCUMENTATION ################### # Find Doxygen (used for documentation) set(DOCS_ENABLED FALSE) # Only set true if Doxygen is found and configured diff --git a/include/OpenShotVersion.h.in b/include/OpenShotVersion.h.in index e15662b2..d8cf0735 100644 --- a/include/OpenShotVersion.h.in +++ b/include/OpenShotVersion.h.in @@ -42,6 +42,9 @@ #define OPENSHOT_VERSION_SO @PROJECT_SO_VERSION@ /// Shared object version number. This increments any time the API and ABI changes (so old apps will no longer link) +// Useful dependency versioning +#define QT_VERSION_STR "@QT_VERSION_STR@" + #include namespace openshot @@ -67,4 +70,4 @@ namespace openshot openshot::OpenShotVersion GetVersion(); } -#endif // OPENSHOT_VERSION_H \ No newline at end of file +#endif // OPENSHOT_VERSION_H diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 17b73863..24ed7764 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -289,6 +289,10 @@ foreach(_qt_comp IN LISTS _qt_components) endif() endforeach() +# Keep track of Qt version, to embed in our version header +set(QT_VERSION_STR ${Qt5Core_VERSION_STRING} CACHE STRING "Qt version linked with" FORCE) +mark_as_advanced(QT_VERSION_STR) + ################### FFMPEG ##################### # Find FFmpeg libraries (used for video encoding / decoding) find_package(FFmpeg REQUIRED COMPONENTS avcodec avdevice avformat avutil swscale)