From 376170d7dd4befd555682c6a127076ac3efc3ad7 Mon Sep 17 00:00:00 2001 From: Jonathan Thomas Date: Mon, 1 Jul 2019 12:24:50 -0500 Subject: [PATCH 1/2] Merging work from @ferdnyc, to move version info to CMake, and other misc Cmake improvements. This was the easiest way to resolve the merge conflict for me (to apply it locally and commit it). --- CMakeLists.txt | 72 +++++++++++++-------- include/OpenShot.h | 2 +- include/{Version.h => OpenShotVersion.h.in} | 20 +++--- include/Tests.h | 38 ----------- src/CMakeLists.txt | 5 +- src/bindings/python/openshot.i | 4 +- src/bindings/ruby/CMakeLists.txt | 2 + src/bindings/ruby/openshot.i | 4 +- tests/CMakeLists.txt | 3 + tests/Clip_Tests.cpp | 1 - tests/FFmpegReader_Tests.cpp | 1 - tests/FFmpegWriter_Tests.cpp | 1 - tests/FrameMapper_Tests.cpp | 1 - tests/ImageWriter_Tests.cpp | 3 +- tests/Timeline_Tests.cpp | 1 - 15 files changed, 68 insertions(+), 90 deletions(-) rename include/{Version.h => OpenShotVersion.h.in} (68%) delete mode 100644 include/Tests.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 03c5a761..bd063371 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,41 +38,29 @@ For more information, please visit . ################ ADD CMAKE MODULES ################## set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules") +# Define install paths according to system conventions +include(GNUInstallDirs) -################ GET VERSION INFORMATION FROM VERSION.H ################## -message(STATUS "Determining Version Number (from Version.h file)") +################ PROJECT VERSION #################### +set(PROJECT_VERSION_FULL "0.2.3-dev1") +set(PROJECT_SO_VERSION 17) -#### Get the lines related to libopenshot version from the Version.h header -file(STRINGS ${CMAKE_CURRENT_SOURCE_DIR}/include/Version.h - OPENSHOT_VERSION_LINES - REGEX "#define[ ]+OPENSHOT_VERSION_.*[0-9]+;.*") - -#### Set each line into it's own variable -list (GET OPENSHOT_VERSION_LINES 0 LINE_MAJOR) -list (GET OPENSHOT_VERSION_LINES 1 LINE_MINOR) -list (GET OPENSHOT_VERSION_LINES 2 LINE_BUILD) -list (GET OPENSHOT_VERSION_LINES 3 LINE_SO) - -#### Get the version number out of each line -STRING(REGEX REPLACE "#define[ ]+OPENSHOT_VERSION_MAJOR[ ]+([0-9]+);(.*)" "\\1" MAJOR_VERSION "${LINE_MAJOR}") -STRING(REGEX REPLACE "#define[ ]+OPENSHOT_VERSION_MINOR[ ]+([0-9]+);(.*)" "\\1" MINOR_VERSION "${LINE_MINOR}") -STRING(REGEX REPLACE "#define[ ]+OPENSHOT_VERSION_BUILD[ ]+([0-9]+);(.*)" "\\1" BUILD_VERSION "${LINE_BUILD}") -STRING(REGEX REPLACE "#define[ ]+OPENSHOT_VERSION_SO[ ]+([0-9]+);(.*)" "\\1" SO_VERSION "${LINE_SO}") - -message(STATUS "MAJOR Version: ${MAJOR_VERSION}") -message(STATUS "MINOR Version: ${MINOR_VERSION}") -message(STATUS "BUILD Version: ${BUILD_VERSION}") -message(STATUS "SO/API/ABI Version: ${SO_VERSION}") -message(STATUS "Determining Version Number - done") +# Remove the dash and anything following, to get the #.#.# version for project() +STRING(REGEX REPLACE "\-.*$" "" VERSION_NUM "${PROJECT_VERSION_FULL}") ################### SETUP PROJECT ################### -PROJECT(libopenshot LANGUAGES C CXX - VERSION ${MAJOR_VERSION}.${MINOR_VERSION}.${BUILD_VERSION}) +# This will define the following variables +# PROJECT_NAME +# PROJECT_VERSION, libopenshot_VERSION +# PROJECT_VERSION_MAJOR, libopenshot_VERSION_MAJOR +# PROJECT_VERSION_MINOR, libopenshot_VERSION_MINOR +# PROJECT_VERSION_PATCH, libopenshot_VERSION_PATCH +PROJECT(libopenshot LANGUAGES C CXX VERSION ${VERSION_NUM}) message(" Generating build files for OpenShot Building ${PROJECT_NAME} (version ${PROJECT_VERSION}) - SO/API/ABI Version: ${SO_VERSION} + SO/API/ABI Version: ${PROJECT_SO_VERSION} ") #### Work around a GCC < 9 bug with handling of _Pragma() in macros @@ -82,6 +70,34 @@ if ((${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") AND set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -no-integrated-cpp") 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) + + +############### Set up include paths ################# +list(APPEND OPENSHOT_INCLUDE_DIRS + include + include/effects + include/Qt + ${CMAKE_CURRENT_BINARY_DIR}/include ) + +########## 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) + + +############### Set up include paths ################# +list(APPEND OPENSHOT_INCLUDE_DIRS + include + include/effects + include/Qt + ${CMAKE_CURRENT_BINARY_DIR}/include ) + #### Enable C++11 (for std::shared_ptr support) set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) @@ -104,4 +120,4 @@ add_subdirectory(tests) include(cmake/Modules/UseDoxygen.cmake) file(GLOB_RECURSE doc_files ${CMAKE_CURRENT_BINARY_DIR}/doc/html/*.*) -INSTALL(FILES ${doc_files} DESTINATION share/doc/libopenshot) +INSTALL(FILES ${doc_files} DESTINATION ${CMAKE_INSTALL_DOCDIR}) diff --git a/include/OpenShot.h b/include/OpenShot.h index fb53164c..c5778f99 100644 --- a/include/OpenShot.h +++ b/include/OpenShot.h @@ -96,7 +96,7 @@ */ // Include the version number of OpenShot Library -#include "Version.h" +#include "OpenShotVersion.h" // Include all other classes #include "AudioBufferSource.h" diff --git a/include/Version.h b/include/OpenShotVersion.h.in similarity index 68% rename from include/Version.h rename to include/OpenShotVersion.h.in index ec9e94a6..89f4ed52 100644 --- a/include/Version.h +++ b/include/OpenShotVersion.h.in @@ -31,18 +31,16 @@ #ifndef OPENSHOT_VERSION_H #define OPENSHOT_VERSION_H -// Crazy c++ macro to convert an integer into a string -#ifndef STRINGIZE - #define STRINGIZE_(x) #x - #define STRINGIZE(x) STRINGIZE_(x) -#endif +#define OPENSHOT_VERSION_ALL "@PROJECT_VERSION@" /// A string of the entire version "Major.Minor.Build" +#define OPENSHOT_VERSION_FULL "@PROJECT_VERSION_FULL@" /// A string of the full version identifier, including suffixes (e.g. "0.0.0-dev0") -#define OPENSHOT_VERSION_MAJOR 0; /// Major version number is incremented when huge features are added or improved. -#define OPENSHOT_VERSION_MINOR 2; /// Minor version is incremented when smaller (but still very important) improvements are added. -#define OPENSHOT_VERSION_BUILD 3; /// Build number is incremented when minor bug fixes and less important improvements are added. -#define OPENSHOT_VERSION_SO 17; /// Shared object version number. This increments any time the API and ABI changes (so old apps will no longer link) -#define OPENSHOT_VERSION_MAJOR_MINOR STRINGIZE(OPENSHOT_VERSION_MAJOR) "." STRINGIZE(OPENSHOT_VERSION_MINOR); /// A string of the "Major.Minor" version -#define OPENSHOT_VERSION_ALL STRINGIZE(OPENSHOT_VERSION_MAJOR) "." STRINGIZE(OPENSHOT_VERSION_MINOR) "." STRINGIZE(OPENSHOT_VERSION_BUILD); /// A string of the entire version "Major.Minor.Build" +#define OPENSHOT_VERSION_MAJOR_MINOR "@PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@" /// A string of the "Major.Minor" version + +#define OPENSHOT_VERSION_MAJOR @PROJECT_VERSION_MAJOR@ /// Major version number is incremented when huge features are added or improved. +#define OPENSHOT_VERSION_MINOR @PROJECT_VERSION_MINOR@ /// Minor version is incremented when smaller (but still very important) improvements are added. +#define OPENSHOT_VERSION_BUILD @PROJECT_VERSION_PATCH@ /// Build number is incremented when minor bug fixes and less important improvements are added. + +#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) #include using namespace std; diff --git a/include/Tests.h b/include/Tests.h deleted file mode 100644 index b647cb0e..00000000 --- a/include/Tests.h +++ /dev/null @@ -1,38 +0,0 @@ -/** - * @file - * @brief Header file for UnitTests - * @author Jonathan Thomas - * - * @ref License - */ - -/* LICENSE - * - * Copyright (c) 2008-2019 OpenShot Studios, LLC - * . This file is part of - * OpenShot Library (libopenshot), an open-source project dedicated to - * delivering high quality video editing and animation solutions to the - * world. For more information visit . - * - * OpenShot Library (libopenshot) is free software: you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * OpenShot Library (libopenshot) is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with OpenShot Library. If not, see . - */ - -#ifndef OPENSHOT_UNITTESTS_H -#define OPENSHOT_UNITTESTS_H - - #ifndef TEST_MEDIA_PATH - #define TEST_MEDIA_PATH "../../src/examples/" - #endif - -#endif diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3dd38a29..9f5b3f5f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -24,6 +24,9 @@ # along with OpenShot Library. If not, see . ################################################################################ +# Pick up our include directories from the parent context +include_directories(${OPENSHOT_INCLUDE_DIRS}) + ################ OPTIONS ################## # Optional build settings for libopenshot OPTION(USE_SYSTEM_JSONCPP "Use system installed JsonCpp" OFF) @@ -299,7 +302,7 @@ add_library(openshot SHARED set_target_properties(openshot PROPERTIES VERSION ${PROJECT_VERSION} - SOVERSION ${SO_VERSION} + SOVERSION ${PROJECT_SO_VERSION} INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib" ) diff --git a/src/bindings/python/openshot.i b/src/bindings/python/openshot.i index 74d2705b..af1abb74 100644 --- a/src/bindings/python/openshot.i +++ b/src/bindings/python/openshot.i @@ -53,7 +53,7 @@ %shared_ptr(Frame) %{ -#include "../../../include/Version.h" +#include "OpenShotVersion.h" #include "../../../include/ReaderBase.h" #include "../../../include/WriterBase.h" #include "../../../include/CacheBase.h" @@ -117,7 +117,7 @@ } } -%include "../../../include/Version.h" +%include "OpenShotVersion.h" %include "../../../include/ReaderBase.h" %include "../../../include/WriterBase.h" %include "../../../include/CacheBase.h" diff --git a/src/bindings/ruby/CMakeLists.txt b/src/bindings/ruby/CMakeLists.txt index e0987ca4..db3655fb 100644 --- a/src/bindings/ruby/CMakeLists.txt +++ b/src/bindings/ruby/CMakeLists.txt @@ -24,6 +24,8 @@ # along with OpenShot Library. If not, see . ################################################################################ +# Pick up our include directories from the parent context +include_directories(${OPENSHOT_INCLUDE_DIRS}) ############### RUBY BINDINGS ################ FIND_PACKAGE(SWIG 2.0 REQUIRED) diff --git a/src/bindings/ruby/openshot.i b/src/bindings/ruby/openshot.i index 775421b6..ab11ae7f 100644 --- a/src/bindings/ruby/openshot.i +++ b/src/bindings/ruby/openshot.i @@ -65,7 +65,7 @@ namespace std { #define RB_RSHIFT(a, b) RSHIFT(a, b) #undef RSHIFT #endif -#include "../../../include/Version.h" +#include "OpenShotVersion.h" #include "../../../include/ReaderBase.h" #include "../../../include/WriterBase.h" #include "../../../include/CacheBase.h" @@ -127,7 +127,7 @@ namespace std { %} #endif -%include "../../../include/Version.h" +%include "OpenShotVersion.h" %include "../../../include/ReaderBase.h" %include "../../../include/WriterBase.h" %include "../../../include/CacheBase.h" diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index b1782774..caefffb0 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -24,6 +24,9 @@ # along with OpenShot Library. If not, see . ################################################################################ +# Pick up our include directories from the parent context +include_directories(${OPENSHOT_INCLUDE_DIRS}) + SET(TEST_MEDIA_PATH "${PROJECT_SOURCE_DIR}/src/examples/") ################ WINDOWS ################## diff --git a/tests/Clip_Tests.cpp b/tests/Clip_Tests.cpp index c77e44b6..6c60bedd 100644 --- a/tests/Clip_Tests.cpp +++ b/tests/Clip_Tests.cpp @@ -30,7 +30,6 @@ #include "UnitTest++.h" #include "../include/OpenShot.h" -#include "../include/Tests.h" using namespace std; using namespace openshot; diff --git a/tests/FFmpegReader_Tests.cpp b/tests/FFmpegReader_Tests.cpp index 4ef570ae..68aba4bb 100644 --- a/tests/FFmpegReader_Tests.cpp +++ b/tests/FFmpegReader_Tests.cpp @@ -30,7 +30,6 @@ #include "UnitTest++.h" #include "../include/OpenShot.h" -#include "../include/Tests.h" using namespace std; using namespace openshot; diff --git a/tests/FFmpegWriter_Tests.cpp b/tests/FFmpegWriter_Tests.cpp index 53a9cbf2..8cb10e15 100644 --- a/tests/FFmpegWriter_Tests.cpp +++ b/tests/FFmpegWriter_Tests.cpp @@ -30,7 +30,6 @@ #include "UnitTest++.h" #include "../include/OpenShot.h" -#include "../include/Tests.h" using namespace std; using namespace openshot; diff --git a/tests/FrameMapper_Tests.cpp b/tests/FrameMapper_Tests.cpp index ce43fc20..f400d830 100644 --- a/tests/FrameMapper_Tests.cpp +++ b/tests/FrameMapper_Tests.cpp @@ -30,7 +30,6 @@ #include "UnitTest++.h" #include "../include/OpenShot.h" -#include "../include/Tests.h" using namespace std; using namespace openshot; diff --git a/tests/ImageWriter_Tests.cpp b/tests/ImageWriter_Tests.cpp index d44bbd84..4236b462 100644 --- a/tests/ImageWriter_Tests.cpp +++ b/tests/ImageWriter_Tests.cpp @@ -30,7 +30,6 @@ #include "UnitTest++.h" #include "../include/OpenShot.h" -#include "../include/Tests.h" using namespace std; using namespace openshot; @@ -81,4 +80,4 @@ TEST(ImageWriter_Test_Gif) CHECK_EQUAL(11, (int)pixels[pixel_index + 2]); CHECK_EQUAL(255, (int)pixels[pixel_index + 3]); } -#endif \ No newline at end of file +#endif diff --git a/tests/Timeline_Tests.cpp b/tests/Timeline_Tests.cpp index 1290bee7..0bb42b89 100644 --- a/tests/Timeline_Tests.cpp +++ b/tests/Timeline_Tests.cpp @@ -30,7 +30,6 @@ #include "UnitTest++.h" #include "../include/OpenShot.h" -#include "../include/Tests.h" using namespace std; using namespace openshot; From 4e08ab32c1386366305212875925ab81ed1e257a Mon Sep 17 00:00:00 2001 From: Jonathan Thomas Date: Mon, 1 Jul 2019 12:43:31 -0500 Subject: [PATCH 2/2] Fixing a few more conflicts between this branch and develop --- CMakeLists.txt | 32 +++++--------------------------- 1 file changed, 5 insertions(+), 27 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bd063371..9c468ae0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,8 +38,6 @@ For more information, please visit . ################ ADD CMAKE MODULES ################## set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules") -# Define install paths according to system conventions -include(GNUInstallDirs) ################ PROJECT VERSION #################### set(PROJECT_VERSION_FULL "0.2.3-dev1") @@ -63,12 +61,10 @@ Generating build files for OpenShot SO/API/ABI Version: ${PROJECT_SO_VERSION} ") -#### 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 - (${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS "9.0.0")) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -no-integrated-cpp") -endif() +# Define install paths according to system conventions +# XXX: This must be AFTER THE PROJECT() COMMAND w/ languages enabled, +# in order to properly configure CMAKE_INSTALL_LIBDIR path +include(GNUInstallDirs) ########## Configure Version.h header ############## configure_file(include/OpenShotVersion.h.in include/OpenShotVersion.h @ONLY) @@ -76,21 +72,6 @@ configure_file(include/OpenShotVersion.h.in include/OpenShotVersion.h @ONLY) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/include/OpenShotVersion.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/libopenshot) - -############### Set up include paths ################# -list(APPEND OPENSHOT_INCLUDE_DIRS - include - include/effects - include/Qt - ${CMAKE_CURRENT_BINARY_DIR}/include ) - -########## 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) - - ############### Set up include paths ################# list(APPEND OPENSHOT_INCLUDE_DIRS include @@ -117,7 +98,4 @@ add_subdirectory(tests) ################### DOCUMENTATION ################### # Find Doxygen (used for documentation) -include(cmake/Modules/UseDoxygen.cmake) - -file(GLOB_RECURSE doc_files ${CMAKE_CURRENT_BINARY_DIR}/doc/html/*.*) -INSTALL(FILES ${doc_files} DESTINATION ${CMAKE_INSTALL_DOCDIR}) +include(cmake/Modules/UseDoxygen.cmake) \ No newline at end of file