Skip to content

Commit 376170d

Browse files
committed
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).
1 parent 67794f9 commit 376170d

15 files changed

+68
-90
lines changed

CMakeLists.txt

Lines changed: 44 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -38,41 +38,29 @@ For more information, please visit <http://www.openshot.org/>.
3838

3939
################ ADD CMAKE MODULES ##################
4040
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules")
41+
# Define install paths according to system conventions
42+
include(GNUInstallDirs)
4143

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

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 it's own variable
51-
list (GET OPENSHOT_VERSION_LINES 0 LINE_MAJOR)
52-
list (GET OPENSHOT_VERSION_LINES 1 LINE_MINOR)
53-
list (GET OPENSHOT_VERSION_LINES 2 LINE_BUILD)
54-
list (GET OPENSHOT_VERSION_LINES 3 LINE_SO)
55-
56-
#### Get the version number out of each line
57-
STRING(REGEX REPLACE "#define[ ]+OPENSHOT_VERSION_MAJOR[ ]+([0-9]+);(.*)" "\\1" MAJOR_VERSION "${LINE_MAJOR}")
58-
STRING(REGEX REPLACE "#define[ ]+OPENSHOT_VERSION_MINOR[ ]+([0-9]+);(.*)" "\\1" MINOR_VERSION "${LINE_MINOR}")
59-
STRING(REGEX REPLACE "#define[ ]+OPENSHOT_VERSION_BUILD[ ]+([0-9]+);(.*)" "\\1" BUILD_VERSION "${LINE_BUILD}")
60-
STRING(REGEX REPLACE "#define[ ]+OPENSHOT_VERSION_SO[ ]+([0-9]+);(.*)" "\\1" SO_VERSION "${LINE_SO}")
61-
62-
message(STATUS "MAJOR Version: ${MAJOR_VERSION}")
63-
message(STATUS "MINOR Version: ${MINOR_VERSION}")
64-
message(STATUS "BUILD Version: ${BUILD_VERSION}")
65-
message(STATUS "SO/API/ABI Version: ${SO_VERSION}")
66-
message(STATUS "Determining Version Number - done")
48+
# Remove the dash and anything following, to get the #.#.# version for project()
49+
STRING(REGEX REPLACE "\-.*$" "" VERSION_NUM "${PROJECT_VERSION_FULL}")
6750

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

7260
message("
7361
Generating build files for OpenShot
7462
Building ${PROJECT_NAME} (version ${PROJECT_VERSION})
75-
SO/API/ABI Version: ${SO_VERSION}
63+
SO/API/ABI Version: ${PROJECT_SO_VERSION}
7664
")
7765

7866
#### Work around a GCC < 9 bug with handling of _Pragma() in macros
@@ -82,6 +70,34 @@ if ((${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") AND
8270
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -no-integrated-cpp")
8371
endif()
8472

73+
########## Configure Version.h header ##############
74+
configure_file(include/OpenShotVersion.h.in include/OpenShotVersion.h @ONLY)
75+
# We'll want that installed later
76+
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/include/OpenShotVersion.h
77+
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/libopenshot)
78+
79+
80+
############### Set up include paths #################
81+
list(APPEND OPENSHOT_INCLUDE_DIRS
82+
include
83+
include/effects
84+
include/Qt
85+
${CMAKE_CURRENT_BINARY_DIR}/include )
86+
87+
########## Configure Version.h header ##############
88+
configure_file(include/OpenShotVersion.h.in include/OpenShotVersion.h @ONLY)
89+
# We'll want that installed later
90+
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/include/OpenShotVersion.h
91+
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/libopenshot)
92+
93+
94+
############### Set up include paths #################
95+
list(APPEND OPENSHOT_INCLUDE_DIRS
96+
include
97+
include/effects
98+
include/Qt
99+
${CMAKE_CURRENT_BINARY_DIR}/include )
100+
85101
#### Enable C++11 (for std::shared_ptr support)
86102
set(CMAKE_CXX_STANDARD 11)
87103
set(CMAKE_CXX_STANDARD_REQUIRED ON)
@@ -104,4 +120,4 @@ add_subdirectory(tests)
104120
include(cmake/Modules/UseDoxygen.cmake)
105121

106122
file(GLOB_RECURSE doc_files ${CMAKE_CURRENT_BINARY_DIR}/doc/html/*.*)
107-
INSTALL(FILES ${doc_files} DESTINATION share/doc/libopenshot)
123+
INSTALL(FILES ${doc_files} DESTINATION ${CMAKE_INSTALL_DOCDIR})

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)