Skip to content

Commit

Permalink
Don't impose C++14 on downstream projects
Browse files Browse the repository at this point in the history
We were setting

    target_compile_features(${objlib} PUBLIC cxx_std_${IMATH_CXX_STANDARD})

The PUBLIC forced downstream projects that consume the
ImathConfig*.cmake exports to use C++ standard at least as recent as
what Imath used to build (which defaults to 14).

But this is unnecessary. There's nothing in Imath's headers that
requires anything beyond C++11. So this patch uses a more fine-grained
setting of target properties to express this more correctly. Now it
will be fine for a C++11 project to consume Imath (via its exported
configs) even if that Imath happened to be built with C++14.

This change is exactly the same as
AcademySoftwareFoundation/openexr#995

Signed-off-by: Larry Gritz <lg@larrygritz.com>
  • Loading branch information
lgritz committed Apr 11, 2021
1 parent a9ce5a3 commit 279f199
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion config/LibraryDefine.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,16 @@ function(IMATH_DEFINE_LIBRARY libname)
${IMATH_CURLIB_HEADERS}
${IMATH_CURLIB_SOURCES})

target_compile_features(${objlib} PUBLIC cxx_std_${IMATH_CXX_STANDARD})
# Use ${IMATH_CXX_STANDARD} to determine the standard we use to compile
# Imath itself. But the headers only require C++11 features, so that's
# all we need to pass on as interface reqirements to downstream projects.
# For example, it's fine for an Imath built with C++14 to be called from
# an app that is compiled with C++11; Imath needn't force the app to
# also use C++14.
target_compile_features(${objlib}
PRIVATE cxx_std_${IMATH_CXX_STANDARD}
INTERFACE cxx_std_11 )

if(IMATH_CURLIB_PRIV_EXPORT AND BUILD_SHARED_LIBS)
target_compile_definitions(${objlib} PRIVATE ${IMATH_CURLIB_PRIV_EXPORT})
if(WIN32)
Expand Down

0 comments on commit 279f199

Please sign in to comment.