Skip to content

Commit eb90825

Browse files
authored
Merge pull request #1349 from johnhaddon/imath3Linking
SConstruct : Fix linking with OpenEXR 3
2 parents 0bf70c0 + a018776 commit eb90825

File tree

1 file changed

+34
-22
lines changed

1 file changed

+34
-22
lines changed

SConstruct

Lines changed: 34 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ EnsureSConsVersion( 3, 0, 2 ) # Substfile is a default builder as of 3.0.2
5555
SConsignFile()
5656

5757
ieCoreMilestoneVersion = 10 # for announcing major milestones - may contain all of the below
58-
ieCoreMajorVersion = 4 # backwards-incompatible changes
59-
ieCoreMinorVersion = 7 # new backwards-compatible features
58+
ieCoreMajorVersion = 5 # backwards-incompatible changes
59+
ieCoreMinorVersion = 0 # new backwards-compatible features
6060
ieCorePatchVersion = 0 # bug fixes
6161
ieCoreVersionSuffix = "" # used for alpha/beta releases. Example: "a1", "b2", etc.
6262

@@ -1299,7 +1299,7 @@ if doConfigure :
12991299
# library names if necessary
13001300
boostVersion = None
13011301
boostVersionHeader = env.FindFile( "boost/version.hpp", dependencyIncludes )
1302-
if (boostVersionHeader ==None):
1302+
if boostVersionHeader is None :
13031303
sys.stderr.write( "ERROR : unable to find the boost headers, check BOOST_INCLUDE_PATH.\n" )
13041304
Exit( 1 )
13051305

@@ -1319,6 +1319,23 @@ if doConfigure :
13191319
sys.stderr.write( "ERROR : unable to determine boost version from \"%s\".\n" % boostVersionHeader )
13201320
Exit( 1 )
13211321

1322+
# Figure out the OpenEXR version
1323+
1324+
exrVersionHeader = env.FindFile( "OpenEXR/OpenEXRConfig.h", dependencyIncludes )
1325+
if exrVersionHeader is None :
1326+
sys.stderr.write( "ERROR : unable to find `OpenEXR/OpenEXRConfig.h`, check OPENEXR_INCLUDE_PATH.\n" )
1327+
Exit( 1 )
1328+
1329+
exrMajorVersion = None
1330+
for line in open( str( exrVersionHeader ) ) :
1331+
m = re.match( r'^#define OPENEXR_VERSION_STRING "(\d)\.(\d)\.(\d)"$', line )
1332+
if m :
1333+
exrMajorVersion = int( m.group( 1 ) )
1334+
1335+
if exrMajorVersion is None :
1336+
sys.stderr.write( "ERROR : unable to determine OpenEXR version from \"{}\".\n".format( exrVersionHeader ) )
1337+
Exit( 1 )
1338+
13221339
env.Append( LIBS = [
13231340
"boost_filesystem" + env["BOOST_LIB_SUFFIX"],
13241341
"boost_regex" + env["BOOST_LIB_SUFFIX"],
@@ -1358,34 +1375,29 @@ if doConfigure :
13581375

13591376
c.Finish()
13601377

1378+
if exrMajorVersion >= 3 :
1379+
env.Append( LIBS = [ "OpenEXR" + env["OPENEXR_LIB_SUFFIX"] ] )
1380+
else :
1381+
env.Append(
1382+
LIBS = [
1383+
"IlmImf" + env["OPENEXR_LIB_SUFFIX"],
1384+
# Windows OpenEXR adds version numbers to all libraries except Half.
1385+
"Half" + ( env["OPENEXR_LIB_SUFFIX"] if env["PLATFORM"] != "win32" else "" )
1386+
]
1387+
)
1388+
13611389
env.Append( LIBS = [
13621390
"tbb" + env["TBB_LIB_SUFFIX"],
13631391
"blosc" + env["BLOSC_LIB_SUFFIX"],
13641392
"Iex" + env["OPENEXR_LIB_SUFFIX"],
13651393
"Imath" + env["OPENEXR_LIB_SUFFIX"],
1366-
"IlmImf" + env["OPENEXR_LIB_SUFFIX"],
13671394
"IlmThread" + env["OPENEXR_LIB_SUFFIX"],
1395+
# Link Windows zlib against static library to avoid potential conflicts
1396+
# with system provided version.
1397+
"z" if env["PLATFORM"] != "win32" else "zlibstatic"
13681398
]
13691399
)
13701400

1371-
# Windows OpenEXR adds version numbers to libraries except Half
1372-
# Link Windows zlib against static library to avoid potential conflicts
1373-
# with system provided version
1374-
if env["PLATFORM"] != "win32" :
1375-
env.Append( LIBS = [
1376-
"Half" + env["OPENEXR_LIB_SUFFIX"],
1377-
"z",
1378-
]
1379-
)
1380-
1381-
else :
1382-
env.Append( LIBS= [
1383-
"Half",
1384-
"zlibstatic",
1385-
]
1386-
)
1387-
1388-
13891401
Help( o.GenerateHelpText( env ) )
13901402

13911403
###########################################################################################

0 commit comments

Comments
 (0)