Skip to content

Commit afb8824

Browse files
committed
Include all Imath headers with via #include <Imath/...>
Since Imath is an external library that installs its headers under a Imath subdirectory, the conventional construct is for the #include to use that subdir. Note that when building with an internal, auto-fetched Imath library, the ImathConfig.h header needs special attention since its location in the source tree is not under the Imath subdir. When this is the situation, symlink/copy ImathConfig.h into the Imath subdir. Signed-off-by: Cary Phillips <cary@ilm.com>
1 parent 1bd1988 commit afb8824

83 files changed

Lines changed: 125 additions & 95 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

cmake/OpenEXRSetup.cmake

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,36 @@ else()
391391
endif()
392392
endif()
393393

394+
# Installed Imath headers use #include <Imath/ImathVec.h> and <Imath/ImathConfig.h>.
395+
# Build-tree Imath targets expose src/Imath (legacy <ImathVec.h>) and a flat
396+
# config/ImathConfig.h (<ImathConfig.h>). Mirror the installed layout for any
397+
# non-imported in-tree Imath (FetchContent, add_subdirectory, etc.).
398+
if(TARGET Imath AND TARGET ImathConfig)
399+
get_target_property(_openexr_imath_imported Imath IMPORTED)
400+
get_target_property(_openexr_imathcfg_imported ImathConfig IMPORTED)
401+
if(NOT _openexr_imath_imported
402+
AND NOT _openexr_imathcfg_imported
403+
AND EXISTS "${Imath_SOURCE_DIR}/src/Imath/ImathVec.h")
404+
set(_openexr_imath_gen_cfg "${Imath_BINARY_DIR}/config/ImathConfig.h")
405+
set(_openexr_imath_cfg_compat "${PROJECT_BINARY_DIR}/OpenEXR_ImathIncludeCompat")
406+
if(EXISTS "${_openexr_imath_gen_cfg}")
407+
file(MAKE_DIRECTORY "${_openexr_imath_cfg_compat}/Imath")
408+
configure_file("${_openexr_imath_gen_cfg}"
409+
"${_openexr_imath_cfg_compat}/Imath/ImathConfig.h" COPYONLY)
410+
endif()
411+
set(_openexr_imath_inc_patch_key "${Imath_SOURCE_DIR}|${Imath_BINARY_DIR}")
412+
if(NOT OPENEXR_IMATH_SUBDIR_INCLUDE_PATCH STREQUAL _openexr_imath_inc_patch_key)
413+
target_include_directories(Imath INTERFACE
414+
"$<BUILD_INTERFACE:${Imath_SOURCE_DIR}/src>")
415+
if(EXISTS "${_openexr_imath_gen_cfg}")
416+
target_include_directories(ImathConfig INTERFACE
417+
"$<BUILD_INTERFACE:${_openexr_imath_cfg_compat}>")
418+
endif()
419+
set(OPENEXR_IMATH_SUBDIR_INCLUDE_PATCH "${_openexr_imath_inc_patch_key}" CACHE INTERNAL "")
420+
endif()
421+
endif()
422+
endif()
423+
394424
###########################################
395425
# Check if we need to emulate vld1q_f32_x2
396426
###########################################

src/bin/exrcheck/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// SPDX-License-Identifier: BSD-3-Clause
22
// Copyright (c) Contributors to the OpenEXR Project.
33

4-
#include <ImathConfig.h>
4+
#include <Imath/ImathConfig.h>
55
#include <ImfCheckFile.h>
66
#include <ImfMisc.h>
77
#include <OpenEXRConfig.h>

src/bin/exrenvmap/EnvmapImage.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
//-----------------------------------------------------------------------------
1111

1212
#include "EnvmapImage.h"
13-
#include <ImathFun.h>
13+
#include <Imath/ImathFun.h>
1414

1515
#include "namespaceAlias.h"
1616
using namespace IMF;

src/bin/exrenvmap/EnvmapImage.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
#include "namespaceAlias.h"
1616

17-
#include <ImathBox.h>
17+
#include <Imath/ImathBox.h>
1818
#include <ImfArray.h>
1919
#include <ImfEnvmap.h>
2020
#include <ImfRgba.h>

src/bin/exrenvmap/namespaceAlias.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#define NAMESPACEALIAS_H_
88

99
#include "IexNamespace.h"
10-
#include "ImathNamespace.h"
10+
#include <Imath/ImathNamespace.h>
1111
#include "ImfNamespace.h"
1212

1313
namespace IMF = OPENEXR_IMF_NAMESPACE;

src/bin/exrmakepreview/makePreview.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
#include "makePreview.h"
1313

14-
#include <ImathFun.h>
15-
#include <ImathMath.h>
14+
#include <Imath/ImathFun.h>
15+
#include <Imath/ImathMath.h>
1616
#include <ImfArray.h>
1717
#include <ImfInputFile.h>
1818
#include <ImfOutputFile.h>

src/bin/exrmaketiled/Image.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
//
1313
//----------------------------------------------------------------------------
1414

15-
#include <ImathBox.h>
15+
#include <Imath/ImathBox.h>
1616
#include <ImfArray.h>
1717
#include <ImfFrameBuffer.h>
1818
#include <ImfPixelType.h>

src/bin/exrmaketiled/makeTiled.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include "Image.h"
1414

1515
#include "Iex.h"
16-
#include "ImathFun.h"
16+
#include <Imath/ImathFun.h>
1717
#include "ImfChannelList.h"
1818
#include "ImfDeepScanLineInputPart.h"
1919
#include "ImfDeepScanLineOutputPart.h"

src/bin/exrmaketiled/namespaceAlias.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#define NAMESPACEALIAS_H_
88

99
#include <IexNamespace.h>
10-
#include <ImathNamespace.h>
10+
#include <Imath/ImathNamespace.h>
1111
#include <ImfNamespace.h>
1212

1313
namespace IMF = OPENEXR_IMF_NAMESPACE;

src/bin/exrmultiview/Image.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
//----------------------------------------------------------------------------
1414

1515
#include <Iex.h>
16-
#include <ImathBox.h>
16+
#include <Imath/ImathBox.h>
1717
#include <ImfArray.h>
1818
#include <ImfChannelList.h>
1919
#include <ImfFrameBuffer.h>

0 commit comments

Comments
 (0)