Skip to content

Commit 19d8868

Browse files
authored
Merge pull request #263 from OpenShot/cmake-owns-version
Move version info ownership to CMake (based on @ferdnyc PR #253)
2 parents 1e00618 + 4e08ab3 commit 19d8868

15 files changed

+55
-100
lines changed

CMakeLists.txt

Lines changed: 31 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -39,49 +39,45 @@ For more information, please visit <http://www.openshot.org/>.
3939
################ ADD CMAKE MODULES ##################
4040
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules")
4141

42-
################ GET VERSION INFORMATION FROM VERSION.H ##################
43-
message(STATUS "Determining Version Number (from Version.h file)")
42+
################ PROJECT VERSION ####################
43+
set(PROJECT_VERSION_FULL "0.2.3-dev1")
44+
set(PROJECT_SO_VERSION 17)
4445

45-
#### Get the lines related to libopenshot version from the Version.h header
46-
file(STRINGS ${CMAKE_CURRENT_SOURCE_DIR}/include/Version.h
47-
OPENSHOT_VERSION_LINES
48-
REGEX "#define[ ]+OPENSHOT_VERSION_.*[0-9]+;.*")
49-
50-
#### Set each line into its own variable
51-
52-
list (GET OPENSHOT_VERSION_LINES 0 LINE_MAJOR)
53-
list (GET OPENSHOT_VERSION_LINES 1 LINE_MINOR)
54-
list (GET OPENSHOT_VERSION_LINES 2 LINE_BUILD)
55-
list (GET OPENSHOT_VERSION_LINES 3 LINE_SO)
56-
57-
#### Get the version number out of each line
58-
STRING(REGEX REPLACE "#define[ ]+OPENSHOT_VERSION_MAJOR[ ]+([0-9]+);(.*)" "\\1" MAJOR_VERSION "${LINE_MAJOR}")
59-
STRING(REGEX REPLACE "#define[ ]+OPENSHOT_VERSION_MINOR[ ]+([0-9]+);(.*)" "\\1" MINOR_VERSION "${LINE_MINOR}")
60-
STRING(REGEX REPLACE "#define[ ]+OPENSHOT_VERSION_BUILD[ ]+([0-9]+);(.*)" "\\1" BUILD_VERSION "${LINE_BUILD}")
61-
STRING(REGEX REPLACE "#define[ ]+OPENSHOT_VERSION_SO[ ]+([0-9]+);(.*)" "\\1" SO_VERSION "${LINE_SO}")
62-
63-
message(STATUS "MAJOR Version: ${MAJOR_VERSION}")
64-
message(STATUS "MINOR Version: ${MINOR_VERSION}")
65-
message(STATUS "BUILD Version: ${BUILD_VERSION}")
66-
message(STATUS "SO/API/ABI Version: ${SO_VERSION}")
67-
message(STATUS "Determining Version Number - done")
46+
# Remove the dash and anything following, to get the #.#.# version for project()
47+
STRING(REGEX REPLACE "\-.*$" "" VERSION_NUM "${PROJECT_VERSION_FULL}")
6848

6949
################### SETUP PROJECT ###################
70-
PROJECT(libopenshot LANGUAGES C CXX
71-
VERSION ${MAJOR_VERSION}.${MINOR_VERSION}.${BUILD_VERSION})
50+
# This will define the following variables
51+
# PROJECT_NAME
52+
# PROJECT_VERSION, libopenshot_VERSION
53+
# PROJECT_VERSION_MAJOR, libopenshot_VERSION_MAJOR
54+
# PROJECT_VERSION_MINOR, libopenshot_VERSION_MINOR
55+
# PROJECT_VERSION_PATCH, libopenshot_VERSION_PATCH
56+
PROJECT(libopenshot LANGUAGES C CXX VERSION ${VERSION_NUM})
7257

7358
message("
7459
Generating build files for OpenShot
7560
Building ${PROJECT_NAME} (version ${PROJECT_VERSION})
76-
SO/API/ABI Version: ${SO_VERSION}
61+
SO/API/ABI Version: ${PROJECT_SO_VERSION}
7762
")
7863

79-
#### Work around a GCC < 9 bug with handling of _Pragma() in macros
80-
#### See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55578
81-
if ((${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") AND
82-
(${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS "9.0.0"))
83-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -no-integrated-cpp")
84-
endif()
64+
# Define install paths according to system conventions
65+
# XXX: This must be AFTER THE PROJECT() COMMAND w/ languages enabled,
66+
# in order to properly configure CMAKE_INSTALL_LIBDIR path
67+
include(GNUInstallDirs)
68+
69+
########## Configure Version.h header ##############
70+
configure_file(include/OpenShotVersion.h.in include/OpenShotVersion.h @ONLY)
71+
# We'll want that installed later
72+
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/include/OpenShotVersion.h
73+
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/libopenshot)
74+
75+
############### Set up include paths #################
76+
list(APPEND OPENSHOT_INCLUDE_DIRS
77+
include
78+
include/effects
79+
include/Qt
80+
${CMAKE_CURRENT_BINARY_DIR}/include )
8581

8682
#### Enable C++11 (for std::shared_ptr support)
8783
set(CMAKE_CXX_STANDARD 11)
@@ -102,7 +98,4 @@ add_subdirectory(tests)
10298

10399
################### DOCUMENTATION ###################
104100
# Find Doxygen (used for documentation)
105-
include(cmake/Modules/UseDoxygen.cmake)
106-
107-
file(GLOB_RECURSE doc_files ${CMAKE_CURRENT_BINARY_DIR}/doc/html/*.*)
108-
INSTALL(FILES ${doc_files} DESTINATION share/doc/libopenshot)
101+
include(cmake/Modules/UseDoxygen.cmake)

include/OpenShot.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
*/
9797

9898
// Include the version number of OpenShot Library
99-
#include "Version.h"
99+
#include "OpenShotVersion.h"
100100

101101
// Include all other classes
102102
#include "AudioBufferSource.h"

include/Version.h renamed to include/OpenShotVersion.h.in

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,16 @@
3131
#ifndef OPENSHOT_VERSION_H
3232
#define OPENSHOT_VERSION_H
3333

34-
// Crazy c++ macro to convert an integer into a string
35-
#ifndef STRINGIZE
36-
#define STRINGIZE_(x) #x
37-
#define STRINGIZE(x) STRINGIZE_(x)
38-
#endif
34+
#define OPENSHOT_VERSION_ALL "@PROJECT_VERSION@" /// A string of the entire version "Major.Minor.Build"
35+
#define OPENSHOT_VERSION_FULL "@PROJECT_VERSION_FULL@" /// A string of the full version identifier, including suffixes (e.g. "0.0.0-dev0")
36+
37+
#define OPENSHOT_VERSION_MAJOR_MINOR "@PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@" /// A string of the "Major.Minor" version
38+
39+
#define OPENSHOT_VERSION_MAJOR @PROJECT_VERSION_MAJOR@ /// Major version number is incremented when huge features are added or improved.
40+
#define OPENSHOT_VERSION_MINOR @PROJECT_VERSION_MINOR@ /// Minor version is incremented when smaller (but still very important) improvements are added.
41+
#define OPENSHOT_VERSION_BUILD @PROJECT_VERSION_PATCH@ /// Build number is incremented when minor bug fixes and less important improvements are added.
3942

40-
#define OPENSHOT_VERSION_MAJOR 0; /// Major version number is incremented when huge features are added or improved.
41-
#define OPENSHOT_VERSION_MINOR 2; /// Minor version is incremented when smaller (but still very important) improvements are added.
42-
#define OPENSHOT_VERSION_BUILD 3; /// Build number is incremented when minor bug fixes and less important improvements are added.
43-
#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)
44-
#define OPENSHOT_VERSION_MAJOR_MINOR STRINGIZE(OPENSHOT_VERSION_MAJOR) "." STRINGIZE(OPENSHOT_VERSION_MINOR); /// A string of the "Major.Minor" version
45-
#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"
43+
#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)
4644

4745
#include <sstream>
4846
using namespace std;

include/Tests.h

Lines changed: 0 additions & 38 deletions
This file was deleted.

src/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
# along with OpenShot Library. If not, see <http://www.gnu.org/licenses/>.
2525
################################################################################
2626

27+
# Pick up our include directories from the parent context
28+
include_directories(${OPENSHOT_INCLUDE_DIRS})
29+
2730
################ OPTIONS ##################
2831
# Optional build settings for libopenshot
2932
OPTION(USE_SYSTEM_JSONCPP "Use system installed JsonCpp" OFF)
@@ -299,7 +302,7 @@ add_library(openshot SHARED
299302
set_target_properties(openshot
300303
PROPERTIES
301304
VERSION ${PROJECT_VERSION}
302-
SOVERSION ${SO_VERSION}
305+
SOVERSION ${PROJECT_SO_VERSION}
303306
INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib"
304307
)
305308

src/bindings/python/openshot.i

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
%shared_ptr(Frame)
5454

5555
%{
56-
#include "../../../include/Version.h"
56+
#include "OpenShotVersion.h"
5757
#include "../../../include/ReaderBase.h"
5858
#include "../../../include/WriterBase.h"
5959
#include "../../../include/CacheBase.h"
@@ -117,7 +117,7 @@
117117
}
118118
}
119119

120-
%include "../../../include/Version.h"
120+
%include "OpenShotVersion.h"
121121
%include "../../../include/ReaderBase.h"
122122
%include "../../../include/WriterBase.h"
123123
%include "../../../include/CacheBase.h"

src/bindings/ruby/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
# along with OpenShot Library. If not, see <http://www.gnu.org/licenses/>.
2525
################################################################################
2626

27+
# Pick up our include directories from the parent context
28+
include_directories(${OPENSHOT_INCLUDE_DIRS})
2729

2830
############### RUBY BINDINGS ################
2931
FIND_PACKAGE(SWIG 2.0 REQUIRED)

src/bindings/ruby/openshot.i

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ namespace std {
6565
#define RB_RSHIFT(a, b) RSHIFT(a, b)
6666
#undef RSHIFT
6767
#endif
68-
#include "../../../include/Version.h"
68+
#include "OpenShotVersion.h"
6969
#include "../../../include/ReaderBase.h"
7070
#include "../../../include/WriterBase.h"
7171
#include "../../../include/CacheBase.h"
@@ -127,7 +127,7 @@ namespace std {
127127
%}
128128
#endif
129129

130-
%include "../../../include/Version.h"
130+
%include "OpenShotVersion.h"
131131
%include "../../../include/ReaderBase.h"
132132
%include "../../../include/WriterBase.h"
133133
%include "../../../include/CacheBase.h"

tests/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
# along with OpenShot Library. If not, see <http://www.gnu.org/licenses/>.
2525
################################################################################
2626

27+
# Pick up our include directories from the parent context
28+
include_directories(${OPENSHOT_INCLUDE_DIRS})
29+
2730
SET(TEST_MEDIA_PATH "${PROJECT_SOURCE_DIR}/src/examples/")
2831

2932
################ WINDOWS ##################

tests/Clip_Tests.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030

3131
#include "UnitTest++.h"
3232
#include "../include/OpenShot.h"
33-
#include "../include/Tests.h"
3433

3534
using namespace std;
3635
using namespace openshot;

0 commit comments

Comments
 (0)