Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenEXRConfig.h.in uses version extracted from openexr_version.h #1527

Merged
merged 5 commits into from
Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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
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
10 changes: 5 additions & 5 deletions src/test/OpenEXRCoreTest/base_units.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ testBase (const std::string& tempdir)
if (major != COMP_MAJ || minor != COMP_MIN || patch != COMP_PATCH ||
!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 << "."
Expand Down
Loading