Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@ cmake_minimum_required(VERSION 3.18.2)
# Project Metadata
# TODO: read this information from a configuration file, here, and in setup.py

set(OTIO_VERSION_MAJOR "0")
set(OTIO_VERSION_MINOR "19")
set(OTIO_VERSION_PATCH "0")
file(READ "src/opentimelineio/version.h" VERSION_H)
string(REGEX MATCH "VERSION_MAJOR ([0-9]*)" _ ${VERSION_H})
set(OTIO_VERSION_MAJOR ${CMAKE_MATCH_1})
string(REGEX MATCH "VERSION_MINOR ([0-9]*)" _ ${VERSION_H})
set(OTIO_VERSION_MINOR ${CMAKE_MATCH_1})
string(REGEX MATCH "VERSION_PATCH ([0-9]*)" _ ${VERSION_H})
set(OTIO_VERSION_PATCH ${CMAKE_MATCH_1})
set(OTIO_VERSION ${OTIO_VERSION_MAJOR}.${OTIO_VERSION_MINOR}.${OTIO_VERSION_PATCH})

set(OTIO_AUTHOR "Contributors to the OpenTimelineIO project")
Expand Down
22 changes: 3 additions & 19 deletions src/opentime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ set(OPENTIME_HEADER_FILES
rationalTime.h
stringPrintf.h
timeRange.h
timeTransform.h)
timeTransform.h
version.h)

add_library(opentime ${OTIO_SHARED_OR_STATIC_LIB}
errorStatus.cpp
Expand All @@ -16,12 +17,7 @@ add_library(opentime ${OTIO_SHARED_OR_STATIC_LIB}

add_library(OTIO::opentime ALIAS opentime)

target_include_directories(
opentime
PRIVATE
"${PROJECT_SOURCE_DIR}/src"
"${CMAKE_CURRENT_BINARY_DIR}/.."
)
target_include_directories(opentime PRIVATE "${PROJECT_SOURCE_DIR}/src")

set_target_properties(opentime PROPERTIES
DEBUG_POSTFIX "${OTIO_DEBUG_POSTFIX}"
Expand Down Expand Up @@ -56,11 +52,6 @@ target_compile_options(opentime PRIVATE
$<$<CXX_COMPILER_ID:MSVC>: /EHsc>
)

configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/version.h.in
${CMAKE_CURRENT_BINARY_DIR}/version.h
)

if(OTIO_CXX_INSTALL)
install(FILES ${OPENTIME_HEADER_FILES}
DESTINATION "${OTIO_RESOLVED_CXX_INSTALL_DIR}/include/opentime")
Expand Down Expand Up @@ -98,12 +89,5 @@ if(OTIO_CXX_INSTALL)
DESTINATION
${OTIO_RESOLVED_CXX_INSTALL_DIR}/share/opentime
)

install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/version.h
DESTINATION
"${OTIO_RESOLVED_CXX_INSTALL_DIR}/include/opentime"
)
endif()

17 changes: 17 additions & 0 deletions src/opentime/version.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright Contributors to the OpenTimelineIO project

#pragma once

#define OPENTIME_VERSION_MAJOR 0
#define OPENTIME_VERSION_MINOR 19
#define OPENTIME_VERSION_PATCH 0
#define OPENTIME_VERSION v0_19_0
#define OPENTIME_VERSION_NS v0_19
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's a variant that leaves no room for human forgetfulness

#define OPENTIME_VERSION_MAJOR 0
#define OPENTIME_VERSION_MINOR 19
#define OPENTIME_VERSION_PATCH 0
#define OPENTIME_VERSION
v##OPENTIME_VERSION_MAJOR####OPENTIME_VERSION_MINOR####OPENTIME_VERSION_PATCH
#define OPENTIME_VERSION_NS
v##OPENTIME_VERSION_MAJOR##_##OPENTIME_VERSION_MINOR

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I'm missing something, but that doesn't seem to be working for me using VS2022. I get: vOPENTIME_VERSION_MAJOR_OPENTIME_VERSION_MINOR_OPENTIME_VERSION_PATCH.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That looks like too many ## in a row, or missing some _ between?. Here's how that's supposed to work:
https://gcc.gnu.org/onlinedocs/cpp/Concatenation.html

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, but I don't think the macros are expanding like expected. Running this simple example through cpp on Linux:

#define VERSION_MAJOR 1
#define VERSION_MINOR 2
#define VERSION_NS v##VERSION_MAJOR##_##VERSION_MINOR

namespace VERSION_NS {}

Results in this output:

namespace vVERSION_MAJOR_VERSION_MINOR {}

I can get it to work by using macro arguments, but I don't think the added complexity is worth it:

#define VERSION_MAJOR 1
#define VERSION_MINOR 2
#define VERSION_NS v##VERSION_MAJOR##_##VERSION_MINOR
#define VERSION_NS2(MAJOR, MINOR) v##MAJOR##_##MINOR
#define VERSION_NS3(MAJOR, MINOR) VERSION_NS2(MAJOR, MINOR)

namespace VERSION_NS {}
namespace VERSION_NS2(VERSION_MAJOR, VERSION_MINOR) {}
namespace VERSION_NS3(VERSION_MAJOR, VERSION_MINOR) {}

Results in this output:

namespace vVERSION_MAJOR_VERSION_MINOR {}
namespace vVERSION_MAJOR_VERSION_MINOR {}
namespace v1_2 {}


namespace opentime {
namespace OPENTIME_VERSION_NS {
}

using namespace OPENTIME_VERSION_NS;
} // namespace opentime
17 changes: 0 additions & 17 deletions src/opentime/version.h.in

This file was deleted.

22 changes: 3 additions & 19 deletions src/opentimelineio/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ set(OPENTIMELINEIO_HEADER_FILES
transition.h
typeRegistry.h
unknownSchema.h
vectorIndexing.h)
vectorIndexing.h
version.h)

add_library(opentimelineio ${OTIO_SHARED_OR_STATIC_LIB}
color.cpp
Expand Down Expand Up @@ -79,12 +80,7 @@ add_library(opentimelineio ${OTIO_SHARED_OR_STATIC_LIB}

add_library(OTIO::opentimelineio ALIAS opentimelineio)

target_include_directories(
opentimelineio
PRIVATE
"${PROJECT_SOURCE_DIR}/src"
"${CMAKE_CURRENT_BINARY_DIR}/.."
)
target_include_directories(opentimelineio PRIVATE "${PROJECT_SOURCE_DIR}/src")

if(OTIO_FIND_RAPIDJSON)
target_include_directories(opentimelineio
Expand Down Expand Up @@ -132,11 +128,6 @@ target_compile_options(opentimelineio PRIVATE
$<$<CXX_COMPILER_ID:MSVC>: /EHsc>
)

configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/version.h.in
${CMAKE_CURRENT_BINARY_DIR}/version.h
)

if(OTIO_CXX_INSTALL)
install(FILES ${OPENTIMELINEIO_HEADER_FILES}
DESTINATION "${OTIO_RESOLVED_CXX_INSTALL_DIR}/include/opentimelineio")
Expand Down Expand Up @@ -176,11 +167,4 @@ if(OTIO_CXX_INSTALL)
DESTINATION
${OTIO_RESOLVED_CXX_INSTALL_DIR}/share/opentimelineio
)

install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/version.h
DESTINATION
"${OTIO_RESOLVED_CXX_INSTALL_DIR}/include/opentimelineio"
)
endif()
10 changes: 5 additions & 5 deletions src/opentimelineio/version.h.in → src/opentimelineio/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

#pragma once

#define OPENTIMELINEIO_VERSION_MAJOR @PROJECT_VERSION_MAJOR@
#define OPENTIMELINEIO_VERSION_MINOR @PROJECT_VERSION_MINOR@
#define OPENTIMELINEIO_VERSION_PATCH @PROJECT_VERSION_PATCH@
#define OPENTIMELINEIO_VERSION v@PROJECT_VERSION_MAJOR@_@PROJECT_VERSION_MINOR@_@PROJECT_VERSION_PATCH@
#define OPENTIMELINEIO_VERSION_NS v@PROJECT_VERSION_MAJOR@_@PROJECT_VERSION_MINOR@
#define OPENTIMELINEIO_VERSION_MAJOR 0
#define OPENTIMELINEIO_VERSION_MINOR 19
#define OPENTIMELINEIO_VERSION_PATCH 0
#define OPENTIMELINEIO_VERSION v0_19_0
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same DRY note as above

#define OPENTIMELINEIO_VERSION_NS v0_19

#include "opentime/rationalTime.h"
#include "opentime/timeRange.h"
Expand Down
1 change: 0 additions & 1 deletion src/py-opentimelineio/opentime-bindings/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ target_include_directories(_opentime
PRIVATE "${PROJECT_SOURCE_DIR}/src"
PRIVATE "${PROJECT_SOURCE_DIR}/src/deps"
PRIVATE "${PROJECT_SOURCE_DIR}/src/deps/optional-lite/include"
PRIVATE "${CMAKE_BINARY_DIR}/src"
)

target_link_libraries(_opentime PUBLIC opentimelineio opentime)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ target_include_directories(_otio
PRIVATE "${PROJECT_SOURCE_DIR}/src"
PRIVATE "${PROJECT_SOURCE_DIR}/src/deps"
PRIVATE "${PROJECT_SOURCE_DIR}/src/deps/optional-lite/include"
PRIVATE "${CMAKE_BINARY_DIR}/src"
)

target_link_libraries(_otio PUBLIC opentimelineio opentime)
Expand Down
1 change: 0 additions & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ include_directories(
${PROJECT_SOURCE_DIR}/src/deps
${PROJECT_SOURCE_DIR}/src/deps/optional-lite/include
${PROJECT_SOURCE_DIR}/src/tests
${CMAKE_BINARY_DIR}/src
)

list(APPEND tests_opentime test_opentime)
Expand Down
Loading