Skip to content

Commit

Permalink
OpenEXRConfig.h.in uses version extracted from openexr_version.h (#1527)
Browse files Browse the repository at this point in the history
* OpenEXRConfig.h.in uses version extracted from openexr_version.h

The logic was already in place to extract the version from
`openexr_version.h`, so the `.in` file just needed to reference the
proper CMake variables. This also duplicates the `OpenEXR_VERSION_*`
settings to `OPENEXR_VERSION_*`.

Signed-off-by: Cary Phillips <cary@ilm.com>

* bazel

Signed-off-by: Cary Phillips <cary@ilm.com>

* comment

Signed-off-by: Cary Phillips <cary@ilm.com>

* fix formatting of core version test error message

Signed-off-by: Cary Phillips <cary@ilm.com>

* fix extra comparison test

Signed-off-by: Cary Phillips <cary@ilm.com>

---------

Signed-off-by: Cary Phillips <cary@ilm.com>
  • Loading branch information
cary-ilm committed Aug 28, 2023
1 parent cd854af commit df91c16
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 22 deletions.
3 changes: 3 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ expand_template(
"@OPENEXR_PACKAGE_NAME@": "OpenEXR 3.2.0",
"@OPENEXR_VERSION_EXTRA@": "",
"@OPENEXR_VERSION@": "3.2.0",
"@OPENEXR_VERSION_MAJOR@": "3",
"@OPENEXR_VERSION_MINOR@": "2",
"@OPENEXR_VERSION_PATCH@": "0",
"#cmakedefine OPENEXR_ENABLE_API_VISIBILITY": "#define OPENEXR_ENABLE_API_VISIBILITY",
"#cmakedefine OPENEXR_HAVE_LARGE_STACK 1": "/* #undef OPENEXR_HAVE_LARGE_STACK */",
},
Expand Down
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ endif()

file(READ "src/lib/OpenEXRCore/openexr_version.h" VERSION_H)
string(REGEX MATCH "VERSION_MAJOR ([0-9]*)" _ ${VERSION_H})
set(VER_MAJ ${CMAKE_MATCH_1})
set(OPENEXR_VERSION_MAJOR ${CMAKE_MATCH_1})
string(REGEX MATCH "VERSION_MINOR ([0-9]*)" _ ${VERSION_H})
set(VER_MIN ${CMAKE_MATCH_1})
set(OPENEXR_VERSION_MINOR ${CMAKE_MATCH_1})
string(REGEX MATCH "VERSION_PATCH ([0-9]*)" _ ${VERSION_H})
set(VER_PCH ${CMAKE_MATCH_1})
set(OPENEXR_VERSION_PATCH ${CMAKE_MATCH_1})

project(OpenEXR VERSION ${VER_MAJ}.${VER_MIN}.${VER_PCH} LANGUAGES C CXX)
project(OpenEXR VERSION ${OPENEXR_VERSION_MAJOR}.${OPENEXR_VERSION_MINOR}.${OPENEXR_VERSION_PATCH} LANGUAGES C CXX)

set(OPENEXR_VERSION_RELEASE_TYPE "-dev" CACHE STRING "Extra version tag string for OpenEXR build, such as -dev, -beta1, etc.")

Expand Down
21 changes: 13 additions & 8 deletions cmake/OpenEXRConfig.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,19 @@

#pragma once

/// @TODO get the version from the header files.
/// due to the structure of the cmake configuration steps,
/// it's not obvious how to structure things for this to work.
/// so for now, just hardcode the version here.
//#include <OpenEXRCore/openexr_version.h>
#define OPENEXR_VERSION_MAJOR 3
#define OPENEXR_VERSION_MINOR 2
#define OPENEXR_VERSION_PATCH 0
//
// The OpenEXR release version is defined officially in
// src/lib/OpenEXRCore/openexr_version.h, but CMake doesn't readily allow
// that to be included here, so duplicate the settings for
// backwards-compatibility with applications that may expect to get the
// defines from this include.
//

#ifndef INCLUDED_OPENEXR_VERSION_H
#define OPENEXR_VERSION_MAJOR @OpenEXR_VERSION_MAJOR@
#define OPENEXR_VERSION_MINOR @OpenEXR_VERSION_MINOR@
#define OPENEXR_VERSION_PATCH @OpenEXR_VERSION_PATCH@
#endif

//
// Options / configuration based on O.S. / compiler
Expand Down
1 change: 1 addition & 0 deletions src/lib/OpenEXRCore/base.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include "openexr_base.h"
#include "openexr_errors.h"
#include "openexr_version.h"

/**************************************/

Expand Down
2 changes: 1 addition & 1 deletion src/test/OpenEXRCoreTest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ target_compile_definitions(OpenEXRCoreTest PRIVATE
COMP_MAJ=${OpenEXR_VERSION_MAJOR}
COMP_MIN=${OpenEXR_VERSION_MINOR}
COMP_PATCH=${OpenEXR_VERSION_PATCH}
COMP_EXTRA="\\"${OPENEXR_VERSION_RELEASE_TYPE}\\""
COMP_EXTRA="${OPENEXR_VERSION_RELEASE_TYPE}"
)
set_target_properties(OpenEXRCoreTest PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
Expand Down
18 changes: 9 additions & 9 deletions src/test/OpenEXRCoreTest/base_units.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,21 @@ testBase (const std::string& tempdir)

exr_get_library_version (&major, &minor, &patch, &extra);
if (major != COMP_MAJ || minor != COMP_MIN || patch != COMP_PATCH ||
!strcmp (extra, compextra))
strcmp (extra, compextra))
{
std::cerr << "ERROR testing library, wrong library version: " << major
std::cerr << "ERROR testing library, wrong library version: '" << major
<< "." << minor << "." << patch;
if (extra[0] != '\0') std::cerr << "-" << extra;
std::cerr << " vs compiled in " << COMP_MAJ << "." << COMP_MIN << "."
if (extra[0] != '\0') std::cerr << extra;
std::cerr << "' vs compiled in '" << COMP_MAJ << "." << COMP_MIN << "."
<< COMP_PATCH;
if (compextra[0] != '\0') std::cerr << "-" << compextra;
std::cerr << std::endl;
if (compextra[0] != '\0') std::cerr << compextra;
std::cerr << "'" << std::endl;
EXRCORE_TEST (false);
}
std::cout << "Testing OpenEXR library version: " << major << "." << minor << "."
std::cout << "Testing OpenEXR library version: '" << major << "." << minor << "."
<< patch;
if (extra[0] != '\0') std::cout << "-" << extra;
std::cout << std::endl;
if (extra[0] != '\0') std::cout << extra;
std::cout << "'" << std::endl;

exr_get_library_version (NULL, &minor, &patch, &extra);
exr_get_library_version (&major, NULL, &patch, &extra);
Expand Down

0 comments on commit df91c16

Please sign in to comment.