From b0b3cf998e84d9bca68b3de649d09a38f281f5ba Mon Sep 17 00:00:00 2001 From: Larry Gritz Date: Sat, 6 Jul 2024 22:35:14 -0700 Subject: [PATCH 01/17] Fix GHA CI after they upgraded nodejs (#1837) They upgraded to a version that requires a glibc newer than is in the pre-2023 ASWF containers. Signed-off-by: Larry Gritz --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0ff552ad3..d05e08748 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -265,6 +265,8 @@ jobs: USE_BATCHED: ${{matrix.batched}} USE_SIMD: ${{matrix.simd}} ABI_CHECK: ${{matrix.abi_check}} + ACTIONS_RUNNER_FORCE_ACTIONS_NODE_VERSION: node16 + ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true steps: # We would like to use harden-runner, but it flags too many false # positives, every time we download a dependency. We should use it only From 0fd14170a8ba6bebea9d7467303ad4c57a555dd2 Mon Sep 17 00:00:00 2001 From: Larry Gritz Date: Sun, 7 Jul 2024 09:04:06 -0700 Subject: [PATCH 02/17] cleanup: Switch away from deprecated OIIO function names (#1838) Signed-off-by: Larry Gritz --- src/testshade/testshade.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/testshade/testshade.cpp b/src/testshade/testshade.cpp index db5bac164..4d6a74cd8 100644 --- a/src/testshade/testshade.cpp +++ b/src/testshade/testshade.cpp @@ -1418,9 +1418,9 @@ batched_save_outputs(SimpleRenderer* rend, ShadingSystem* shadingsys, int y = by[batchIndex]; int data = batchResults[batchIndex]; float pixel[1]; - OIIO::convert_types(TypeDesc::BASETYPE(t.basetype), &data, - TypeDesc::FLOAT, &pixel[0], - 1 /*nchans*/); + OIIO::convert_pixel_values(TypeDesc::BASETYPE(t.basetype), + &data, TypeDesc::FLOAT, + &pixel[0], 1 /*nchans*/); outputimg->setpixel(x, y, &pixel[0]); if (print_outputs) { *oStreams[batchIndex] @@ -1442,9 +1442,9 @@ batched_save_outputs(SimpleRenderer* rend, ShadingSystem* shadingsys, intPixel[c] = batchResults[batchIndex][c]; } - OIIO::convert_types(TypeDesc::BASETYPE(t.basetype), - intPixel, TypeDesc::FLOAT, floatPixel, - 3 /*nchans*/); + OIIO::convert_pixel_values(TypeDesc::BASETYPE(t.basetype), + intPixel, TypeDesc::FLOAT, + floatPixel, 3 /*nchans*/); outputimg->setpixel(x, y, floatPixel); if (print_outputs) { (*oStreams[batchIndex]) From 27a8bdebca298fd4f0b5d4dc447de834666ee71a Mon Sep 17 00:00:00 2001 From: Larry Gritz Date: Sun, 7 Jul 2024 16:16:38 -0700 Subject: [PATCH 03/17] ci: deal with CentOS 7 EOL and disappearance of yum mirrors (#1839) This was breaking CI for us. Hard break for icc/icx tests, since those REQUIRED a yum install of the intel compilers. Softer undetected break for all the ASWF <= 2022 containers based on CentOS 7, which were not failing outright but were failing to install certain optional packages. The solution (for now) is to configure yum to exclude the missing repo. Signed-off-by: Larry Gritz --- src/build-scripts/gh-installdeps.bash | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/build-scripts/gh-installdeps.bash b/src/build-scripts/gh-installdeps.bash index b40201e23..32e4035a3 100755 --- a/src/build-scripts/gh-installdeps.bash +++ b/src/build-scripts/gh-installdeps.bash @@ -12,12 +12,19 @@ set -ex # Install system packages when those are acceptable for dependencies. # if [[ "$ASWF_ORG" != "" ]] ; then - # Using ASWF CentOS container + # Using ASWF container export PATH=/opt/rh/devtoolset-6/root/usr/bin:/usr/local/bin:$PATH #ls /etc/yum.repos.d + if [[ "$ASWF_VFXPLATFORM_VERSION" == "2021" || "$ASWF_VFXPLATFORM_VERSION" == "2022" ]] ; then + # CentOS 7 based containers need the now-nonexistant centos repo to be + # excluded or all the subsequent yum install commands will fail. + yum-config-manager --disable centos-sclo-rh && true + sed -i 's,^mirrorlist=,#,; s,^#baseurl=http://mirror\.centos\.org/centos/$releasever,baseurl=https://vault.centos.org/7.9.2009,' /etc/yum.repos.d/CentOS-Base.repo + fi + sudo /usr/bin/yum install -y giflib giflib-devel && true # sudo /usr/bin/yum install -y ffmpeg ffmpeg-devel && true From 7f3ff8ce3887cbd34cec9ff8f54e6113f6a69905 Mon Sep 17 00:00:00 2001 From: Chris Hellmuth Date: Tue, 9 Jul 2024 08:52:12 -0700 Subject: [PATCH 04/17] fix: reparameter string needed to be ustringhash (#1841) This patch fixes a regression that went unnoticed during the ustringhash conversion. Right now OSL expects strings to be represented at runtime as ustringhashes, but interactive parameters' values are still being stored as ustrings. This requires fixing in two locations, first the code that sets the initial value of an interactive parameter, and second the code that copies updated parameters into the interactive buffer. Tests: New reparameter-strings test. Signed-off-by: Chris Hellmuth --- src/cmake/testing.cmake | 2 +- src/liboslexec/runtimeoptimize.cpp | 8 +++++++- src/liboslexec/shadingsys.cpp | 16 +++++++++++++--- testsuite/reparam-string/OPTIX | 0 testsuite/reparam-string/ref/out.txt | 4 ++++ testsuite/reparam-string/run.py | 15 +++++++++++++++ testsuite/reparam-string/test.osl | 8 ++++++++ 7 files changed, 48 insertions(+), 5 deletions(-) create mode 100644 testsuite/reparam-string/OPTIX create mode 100644 testsuite/reparam-string/ref/out.txt create mode 100755 testsuite/reparam-string/run.py create mode 100644 testsuite/reparam-string/test.osl diff --git a/src/cmake/testing.cmake b/src/cmake/testing.cmake index fc5e956b0..9f37b3d6c 100644 --- a/src/cmake/testing.cmake +++ b/src/cmake/testing.cmake @@ -348,7 +348,7 @@ macro (osl_add_all_tests) printf-reg printf-whole-array raytype raytype-reg raytype-specialized regex-reg - reparam reparam-arrays testoptix-reparam + reparam reparam-arrays reparam-string testoptix-reparam render-background render-bumptest render-cornell render-furnace-diffuse render-mx-furnace-burley-diffuse diff --git a/src/liboslexec/runtimeoptimize.cpp b/src/liboslexec/runtimeoptimize.cpp index ca8c8f6b2..8e91a9d08 100644 --- a/src/liboslexec/runtimeoptimize.cpp +++ b/src/liboslexec/runtimeoptimize.cpp @@ -3290,7 +3290,13 @@ RuntimeOptimizer::run() offset = OIIO::round_to_multiple_of_pow2(offset, alignment); interactive_data.resize(offset + totalsize); // Copy from the instance value to the interactive block - memcpy(&interactive_data[offset], s.data(), typesize); + // If the value is a string, copy its hash. + if (s.typespec().is_string()) { + ustring string_data = *reinterpret_cast(s.data()); + ustringhash string_hash(string_data); + memcpy(&interactive_data[offset], &string_hash, typesize); + } else + memcpy(&interactive_data[offset], s.data(), typesize); if (totalsize > typesize) memset(&interactive_data[offset] + typesize, 0, totalsize - typesize); diff --git a/src/liboslexec/shadingsys.cpp b/src/liboslexec/shadingsys.cpp index 7efc5b13d..155d2baca 100644 --- a/src/liboslexec/shadingsys.cpp +++ b/src/liboslexec/shadingsys.cpp @@ -3398,12 +3398,22 @@ ShadingSystemImpl::ReParameter(ShaderGroup& group, string_view layername_, size_t size = type.size(); m_stat_reparam_calls_total += 1; m_stat_reparam_bytes_total += size; - if (memcmp(group.interactive_arena_ptr() + offset, val, size)) { - memcpy(group.interactive_arena_ptr() + offset, val, type.size()); + + // Copy ustringhashes instead of ustrings + const void* payload; + ustringhash string_hash; + if (type == TypeDesc::STRING) { + string_hash = ustringhash_from(*reinterpret_cast(val)); + payload = &string_hash; + } else + payload = val; + + if (memcmp(group.interactive_arena_ptr() + offset, payload, size)) { + memcpy(group.interactive_arena_ptr() + offset, payload, type.size()); if (use_optix()) renderer()->copy_to_device(group.device_interactive_arena().d_get() + offset, - val, type.size()); + payload, type.size()); m_stat_reparam_calls_changed += 1; m_stat_reparam_bytes_changed += size; } diff --git a/testsuite/reparam-string/OPTIX b/testsuite/reparam-string/OPTIX new file mode 100644 index 000000000..e69de29bb diff --git a/testsuite/reparam-string/ref/out.txt b/testsuite/reparam-string/ref/out.txt new file mode 100644 index 000000000..2a9d11a35 --- /dev/null +++ b/testsuite/reparam-string/ref/out.txt @@ -0,0 +1,4 @@ +Compiled test.osl -> test.oso +test_string = initial value +test_string = updated value + diff --git a/testsuite/reparam-string/run.py b/testsuite/reparam-string/run.py new file mode 100755 index 000000000..1bbdbf76b --- /dev/null +++ b/testsuite/reparam-string/run.py @@ -0,0 +1,15 @@ +#!/usr/bin/env python + +# Copyright Contributors to the Open Shading Language project. +# SPDX-License-Identifier: BSD-3-Clause +# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage + +command += testshade(" ".join([ + "--layer lay0", + "--param:type=string:interactive=1 test_string 'initial value'", + "test --iters 2", + "--reparam:type=string:interactive=1 lay0 test_string 'updated value'", +])) + +outputs = [ "out.txt" ] + diff --git a/testsuite/reparam-string/test.osl b/testsuite/reparam-string/test.osl new file mode 100644 index 000000000..0fb9be3d2 --- /dev/null +++ b/testsuite/reparam-string/test.osl @@ -0,0 +1,8 @@ +// Copyright Contributors to the Open Shading Language project. +// SPDX-License-Identifier: BSD-3-Clause +// https://github.com/AcademySoftwareFoundation/OpenShadingLanguage + +shader test(string test_string = "override me" [[ int interactive = 1 ]]) +{ + printf("test_string = %s\n", test_string); +} From 152bbc9386391002797ca4be31eb6fe588e4f6fc Mon Sep 17 00:00:00 2001 From: Larry Gritz Date: Tue, 9 Jul 2024 09:25:13 -0700 Subject: [PATCH 05/17] Bump version to stage developer snapshot --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b0e96253f..a340e79a0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ cmake_minimum_required (VERSION 3.15) -set (OSL_VERSION "1.14.1.0") +set (OSL_VERSION "1.14.1.1") set (OSL_VERSION_OVERRIDE "" CACHE STRING "Version override (use with caution)!") mark_as_advanced (OSL_VERSION_OVERRIDE) From 142426d62b3d79b98d3d14413368dbb7a24c1bee Mon Sep 17 00:00:00 2001 From: Larry Gritz Date: Wed, 10 Jul 2024 20:33:17 -0700 Subject: [PATCH 06/17] cleanup: Switch away from a long-deprecated OIIO method (#1842) cleanup: Switch away from some long-deprecated OIIO functions Signed-off-by: Larry Gritz --- src/osltoy/qtutils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/osltoy/qtutils.h b/src/osltoy/qtutils.h index a611aa339..709a7754c 100644 --- a/src/osltoy/qtutils.h +++ b/src/osltoy/qtutils.h @@ -105,7 +105,7 @@ ImageBuf_to_QImage(const OIIO::ImageBuf& ib) return {}; if (ib.cachedpixels()) - const_cast(&ib)->make_writeable(true); + const_cast(&ib)->make_writable(true); return QImage((const uchar*)ib.localpixels(), spec.width, spec.height, (int)spec.scanline_bytes(), format); } From fe38c321e45e2be189fed4f68103a1986af4f34f Mon Sep 17 00:00:00 2001 From: Larry Gritz Date: Thu, 11 Jul 2024 13:53:03 -0700 Subject: [PATCH 07/17] api: Switch shade_image to use current OIIO::paropt (#1843) ... instead of long-deprecated parallel_options. This is an API compatible change because OIIO itself has a paropt constructor that takes a parallel_options, and I'll leave that deprecated but present for a bit longer in OIIO. For the sake of link compatibility, we leave the old function defined in shade_image.cpp, so this should not present an ABI change. We'll remove the old version later when it's safe. Signed-off-by: Larry Gritz --- src/include/OSL/oslexec.h | 2 +- src/liboslexec/shadeimage.cpp | 14 +++++++++++++- src/osltoy/osltoyrenderer.cpp | 6 +----- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/include/OSL/oslexec.h b/src/include/OSL/oslexec.h index 7583c7765..5e2220e51 100644 --- a/src/include/OSL/oslexec.h +++ b/src/include/OSL/oslexec.h @@ -1159,7 +1159,7 @@ shade_image(ShadingSystem& shadingsys, ShaderGroup& group, const ShaderGlobals* defaultsg, OIIO::ImageBuf& buf, cspan outputs, ShadeImageLocations shadelocations = ShadePixelCenters, - OIIO::ROI roi = OIIO::ROI(), OIIO::parallel_options popt = 0); + OIIO::ROI roi = OIIO::ROI(), OIIO::paropt popt = 0); #endif diff --git a/src/liboslexec/shadeimage.cpp b/src/liboslexec/shadeimage.cpp index a556def54..247a74459 100644 --- a/src/liboslexec/shadeimage.cpp +++ b/src/liboslexec/shadeimage.cpp @@ -26,7 +26,7 @@ bool shade_image(ShadingSystem& shadingsys, ShaderGroup& group, const ShaderGlobals* defaultsg, OIIO::ImageBuf& buf, cspan outputs, ShadeImageLocations shadelocations, - OIIO::ROI roi, OIIO::parallel_options popt) + OIIO::ROI roi, OIIO::paropt popt) { using namespace OIIO; using namespace ImageBufAlgo; @@ -173,4 +173,16 @@ shade_image(ShadingSystem& shadingsys, ShaderGroup& group, +// DEPRECATED(1.14) +OSLEXECPUBLIC +bool +shade_image(ShadingSystem& shadingsys, ShaderGroup& group, + const ShaderGlobals* defaultsg, OIIO::ImageBuf& buf, + cspan outputs, ShadeImageLocations shadelocations, + OIIO::ROI roi, OIIO::parallel_options popt) +{ + return shade_image(shadingsys, group, defaultsg, buf, outputs, + shadelocations, roi, OIIO::paropt(popt)); +} + OSL_NAMESPACE_EXIT diff --git a/src/osltoy/osltoyrenderer.cpp b/src/osltoy/osltoyrenderer.cpp index f4584810c..968021d48 100644 --- a/src/osltoy/osltoyrenderer.cpp +++ b/src/osltoy/osltoyrenderer.cpp @@ -130,11 +130,7 @@ OSLToyRenderer::render_image() OIIO::ImageSpec(m_xres, m_yres, 3, TypeDesc::FLOAT)); static ustring outputs[] = { ustring("Cout") }; - // OIIO::Timer timer; - OIIO::parallel_options popt; - popt.minitems = 4096; - popt.splitdir = OIIO::Split_Tile; - popt.recursive = true; + OIIO::paropt popt(0, OIIO::paropt::SplitDir::Tile, 4096); shade_image(*shadingsys(), *shadergroup(), &m_shaderglobals_template, m_framebuffer, outputs, ShadePixelCenters, OIIO::ROI(), popt); // std::cout << timer() << "\n"; From 20461f1622f23196354eb45b954b4d70faeaf8c4 Mon Sep 17 00:00:00 2001 From: Larry Gritz Date: Sun, 21 Jul 2024 11:17:04 -0700 Subject: [PATCH 08/17] build: llvm 18 compat issue - include libclangAPINotes (#1812) Fixes #1809 Signed-off-by: Larry Gritz --- src/cmake/modules/FindLLVM.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cmake/modules/FindLLVM.cmake b/src/cmake/modules/FindLLVM.cmake index 9cdaeed1c..967f32874 100644 --- a/src/cmake/modules/FindLLVM.cmake +++ b/src/cmake/modules/FindLLVM.cmake @@ -109,7 +109,7 @@ endif () foreach (COMPONENT clangFrontend clangDriver clangSerialization clangParse clangSema clangAnalysis clangAST clangASTMatchers clangBasic clangEdit clangLex - clangSupport) + clangSupport clangAPINotes) find_library ( _CLANG_${COMPONENT}_LIBRARY NAMES ${COMPONENT} PATHS ${LLVM_LIB_DIR}) From e4781703d5308e61f76f30212acac24f23e62224 Mon Sep 17 00:00:00 2001 From: Larry Gritz Date: Sun, 21 Jul 2024 11:17:37 -0700 Subject: [PATCH 09/17] cleanup: Some modernization of osl.imageio (#1840) Signed-off-by: Larry Gritz --- src/build-scripts/ci-startup.bash | 1 + src/osl.imageio/oslinput.cpp | 57 +++++++++++++------------------ 2 files changed, 25 insertions(+), 33 deletions(-) diff --git a/src/build-scripts/ci-startup.bash b/src/build-scripts/ci-startup.bash index a3d7b7d64..f90811b8f 100755 --- a/src/build-scripts/ci-startup.bash +++ b/src/build-scripts/ci-startup.bash @@ -21,6 +21,7 @@ mkdir -p $CCACHE_DIR export OSL_ROOT=$PWD/dist export DYLD_LIBRARY_PATH=$OSL_ROOT/lib:$DYLD_LIBRARY_PATH export LD_LIBRARY_PATH=$OSL_ROOT/lib:$LD_LIBRARY_PATH +export OPENIMAGEIO_PLUGIN_PATH=$OSL_ROOT/lib:${OPENIMAGEIO_PLUGIN_PATH} export OIIO_LIBRARY_PATH=$OSL_ROOT/lib:${OIIO_LIBRARY_PATH} export LSAN_OPTIONS=suppressions=$PWD/src/build-scripts/nosanitize.txt export ASAN_OPTIONS=print_suppressions=0:detect_odr_violation=1 diff --git a/src/osl.imageio/oslinput.cpp b/src/osl.imageio/oslinput.cpp index 0ca136eb0..2c932b082 100644 --- a/src/osl.imageio/oslinput.cpp +++ b/src/osl.imageio/oslinput.cpp @@ -59,29 +59,29 @@ OSL_NAMESPACE_ENTER class OSLInput final : public ImageInput { public: OSLInput(); - virtual ~OSLInput(); - virtual const char* format_name(void) const { return "osl"; } - virtual int supports(string_view feature) const + virtual ~OSLInput() override; + virtual const char* format_name(void) const override { return "osl"; } + virtual int supports(string_view feature) const override { return (feature == "procedural"); } - virtual bool valid_file(const std::string& filename) const; - virtual bool open(const std::string& name, ImageSpec& newspec); + virtual bool valid_file(const std::string& filename) const override; + virtual bool open(const std::string& name, ImageSpec& newspec) override; virtual bool open(const std::string& name, ImageSpec& newspec, - const ImageSpec& config); - virtual bool close(); - virtual int current_subimage(void) const { return m_subimage; } - virtual int current_miplevel(void) const { return m_miplevel; } - virtual bool seek_subimage(int subimage, int miplevel); + const ImageSpec& config) override; + virtual bool close() override; + virtual int current_subimage(void) const override { return m_subimage; } + virtual int current_miplevel(void) const override { return m_miplevel; } + virtual bool seek_subimage(int subimage, int miplevel) override; virtual bool read_native_scanline(int subimage, int miplevel, int y, int z, - void* data); + void* data) override; virtual bool read_native_scanlines(int subimage, int miplevel, int ybegin, - int yend, int z, void* data); + int yend, int z, void* data) override; virtual bool read_native_tile(int subimage, int miplevel, int x, int y, - int z, void* data); + int z, void* data) override; virtual bool read_native_tiles(int subimage, int miplevel, int xbegin, int xend, int ybegin, int yend, int zbegin, - int zend, void* data); + int zend, void* data) override; private: std::string m_filename; ///< Stash the filename @@ -112,14 +112,14 @@ osl_input_imageio_create() return new OSLInput; } -OIIO_EXPORT void -osl_input_imageio_delete(ImageInput* p) +OIIO_EXPORT int osl_imageio_version = OIIO_PLUGIN_VERSION; + +OIIO_EXPORT const char* +osl_imageio_library_version() { - delete p; + return ustring(OSL_LIBRARY_VERSION_STRING).c_str(); } -OIIO_EXPORT int osl_imageio_version = OIIO_PLUGIN_VERSION; - OIIO_EXPORT const char* osl_input_extensions[] = { "osl", "oso", "oslgroup", "oslbody", NULL }; @@ -498,14 +498,13 @@ OSLInput::open(const std::string& name, ImageSpec& newspec, OIIO::lock_guard lock(shading_mutex); shadername.remove_suffix(4); m_group = shadingsys->ShaderGroupBegin(); - for (size_t p = 0, np = m_topspec.extra_attribs.size(); p < np; ++p) { - const ParamValue& pv(m_topspec.extra_attribs[p]); + for (auto&& pv : m_topspec.extra_attribs) { shadingsys->Parameter(pv.name(), pv.type(), pv.data(), pv.interp() == ParamValue::INTERP_CONSTANT); } if (!shadingsys->Shader("surface", shadername, "" /*layername*/)) { - errorfmt("y {}", errhandler.haserror() ? errhandler.geterror() - : std::string("OSL error")); + errorfmt("{}", errhandler.haserror() ? errhandler.geterror() + : std::string("OSL error")); ok = false; } shadingsys->ShaderGroupEnd(); @@ -605,11 +604,7 @@ bool OSLInput::read_native_scanlines(int subimage, int miplevel, int ybegin, int yend, int z, void* data) { -#if OIIO_PLUGIN_VERSION >= 24 lock_guard lock(*this); -#else - lock_guard lock(m_mutex); -#endif if (!seek_subimage(subimage, miplevel)) return false; @@ -650,20 +645,16 @@ OSLInput::read_native_tiles(int subimage, int miplevel, int xbegin, int xend, int ybegin, int yend, int zbegin, int zend, void* data) { -#if OIIO_PLUGIN_VERSION >= 24 lock_guard lock(*this); -#else - lock_guard lock(m_mutex); -#endif if (!seek_subimage(subimage, miplevel)) return false; if (!m_group.get()) { - errorfmt("read_native_scanlines called with missing shading group"); + errorfmt("read_native_tiles called with missing shading group"); return false; } // Create an ImageBuf wrapper of the user's data - ImageSpec spec = m_spec; // Make a spec that describes just this scanline + ImageSpec spec = m_spec; // Make a spec that describes just these tiles spec.x = xbegin; spec.y = ybegin; spec.z = zbegin; From 8913eed603004e1724882f664e50b50d66e5189b Mon Sep 17 00:00:00 2001 From: Larry Gritz Date: Sun, 21 Jul 2024 11:18:58 -0700 Subject: [PATCH 10/17] build: Make finding bison work better on Apple Silicon Macs + homebrew (#1822) Homebrew changes location by default on the new ARM-based Macs. Check the new paths, too. Signed-off-by: Larry Gritz --- src/cmake/flexbison.cmake | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/cmake/flexbison.cmake b/src/cmake/flexbison.cmake index 9959cfa58..b7db6ed94 100644 --- a/src/cmake/flexbison.cmake +++ b/src/cmake/flexbison.cmake @@ -21,9 +21,14 @@ # MacOS/xcode in /usr/bin, which seems to be too old for the reentrant # parser directives we use. Only do this if there is no BISON_ROOT # specifying a particular Bison to use. -if (APPLE AND EXISTS /usr/local/opt - AND NOT BISON_ROOT AND NOT DEFINED ENV{BISON_ROOT}) - find_program(BISON_EXECUTABLE NAMES /usr/local/opt/bison/bin/bison +if (APPLE AND NOT BISON_ROOT AND NOT DEFINED ENV{BISON_ROOT} + AND (EXISTS /usr/local/opt OR EXISTS /opt/homebrew + OR DEFINED ENV{HOMEBREW_PREFIX})) + find_program(BISON_EXECUTABLE + NAMES + ENV{HOMEBREW_PREFIX}/opt/bison/bin/bison + /opt/homebrew/opt/bison/bin/bison + /usr/local/opt/bison/bin/bison DOC "path to the bison executable") endif() From 074baf4bf29e9e2863ea00eaa52a0450a2a9b8fe Mon Sep 17 00:00:00 2001 From: Larry Gritz Date: Mon, 22 Jul 2024 07:05:05 -0700 Subject: [PATCH 11/17] fix: fix warnings and deal with recent OIIO deprecations (#1844) * fix: Handle OIIO deprecations * int: Use ustring::strhash if it exists (not Strutil::strhash) If it exists, ustring::strhash has some planned special properties. * Deal with OIIO deprecations --------- Signed-off-by: Larry Gritz --- src/include/OSL/hashes.h | 6 +++++- src/liboslexec/batched_llvm_gen.cpp | 7 +++++-- src/liboslexec/batched_llvm_instance.cpp | 2 +- src/osltoy/osltoyapp.cpp | 5 ++--- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/include/OSL/hashes.h b/src/include/OSL/hashes.h index 7e0b65a09..1e91f36fc 100644 --- a/src/include/OSL/hashes.h +++ b/src/include/OSL/hashes.h @@ -40,7 +40,11 @@ constexpr inline size_t strhash(const char* s) { size_t len = pvt::pvtstrlen(s); - return OIIO::Strutil::strhash(OIIO::string_view(s, len)); +#ifdef OIIO_USTRING_SAFE_HASH + return ustring::strhash(string_view(s, len)); +#else + return OIIO::Strutil::strhash(string_view(s, len)); +#endif } // Template to ensure the hash is evaluated at compile time. diff --git a/src/liboslexec/batched_llvm_gen.cpp b/src/liboslexec/batched_llvm_gen.cpp index dacf4f0ba..f589d6a94 100644 --- a/src/liboslexec/batched_llvm_gen.cpp +++ b/src/liboslexec/batched_llvm_gen.cpp @@ -2929,7 +2929,8 @@ LLVMGEN(llvm_gen_filterwidth) } rop.ll.call_function(rop.build_name(func_spec), - { &args[0], argCount }); + { &args[0], + cspan::size_type(argCount) }); // Don't have 2nd order derivs rop.llvm_zero_derivs(Result); } @@ -6957,7 +6958,9 @@ LLVMGEN(llvm_gen_calculatenormal) args[arg_count++] = rop.ll.mask_as_int(rop.ll.current_mask()); func_spec.mask(); } - rop.ll.call_function(rop.build_name(func_spec), { &args[0], arg_count }); + rop.ll.call_function(rop.build_name(func_spec), + { &args[0], + cspan::size_type(arg_count) }); if (Result.has_derivs()) rop.llvm_zero_derivs(Result); diff --git a/src/liboslexec/batched_llvm_instance.cpp b/src/liboslexec/batched_llvm_instance.cpp index 8e6ff0a76..b2cb6c7cd 100644 --- a/src/liboslexec/batched_llvm_instance.cpp +++ b/src/liboslexec/batched_llvm_instance.cpp @@ -200,7 +200,7 @@ struct CStrHash { OSL_FORCEINLINE size_t operator()(const char* str) const { OSL_DASSERT(str != nullptr); - return OIIO::Strutil::strhash(str); + return OSL::strhash(str); } }; diff --git a/src/osltoy/osltoyapp.cpp b/src/osltoy/osltoyapp.cpp index aa47d639f..3e6a59d08 100644 --- a/src/osltoy/osltoyapp.cpp +++ b/src/osltoy/osltoyapp.cpp @@ -432,9 +432,8 @@ OSLToyMainWindow::OSLToyMainWindow(OSLToyRenderer* rend, int xr, int yr) QPixmap pixmap(xres, yres); OIIO::ImageBuf checks( OIIO::ImageSpec(xres, yres, 3, OIIO::TypeDesc::UINT8)); - const float white[] = { 1, 1, 1 }; - const float black[] = { 0, 0, 0 }; - OIIO::ImageBufAlgo::checker(checks, 16, 16, 1, white, black); + OIIO::ImageBufAlgo::checker(checks, 16, 16, 1, 1.0f /* white */, + 0.0f /* black */); renderView->update(checks); textTabs = new QTabWidget; From 3a42777a7cd2cd697fc3accbd6cb2f3dd8b757ec Mon Sep 17 00:00:00 2001 From: Larry Gritz Date: Mon, 22 Jul 2024 23:03:10 -0400 Subject: [PATCH 12/17] CHANGES updates Signed-off-by: Larry Gritz --- CHANGES.md | 129 ++++++++++++++++++++++++++++++++++++++++++++++++++--- README.md | 38 +++++++++------- 2 files changed, 146 insertions(+), 21 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index a2c2b87e7..3eaa51601 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -6,42 +6,158 @@ Release 1.14 -- in progress (compared to 1.13) ### New minimum dependencies and compatibility changes: * Note: it is likely that by the time it is released, OSL 1.14 will require - Imath >= 3.1. + Imath >= 3.1, Python >= 3.7, C++ >= 17, gcc >= 9.3. -### OSL Language and oslc compiler (for shader writers): +### OSL Language, standard library, and oslc compiler (for shader writers): + - Fix the subsurface_bssrdf parameters to conform to MaterialX. [#1823](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1823) (by Christopher Kulla) (1.14.1.0) ### ⛰️ API changes and new ShadingSystem features (for renderer writers): +* The big switch to `ustringhash`: To better accommodate GPU execution, and to + make the code and techniques less divergent between CPU and GPU code paths, + we have changed the runtime representation of strings from `ustring` to + `ustringhash` -- which is still a 64 bit token, but rather than the address + of the unique characters, which may change from run to run and harm the + OptiX/CUDA PTX cache performance, it is the deterministic hash of the + characters. Thus, not just the runtime, but all of the interfaces of + RendererServices and other APIs that the renderers use to set up and + communicate with the ShadingSystem, now have been changed to expect + ustringhash instead of ustring. + [#1732](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1732) (by Steena Monteiro) (1.14.0.0) +* Add API for building interpolated getter free functions. + [#1765](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1765) (by Thibault Vergne) (1.14.0.0) +* Switch `shade_image()` to use current OIIO::paropt [#1843](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1843) (1.14.1.1) ### 🚀 SIMD batched shading mode + - *batched*: Codegen bug for compref with varying index [#1776](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1776) (by Alex Wells) (1.14.1.0) ### 🚀 OptiX GPU rendering + - Fix NVPTX TargetMachine leak, etc. [#1763](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1763) (by Tim Grant) (1.14.0.0) + - Fix GPU interpolated param initialization [#1791](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1791) (by Chris Hellmuth) (1.14.1.0) + - Add `lazytrace` ShadingSystem option to avoid combinatoric optixTrace + inlining: when enabled, run layers with trace ops unconditionally at the + start of shader evaluation. This costs some potential performance in cases + where the trace layer would never be evaluated, but removes all the + compilation penalties that the inlining was presenting. + [#1815](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1815) (by Chris Hellmuth) (1.14.1.0) ### 🐛/🔧 Internals: fixes, improvements, and developer concerns + - Mute partio error prints [#1774](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1774) (by olegul) (1.14.1.0) + - calculatenormal needs to use the fliphandedness global [#1783](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1783) (by sfriedmapixar) (1.14.1.0) + - Print closure missing error message at compile time instead of run time. [#1781](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1781) (by sfriedmapixar) (1.14.1.0) + - Make isconnected() work with downstream renderer "connections." [#1782](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1782) (by sfriedmapixar) (1.14.1.0) + - *int*: Change OSL_CONSTEXPR14 to constexpr [#1805](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1805) (1.14.1.0) + - Remove unnecessary ustring lookup [#1824](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1824) (by Chris Hellmuth) (1.14.1.0) + - Make backfacing shadeop indicate backfacing shader-global is needed [#1827](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1827) (by sfriedmapixar) (1.14.1.0) + - Reparameter string needed to be ustringhash [#1841](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1841) (by Chris Hellmuth) (1.14.1.0) + - Some modernization of osl.imageio [#1840](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1840) (1.14.1.1) ### 🏗 Build/test/CI and platform ports * CMake build system and scripts: + - *build*: Add options to use static Cuda libraries (controlled by + CMake variable `CUDA_PREFER_STATIC_LIBS`) [#1772](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1772) (1.14.1.0) + - *build*: Remove a lot of old SPI build cruft [#1778](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1778) (1.14.1.0) + - Simplify oslquery library include and link needs [#1787](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1787) (1.14.1.0) + - Propagate cpp version: when building against an OIIO that needs C++17, + OSL will need to be build with C++17, too. [#1797](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1797) (1.14.1.0) + - Eliminate boost as a dependency: [#1802](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1802) (by Christopher Kulla) (1.14.1.0) [#1808](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1808) (by Christopher Kulla) (1.14.1.0) + - Default to C++17 mode (but for now, C++14 is still supported by + setting `CMAKE_CXX_STANDARD`). [#1818](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1818) (1.14.1.0) * Dependency version support: + - Support for LLVM 18. [#1773](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1773) (by مهدي شينون (Mehdi Chinoune)) (1.14.1.0) + [#1803](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1803) (1.14.1.0) + - LLVM 18 compat issue - include libclangAPINotes [#1812](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1812) (1.14.1.1) + - Various fixes to deal with deprecations in the development branch and + upcoming 3.0 release of OpenImageIO: + [#1788](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1788) (1.14.1.0), [#1806](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1806) (1.14.1.0), [#1834](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1834) (1.14.1.0), [#1838](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1838) (1.14.1.0), [#1842](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1842) (1.14.1.1), [#1844](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1844) (1.14.1.1) + - *Use new OIIO ustringhash decode methods when available [#1792](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1792) (by Chris Hellmuth) (1.14.1.0) * Testing and Continuous integration (CI) systems: + - *(testrender)*: Fix testrender GPU regression with bad destruction order [#1814](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1814) (1.14.1.0) + - *(testrender)*: Implement new Oren-Nayar model from OpenPBR [#1817](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1817) (by Christopher Kulla) (1.14.1.0) + - *(testrender)*: Implement OpenPBR's sheen BRDF [#1819](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1819) (by Christopher Kulla) (1.14.1.0) + - *tests*: Update ref output for OptiX execution order variance [#1816](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1816) (1.14.1.0) + - *ci*: Test against LLVM 17 [#1760](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1760) (1.14.0.0) + - *ci*: Increase timeout for slow MacOS-13 runner [#1775](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1775) (1.14.1.0) + - *ci*: Fix broken Macos-13 CI [#1780](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1780) (1.14.1.0) + - *ci*: Allow triggering CI workflow from web [#1779](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1779) (1.14.1.0) + - *ci*: Lock down to OIIO 2.5 for icc tests [#1799](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1799) (1.14.1.0) + - *ci*: Print commit hash of locally built dependencies [#1798](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1798) (1.14.1.0) + - *ci*: Suppress leak sanitizer warnings about internals of robin_hash [#1807](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1807) (1.14.1.0) + - *ci*: Mods to CI to deal with OIIO master raising dependency mins [#1833](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1833) (1.14.1.0) + - *ci*: Fix GHA CI after they upgraded nodejs [#1837](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1837) (1.14.1.0) + - *ci*: Deal with CentOS 7 EOL and disappearance of yum mirrors [#1839](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1839) (1.14.1.0) * Platform support: + - *Mac ARM*: Test with Mac ARM runner [#1770](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1770) (1.14.1.0) + - *Mac ARM*: Make finding bison work better on Apple Silicon Macs + homebrew + [#1822](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1822) (1.14.1.1) ### 📚 Documentation - + - Fix links to RTD docs from github landing page [#1768](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1768) (1.14.0.0) + - Clarify behavior of `round()`: OSL uses "round away from zero" policy for + input values exactly half way between two integers, matching C/C++ + standard round(). But we were not clear about it in the docs. + [#1767](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1767) (1.14.1.0) + - More detail about supported platforms in INSTALL.md [#1796](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1796) (1.14.1.0) + - Fix outdated or wrong repo URLs [#1811](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1811) (1.14.1.0) + - Fixes to documentation of new oren_nayar_diffuse_bsdf parameters [#1820](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1820) (1.14.1.0) ### 🏢 Project Administration + - Account for duplicate emails in the .mailmap [#1759](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1759) (1.14.0.0) + - Releases trigger automatic announcements to the Slack channel. + [#1766](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1766) [#1777](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1777) (by John Mertic) (1.14.1.0) + - Raise our code formatting standard to clang-format 17 [#1761](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1761) (1.14.0.0) -Release 1.13 -- beta 1: December 20, 2023 (compared to 1.12) -------------------------------------------------------------- +Release 1.13.10.0 -- 1 June 2024 (compared to 1.13.9.0) +-------------------------------------------------------- + - *testrender*: Implement new Oren-Nayar model from OpenPBR [#1817](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1817) (by Christopher Kulla) + - *docs*: Fix outdated or wrong repo URLs [#1811](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1811) + + +Release 1.13.9.0 -- 1 May 2024 (compared to 1.13.8.0) +-------------------------------------------------------- + - *deps*: Support for LLVM-18 [#1773](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1773) (by مهدي شينون (Mehdi Chinoune) [#1803](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1803) (by Larry Gritz) + - *fix*: Make isconnected() work with downstream renderer "connections." [#1782](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1782) (by sfriedmapixar) + - *cleanup*: Change OSL_CONSTEXPR14 to constexpr [#1805](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1805) + - *internals build*: Fix ifdef typo [#1804](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1804) + - *build*: Propagate cpp version [#1797](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1797) + - *build*: Print commit hash of locally built dependencies [#1798](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1798) + - *ci*: Lock down to OIIO 2.5 for icc tests [#1799](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1799) + - *ci*: Suppress leak sanitizer warnings about internals of robin_hash [#1807](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1807) + - *docs*: More detail about supported platforms in INSTALL.md [#1796](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1796) + + +Release 1.13.8.0 -- 1 Apr 2024 (compared to 1.13.7.0) +-------------------------------------------------------- +* *fix(batched)*: Codegen bug for compref with varying index for batched shading [#1776](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1776) (by Alex Wells) +* *fix*: Calculatenormal needs fliphandedness [#1783](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1783) (by sfriedmapixar) +* *fix*: Print closure missing error message at compile time instead of run time. [#1781](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1781) (by sfriedmapixar) +* *int*: Change long-deprecated OIIO macro to new one [#1788](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1788) +* *ci*: Fix broken Macos-13 CI [#1780](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1780) + +Release 1.13.7.0 -- 1 Mar 2024 (compared to 1.13.6.1) +-------------------------------------------------------- +* *fix*: Mute partio error prints [#1774](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1774) (by olegul) +* *ci*: Test with Mac ARM runner [#1770](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1770) +* *docs*: Fix links to RTD docs from github landing page [#1768](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1768) +* *admin*: Switch release announcement workflow to jmertic's awesome action [#1766](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1766) + +
+ + +Release 1.13 -- Feb 1, 2024 (compared to 1.12) +=============================================== +- beta 1: December 20, 2023 +- release v1.13.6.1: Feb 1, 2024 ### New minimum dependencies and compatibility changes: @@ -130,6 +246,7 @@ Release 1.13 -- beta 1: December 20, 2023 (compared to 1.12) * OptiX PTX pipeline overhaul [#1680](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1680) (by Tim Grant) (1.13.5.0) * Perf: Don't insert redundant run layer calls inside a basic block [#1665](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1665) [#1669](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1669) [#1672](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1672) (by Chris Hellmuth) (1.13.4.0) +* Fix NVPTX TargetMachine leak, etc. [#1763](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1763) (by Tim Grant) ### 🐛/🔧 Internals: fixes, improvements, and developer concerns @@ -225,6 +342,7 @@ Release 1.13 -- beta 1: December 20, 2023 (compared to 1.12) * For clarity, use the term 'runner' instead of 'os' [#1743](https://github.com/AcademySoftwareFoundation/OpenShadingLangauge/pull/1743) * Test ABI compliance [#1748](https://github.com/AcademySoftwareFoundation/OpenShadingLangauge/pull/1748) * Fix tests passing when test commands fail [#1733](https://github.com/AcademySoftwareFoundation/OpenShadingLangauge/pull/1733) (by Brecht Van Lommel) + * *ci*: Test against LLVM 17 [#1760](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1760) * Platform support: * Include `immintrin.h` only when needed. #1605 (1.13.1.0) * Changed snprintf formatting to satisfy some compilers. @@ -250,6 +368,7 @@ Release 1.13 -- beta 1: December 20, 2023 (compared to 1.12) * Alert slack "release-announcements" channel upon OSL release [#1740](https://github.com/AcademySoftwareFoundation/OpenShadingLangauge/pull/1740) [#1749](https://github.com/AcademySoftwareFoundation/OpenShadingLangauge/pull/1749) * Update pull request template [#1741](https://github.com/AcademySoftwareFoundation/OpenShadingLangauge/pull/1741) +* Account for duplicate emails in the .mailmap [#1759](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1759) --- diff --git a/README.md b/README.md index aa6953d95..710e802e6 100644 --- a/README.md +++ b/README.md @@ -426,7 +426,7 @@ nominated for major awards.) Obi-Wan Kenobi (series), The Boys (S3), Andor (S1) -* **(2023 / upcoming)** +* **(2023)** Ant-Man and the Wasp: Quantumania, The Mandalorian S3, The Magician's Elephant, @@ -434,6 +434,12 @@ nominated for major awards.) Guardians of the Galaxy 3, Spider-Man: Across the Spider-Verse, Elemental, + The Marvels, + Leo +* **(2024 / upcoming)** + Ghostbusters: Frozen Empire, + Inside Out 2, + In Your Dreams, ... @@ -527,21 +533,21 @@ The current project leadership is documented in the Many people have contributed features, bug fixes, and other changes to OSL over the years: Steve Agland, Shane Ambler, Martijn Berger, Farchad Bidgolirad, Nicholas Bishop, Curtis Black, Rasmus Bonnedal, Solomon Boulos, -Stefan Bruens, Stefan Büttner, Matthaus G. Chajdas, Clark Chen, Alejandro -Conty, Damien Courtois, Dieter De Baets, Thomas Dinges, Daniel Dresser, Mads -Drøschler, Peter Ellerington, Luke Emrose, Louis Feng, Mark Final, Henri -Fousse, Stephen Friedman, Syoyo Fujita, Tim Grant, Larry Gritz, Nicolas -Guiard, Euan Haahr, Derek Haase, Sven-Hendrik Haase, John Haddon, Niklas -Harrysson, Daniel Heckenberg, Chris Hellmuth, Adrien Herubel, Dan Horák, -Thiago Ize, Matt Johnson, Ronan Keryell, Chris Kulla, Elvic Liang, Max Liani, -Adam Martinez, John Mertic, Bastien Montagne, Steena Monteiro, Patrick Mours, -Alexis Oblet, Erich Ocean, Mikko Ohtamaa, Jino Park, Alexei Pawlow, Jay -Reynolds, Declan Russell, Benoit Ruiz, Patrick Scheibe, Alex Schworer, -Jonathan Scruggs, Sergey Sharybin, Mark Sisson, Sandip Shukla, Cliff Stein, -Stephan Steinbach, Luya Tshimbalanga, Esteban Tovagliari, Brecht Van Lommel, -Alexander von Knorring, Aidan Welch, Alex Wells, Roman Zulak. (Listed -alphabetically; if we've left anybody out, it is inadvertent, please let us -know.) +Stefan Bruens, Stefan Büttner, Matthaus G. Chajdas, Clark Chen, Mehdi +Chinoune, Alejandro Conty, Damien Courtois, Dieter De Baets, Thomas Dinges, +Daniel Dresser, Mads Drøschler, Peter Ellerington, Luke Emrose, Louis Feng, +Mark Final, Henri Fousse, Stephen Friedman, Syoyo Fujita, Tim Grant, Larry +Gritz, Nicolas Guiard, Euan Haahr, Derek Haase, Sven-Hendrik Haase, John +Haddon, Niklas Harrysson, Daniel Heckenberg, Chris Hellmuth, Adrien Herubel, +Dan Horák, Thiago Ize, Matt Johnson, Ronan Keryell, Chris Kulla, Elvic Liang, +Max Liani, Adam Martinez, John Mertic, Bastien Montagne, Steena Monteiro, +Patrick Mours, Alexis Oblet, Erich Ocean, Mikko Ohtamaa, Jino Park, Alexei +Pawlow, Mitch Prater, Jay Reynolds, Declan Russell, Benoit Ruiz, Patrick +Scheibe, Alex Schworer, Jonathan Scruggs, Sergey Sharybin, Mark Sisson, Sandip +Shukla, Cliff Stein, Stephan Steinbach, Luya Tshimbalanga, Esteban Tovagliari, +Brecht Van Lommel, Thibault Vergne, Alexander von Knorring, Aidan Welch, Alex +Wells, Roman Zulak. (Listed alphabetically; if we've left anybody out, it is +inadvertent, please let us know.) We cannot possibly express sufficient gratitude to the managers at Sony Pictures Imageworks who allowed this project to proceed, supported it From 64000b4c8f8e86779d90b3d4ec51d1130f05d563 Mon Sep 17 00:00:00 2001 From: Larry Gritz Date: Thu, 25 Jul 2024 09:25:00 -0700 Subject: [PATCH 13/17] build: CMake: replace deprecated add_definitions with preferred add_compile_definitions (#1821) Signed-off-by: Larry Gritz --- CMakeLists.txt | 12 ++++++------ doc/build_install/windows/build_osl.py | 2 +- src/cmake/checked_find_package.cmake | 4 ++-- src/cmake/compiler.cmake | 26 +++++++++++++------------- src/cmake/cuda_macros.cmake | 2 +- src/cmake/externalpackages.cmake | 16 ++++++++-------- src/cmake/flexbison.cmake | 2 +- src/liboslexec/CMakeLists.txt | 4 ++-- src/testrender/CMakeLists.txt | 2 +- src/testshade/CMakeLists.txt | 2 +- 10 files changed, 36 insertions(+), 36 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a340e79a0..51d50ebd2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -118,28 +118,28 @@ option (OSL_USTRINGREP_IS_HASH "Always use ustringhash for strings" OFF) set (OSL_NO_DEFAULT_TEXTURESYSTEM OFF CACHE BOOL "Do not use create a raw OIIO::TextureSystem") if (OSL_NO_DEFAULT_TEXTURESYSTEM) - add_definitions ("-DOSL_NO_DEFAULT_TEXTURESYSTEM=1") + add_compile_definitions (OSL_NO_DEFAULT_TEXTURESYSTEM=1) endif () option (USE_FAST_MATH "Use fast math approximations (if no, then use system math library)" ON) if (USE_FAST_MATH) - add_definitions ("-DOSL_FAST_MATH=1") + add_compile_definitions (OSL_FAST_MATH=1) else () - add_definitions ("-DOSL_FAST_MATH=0") + add_compile_definitions (OSL_FAST_MATH=0) endif () option (OIIO_FMATH_SIMD_FRIENDLY "Make sure OIIO fmath functions are SIMD-friendly" OFF) if (OIIO_FMATH_SIMD_FRIENDLY) - add_definitions (-DOIIO_FMATH_SIMD_FRIENDLY=1) + add_compile_definitions (OIIO_FMATH_SIMD_FRIENDLY=1) endif () # Define OSL_INTERNAL symbol only when building OSL itself, will not be # defined for downstream projects using OSL. -add_definitions (-DOSL_INTERNAL=1) +add_compile_definitions (OSL_INTERNAL=1) # To make sure we aren't relying on deprecated OIIO features, we define # OIIO_DISABLE_DEPRECATED before including any OIIO headers. -add_definitions (-DOIIO_DISABLE_DEPRECATED=900000) +add_compile_definitions (OIIO_DISABLE_DEPRECATED=900000) # Set the default namespace. For symbol hiding reasons, it's important that # the project name is a subset of the namespace name. diff --git a/doc/build_install/windows/build_osl.py b/doc/build_install/windows/build_osl.py index d8eebb678..86bfc34ba 100644 --- a/doc/build_install/windows/build_osl.py +++ b/doc/build_install/windows/build_osl.py @@ -896,7 +896,7 @@ def InstallPtex_Windows(context, force, buildArgs): ) PatchFile( "src\\tests\\CMakeLists.txt", - [("add_definitions(-DPTEX_STATIC)", "# add_definitions(-DPTEX_STATIC)")], + [("add_compile_definitions(PTEX_STATIC)", "# add_compile_definitions(PTEX_STATIC)")], ) # Patch Ptex::String to export symbol for operator<< diff --git a/src/cmake/checked_find_package.cmake b/src/cmake/checked_find_package.cmake index d08306227..f42771610 100644 --- a/src/cmake/checked_find_package.cmake +++ b/src/cmake/checked_find_package.cmake @@ -37,7 +37,7 @@ endfunction () # turned off explicitly from one of these sources. # * Print a message if the package is enabled but not found. This is based # on ${Pkgname}_FOUND or $PKGNAME_FOUND. -# * Optional DEFINITIONS ... are passed to add_definitions if the +# * Optional DEFINITIONS ... are passed to add_compile_definitions if the # package is found. # * Optional SETVARIABLES ... is a list of CMake variables to set to # TRUE if the package is found (they will not be set or changed if the @@ -155,7 +155,7 @@ macro (checked_find_package pkgname) endif () endforeach () message (STATUS "${ColorGreen}Found ${pkgname} ${${pkgname}_VERSION} ${_config_status}${ColorReset}") - add_definitions (${_pkg_DEFINITIONS}) + add_compile_definitions (${_pkg_DEFINITIONS}) foreach (_v IN LISTS _pkg_SETVARIABLES) set (${_v} TRUE) endforeach () diff --git a/src/cmake/compiler.cmake b/src/cmake/compiler.cmake index 81ac2092f..4a6a8ad61 100644 --- a/src/cmake/compiler.cmake +++ b/src/cmake/compiler.cmake @@ -183,8 +183,8 @@ if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG) # Options common to gcc and clang # Ensure this macro is set for stdint.h - add_definitions ("-D__STDC_LIMIT_MACROS") - add_definitions ("-D__STDC_CONSTANT_MACROS") + add_compile_definitions (__STDC_LIMIT_MACROS) + add_compile_definitions (__STDC_CONSTANT_MACROS) # this allows native instructions to be used for sqrtf instead of a function call add_compile_options ("-fno-math-errno") endif () @@ -197,11 +197,11 @@ endif () if (MSVC) # Microsoft specific options string (REGEX REPLACE "/W[1-4]" "/W1" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) - add_definitions (-D_CRT_SECURE_NO_DEPRECATE) - add_definitions (-D_CRT_SECURE_NO_WARNINGS) - add_definitions (-D_CRT_NONSTDC_NO_WARNINGS) - add_definitions (-D_SCL_SECURE_NO_WARNINGS) - add_definitions (-DJAS_WIN_MSVC_BUILD) + add_compile_definitions (_CRT_SECURE_NO_DEPRECATE) + add_compile_definitions (_CRT_SECURE_NO_WARNINGS) + add_compile_definitions (_CRT_NONSTDC_NO_WARNINGS) + add_compile_definitions (_SCL_SECURE_NO_WARNINGS) + add_compile_definitions (JAS_WIN_MSVC_BUILD) endif (MSVC) if (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD" @@ -284,7 +284,7 @@ endif () set (GLIBCXX_USE_CXX11_ABI "" CACHE STRING "For gcc, use the new C++11 library ABI (0|1)") if (CMAKE_COMPILER_IS_GNUCC AND ${GCC_VERSION} VERSION_GREATER_EQUAL 5.0) if (NOT ${GLIBCXX_USE_CXX11_ABI} STREQUAL "") - add_definitions ("-D_GLIBCXX_USE_CXX11_ABI=${GLIBCXX_USE_CXX11_ABI}") + add_compile_definitions (_GLIBCXX_USE_CXX11_ABI=${GLIBCXX_USE_CXX11_ABI}) endif () endif () @@ -368,7 +368,7 @@ option (CODECOV "Build code coverage tests" OFF) if (CODECOV AND (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG)) message (STATUS "Compiling for code coverage analysis") add_compile_options (-ftest-coverage -fprofile-arcs) - add_definitions ("-D${PROJ_NAME}_CODE_COVERAGE=1") + add_compile_definitions (${PROJ_NAME}_CODE_COVERAGE=1) link_libraries(gcov) endif () @@ -388,9 +388,9 @@ if (SANITIZE AND (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG)) add_compile_options (-g -fno-omit-frame-pointer) if (CMAKE_COMPILER_IS_GNUCC) # turn on glibcxx extra annotations to find vector writes past end - add_definitions ("-D_GLIBCXX_SANITIZE_VECTOR=1") + add_compile_definitions (_GLIBCXX_SANITIZE_VECTOR=1) endif () - add_definitions ("-D${PROJECT_NAME}_SANITIZE=1") + add_compile_definitions (${PROJECT_NAME}_SANITIZE=1) endif () @@ -524,7 +524,7 @@ message(VERBOSE "Setting SOVERSION to: ${SOVERSION}") # option (BUILD_SHARED_LIBS "Build shared libraries (set to OFF to build static libs)" ON) if (NOT BUILD_SHARED_LIBS) - add_definitions (-D${PROJECT_NAME}_STATIC_DEFINE=1) + add_compile_definitions (${PROJECT_NAME}_STATIC_DEFINE=1) endif () @@ -549,7 +549,7 @@ endif () # We expect our own CI runs to define env variable ${PROJECT_NAME}_CI # if (DEFINED ENV{${PROJECT_NAME}_CI}) - add_definitions (-D${PROJ_NAME}_CI=1 -DBUILD_CI=1) + add_compile_definitions (${PROJ_NAME}_CI=1 BUILD_CI=1) if (APPLE) # Keep Mono framework from being incorrectly searched for include # files on GitHub Actions CI. diff --git a/src/cmake/cuda_macros.cmake b/src/cmake/cuda_macros.cmake index 046aefd20..e9857556d 100644 --- a/src/cmake/cuda_macros.cmake +++ b/src/cmake/cuda_macros.cmake @@ -11,7 +11,7 @@ set (CUDA_OPT_FLAG_CLANG "-O3" CACHE STRING "The optimization level to use when # host behavior, etc. set (CUDA_NO_FTZ OFF CACHE BOOL "Do not enable force-to-zero when compiling for CUDA") if (CUDA_NO_FTZ) - add_definitions ("-DOSL_CUDA_NO_FTZ=1") + add_compile_definitions (DOSL_CUDA_NO_FTZ=1) endif () # Compile a CUDA file to PTX using NVCC diff --git a/src/cmake/externalpackages.cmake b/src/cmake/externalpackages.cmake index 2d33e6542..b92543b62 100644 --- a/src/cmake/externalpackages.cmake +++ b/src/cmake/externalpackages.cmake @@ -50,7 +50,7 @@ checked_find_package (OpenEXR REQUIRED # install version of 2.x. include_directories(BEFORE ${IMATH_INCLUDES}) if (MSVC AND NOT LINKSTATIC) - add_definitions (-DOPENEXR_DLL) # Is this needed for new versions? + add_compile_definitions (OPENEXR_DLL) # Is this needed for new versions? endif () if (OPENEXR_VERSION VERSION_GREATER_EQUAL 2.5.99) @@ -63,7 +63,7 @@ endif () # OpenImageIO checked_find_package (OpenImageIO REQUIRED VERSION_MIN 2.4 - DEFINITIONS -DOIIO_HIDE_FORMAT=1) + DEFINITIONS OIIO_HIDE_FORMAT=1) checked_find_package (pugixml REQUIRED VERSION_MIN 1.8) @@ -80,10 +80,10 @@ link_directories ("${LLVM_LIB_DIR}") # Extract and concatenate major & minor, remove wayward patches, # dots, and "svn" or other suffixes. string (REGEX REPLACE "([0-9]+)\\.([0-9]+).*" "\\1\\2" OSL_LLVM_VERSION ${LLVM_VERSION}) -add_definitions (-DOSL_LLVM_VERSION=${OSL_LLVM_VERSION}) -add_definitions (-DOSL_LLVM_FULL_VERSION="${LLVM_VERSION}") +add_compile_definitions (OSL_LLVM_VERSION=${OSL_LLVM_VERSION}) +add_compile_definitions (OSL_LLVM_FULL_VERSION="${LLVM_VERSION}") if (LLVM_NAMESPACE) - add_definitions ("-DLLVM_NAMESPACE=${LLVM_NAMESPACE}") + add_compile_definitions (LLVM_NAMESPACE=${LLVM_NAMESPACE}) endif () if (APPLE AND LLVM_VERSION VERSION_EQUAL 10.0.1 AND EXISTS "/usr/local/Cellar/llvm") message (WARNING @@ -118,7 +118,7 @@ endif () # Use opaque pointers starting with LLVM 16 if (${LLVM_VERSION} VERSION_GREATER_EQUAL 16.0) set(LLVM_OPAQUE_POINTERS ON) - add_definitions (-DOSL_LLVM_OPAQUE_POINTERS) + add_compile_definitions (OSL_LLVM_OPAQUE_POINTERS) else() set(LLVM_OPAQUE_POINTERS OFF) endif() @@ -126,7 +126,7 @@ endif() # Enable new pass manager for LLVM 16+ if (${LLVM_VERSION} VERSION_GREATER_EQUAL 16.0) set(LLVM_NEW_PASS_MANAGER ON) - add_definitions (-DOSL_LLVM_NEW_PASS_MANAGER) + add_compile_definitions (OSL_LLVM_NEW_PASS_MANAGER) else() set(LLVM_NEW_PASS_MANAGER OFF) endif() @@ -215,7 +215,7 @@ if (OSL_USE_OPTIX) function (osl_optix_target TARGET) target_include_directories (${TARGET} BEFORE PRIVATE ${CUDA_INCLUDES} ${OPTIX_INCLUDES}) ## XXX: Should -DPTX_PATH point to (or include) CMAKE_CURRENT_BINARY_DIR so tests can run before installation ? - target_compile_definitions (${TARGET} PRIVATE "-DPTX_PATH=\"${OSL_PTX_INSTALL_DIR}\"") + target_compile_definitions (${TARGET} PRIVATE PTX_PATH="${OSL_PTX_INSTALL_DIR}") target_link_libraries (${TARGET} PRIVATE ${CUDA_LIBRARIES} ${CUDA_EXTRA_LIBS} ${OPTIX_LIBRARIES} ${OPTIX_EXTRA_LIBS}) endfunction() else () diff --git a/src/cmake/flexbison.cmake b/src/cmake/flexbison.cmake index b7db6ed94..0c9bb07dd 100644 --- a/src/cmake/flexbison.cmake +++ b/src/cmake/flexbison.cmake @@ -41,7 +41,7 @@ if ( FLEX_EXECUTABLE AND BISON_EXECUTABLE ) macro ( FLEX_BISON flexsrc bisonsrc prefix srclist compiler_headers ) # mangle osoparse & oslparse symbols to avoid multiple library conflicts # XXX: This may be excessive now that OSL::pvt::ExtraArg is mangled into the function signature - add_definitions(-D${prefix}parse=${PROJ_NAMESPACE_V}_${prefix}parse) + add_compile_definitions(${prefix}parse=${PROJ_NAMESPACE_V}_${prefix}parse) message (VERBOSE "FLEX_BISON flex=${flexsrc} bison=${bisonsrc} prefix=${prefix}") get_filename_component ( bisonsrc_we ${bisonsrc} NAME_WE ) diff --git a/src/liboslexec/CMakeLists.txt b/src/liboslexec/CMakeLists.txt index 328565af6..517706419 100644 --- a/src/liboslexec/CMakeLists.txt +++ b/src/liboslexec/CMakeLists.txt @@ -211,7 +211,7 @@ if (USE_LLVM_BITCODE) EMBED_LLVM_BITCODE_IN_CPP ( "${rs_dependent_ops_srcs}" "_host_rs" "osl_llvm_compiled_rs_dependent_ops" lib_src "" "${include_dirs}") if (CUDA_FOUND) - add_definitions (-DOSL_LLVM_CUDA_BITCODE) + add_compile_definitions (OSL_LLVM_CUDA_BITCODE) # The shadeops are compiled to both LLVM bitcode and PTX, and embedded # in liboslexec in binary format. The bitcode is used to seed the LLVM @@ -255,7 +255,7 @@ else () # With MSVC/Mingw, we don't compile llvm_ops.cpp to LLVM bitcode, due # to clang being unable to compile MSVC C++ header files at this time. # Instead it is part of the regular build process. - add_definitions (-DOSL_LLVM_NO_BITCODE) + add_compile_definitions (OSL_LLVM_NO_BITCODE) set (lib_src ${lib_src} llvm_ops.cpp) endif () diff --git a/src/testrender/CMakeLists.txt b/src/testrender/CMakeLists.txt index 5f72bfbdb..c48808f92 100644 --- a/src/testrender/CMakeLists.txt +++ b/src/testrender/CMakeLists.txt @@ -33,7 +33,7 @@ if (OSL_USE_OPTIX) endforeach () # Compile the renderer-supplied shadeops (rend_lib) to LLVM bitcode and PTX - add_definitions (-DOSL_LLVM_CUDA_BITCODE) + add_compile_definitions (OSL_LLVM_CUDA_BITCODE) CUDA_SHADEOPS_COMPILE ( "rend_lib_testrender" rend_lib_bc rend_lib_ptx diff --git a/src/testshade/CMakeLists.txt b/src/testshade/CMakeLists.txt index 88d710166..cecc1b85e 100644 --- a/src/testshade/CMakeLists.txt +++ b/src/testshade/CMakeLists.txt @@ -38,7 +38,7 @@ if (OSL_USE_OPTIX) endforeach () # Compile the renderer-supplied shadeops (rend_lib) to LLVM bitcode and PTX - add_definitions (-DOSL_LLVM_CUDA_BITCODE) + add_compile_definitions (OSL_LLVM_CUDA_BITCODE) CUDA_SHADEOPS_COMPILE ( "rend_lib_testshade" rend_lib_bc rend_lib_ptx From b865cb0258e8f6a5e8a446c3f64a2f97d421a33d Mon Sep 17 00:00:00 2001 From: Larry Gritz Date: Mon, 29 Jul 2024 08:27:03 -0700 Subject: [PATCH 14/17] build: port set_utils and dependency_utils from oiio cmake scripts (#1845) For those who didn't see this get added in OIIO land a few months back, the highlights are: * set_utils.cmake -- variable setting utilities, including replacements/wrappers for set(CACHE) and option() that have a few extra bells and whistles, including that they allow environment variables of the same name to override the default values. * dependency_utils.cmake -- moved the prior contents of checked_find_package.cmake here, added more features, including... * An end-of-config dependency report that prints which dependencies were found and their versions, which were found but were too old, which were missing. * The skeleton of an automatic local dependency build facility. The short story is that if a dependency is not found or is too old AND it can find a file called src/cmake/build_PACKAGE.cmake, it will run that file and expect it to download and build the dependency on the fly. I haven't added any of those scripts here yet, but on the OIIO side we already have a few to build certain critical dependencies. Future PRs to OSL will also add the missing pieces to build the dependencies. Signed-off-by: Larry Gritz --- CMakeLists.txt | 44 +- src/cmake/checked_find_package.cmake | 211 --------- src/cmake/colors.cmake | 5 + src/cmake/dependency_utils.cmake | 620 +++++++++++++++++++++++++++ src/cmake/set_utils.cmake | 123 ++++++ 5 files changed, 783 insertions(+), 220 deletions(-) delete mode 100644 src/cmake/checked_find_package.cmake create mode 100644 src/cmake/dependency_utils.cmake create mode 100644 src/cmake/set_utils.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 51d50ebd2..a0d7af7ce 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,6 +39,28 @@ if (CMAKE_VERSION VERSION_LESS 3.21) endif () endif () +# Set up module path for our own cmake modules and add some esential ones +list (APPEND CMAKE_MODULE_PATH + "${PROJECT_SOURCE_DIR}/src/cmake/modules" + "${PROJECT_SOURCE_DIR}/src/cmake") + +# Utilities +include (colors) +include (set_utils) +include (check_is_enabled) +include (fancy_add_executable) + +# If the user wants to use Conan to build dependencies, they will have done +# this prior to the cmake config: +# cd +# conan install +# and that will leave a conanbuildinfo.cmake in the build area for us. +if (EXISTS ${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) + include (${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) + message (STATUS "Using Conan for dependencies") + conan_basic_setup() +endif() + if (NOT CMAKE_BUILD_TYPE) set (CMAKE_BUILD_TYPE "Release") endif () @@ -60,6 +82,7 @@ message (STATUS "Project build dir = ${CMAKE_BINARY_DIR}") message (STATUS "Project install prefix = ${CMAKE_INSTALL_PREFIX}") message (STATUS "Configuration types = ${CMAKE_CONFIGURATION_TYPES}") message (STATUS "Build type = ${CMAKE_BUILD_TYPE}") +message (STATUS "Supported release = ${${PROJECT_NAME}_SUPPORTED_RELEASE}") # Make the build area layout look a bit more like the final dist layout set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) @@ -70,7 +93,6 @@ if ("${PROJECT_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}") message (FATAL_ERROR "Not allowed to run in-source build!") endif () - option (CMAKE_USE_FOLDERS "Use the FOLDER target property to organize targets into folders." ON) mark_as_advanced (CMAKE_USE_FOLDERS) if (CMAKE_USE_FOLDERS) @@ -158,22 +180,24 @@ if (${PROJ_NAME}_NAMESPACE_INCLUDE_PATCH) endif () message(STATUS "Setting Namespace to: ${PROJ_NAMESPACE_V}") +# Define OSL_INTERNAL symbol only when building OSL itself, will not be +# defined for downstream projects using OSL. +add_definitions (-DOSL_INTERNAL=1) -list (APPEND CMAKE_MODULE_PATH - "${PROJECT_SOURCE_DIR}/src/cmake/modules" - "${PROJECT_SOURCE_DIR}/src/cmake") - -# Helpful functions and macros for our project -include (colors) -include (check_is_enabled) -include (checked_find_package) +# To make sure we aren't relying on deprecated OIIO features, we define +# OIIO_DISABLE_DEPRECATED before including any OIIO headers. +add_definitions (-DOIIO_DISABLE_DEPRECATED=900000) # All the C++ and compiler related options and adjustments include (compiler) +# Dependency finding utilities and all dependency-related options +include (dependency_utils) + # Utilities and options related to finding python and making python bindings include (pythonutils) +# Dependency finding utilities and all dependency-related options include (externalpackages) include (flexbison) include (cuda_macros) @@ -311,3 +335,5 @@ endif () if (PROJECT_IS_TOP_LEVEL) include (packaging) endif () + +print_package_notfound_report () diff --git a/src/cmake/checked_find_package.cmake b/src/cmake/checked_find_package.cmake deleted file mode 100644 index f42771610..000000000 --- a/src/cmake/checked_find_package.cmake +++ /dev/null @@ -1,211 +0,0 @@ -# Copyright Contributors to the Open Shading Language project. -# SPDX-License-Identifier: BSD-3-Clause -# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage - - -set (REQUIRED_DEPS "" CACHE STRING - "Additional dependencies to consider required (semicolon-separated list, or ALL)") -set (OPTIONAL_DEPS "" CACHE STRING - "Additional dependencies to consider optional (semicolon-separated list, or ALL)") -option (ALWAYS_PREFER_CONFIG "Prefer a dependency's exported config file if it's available" OFF) - - -# Utility function to list the names and values of all variables matching -# the pattern (case-insensitive) -function (dump_matching_variables pattern) - string (TOLOWER ${pattern} _pattern_lower) - get_cmake_property(_allvars VARIABLES) - list (SORT _allvars) - foreach (_var IN LISTS _allvars) - string (TOLOWER ${_var} _var_lower) - if (_var_lower MATCHES ${_pattern_lower}) - message (STATUS " ${_var} = ${${_var}}") - endif () - endforeach () -endfunction () - - - -# checked_find_package(Pkgname ...) is a wrapper for find_package, with the -# following extra features: -# * If either `USE_Pkgname` or the all-uppercase `USE_PKGNAME` (or -# `ENABLE_Pkgname` or `ENABLE_PKGNAME`) exists as either a CMake or -# environment variable, is nonempty by contains a non-true/nonzero -# value, do not search for or use the package. The optional ENABLE -# arguments allow you to override the name of the enabling variable. In -# other words, support for the dependency is presumed to be ON, unless -# turned off explicitly from one of these sources. -# * Print a message if the package is enabled but not found. This is based -# on ${Pkgname}_FOUND or $PKGNAME_FOUND. -# * Optional DEFINITIONS ... are passed to add_compile_definitions if the -# package is found. -# * Optional SETVARIABLES ... is a list of CMake variables to set to -# TRUE if the package is found (they will not be set or changed if the -# package is not found). -# * Optional PRINT is a list of variables that will be printed -# if the package is found, if VERBOSE is on. -# * Optional DEPS is a list of hard dependencies; for each one, if -# dep_FOUND is not true, disable this package with an error message. -# * Optional ISDEPOF names another package for which the -# present package is only needed because it's a dependency, and -# therefore if is disabled, we don't bother with this -# package either. -# * Optional VERSION_MIN and VERSION_MAX, if supplied, give minimum and -# maximum versions that will be accepted. The min is inclusive, the max -# is exclusive (i.e., check for min <= version < max). Note that this is -# not the same as providing a version number to find_package, which -# checks compatibility, not minimum. Sometimes we really do just want to -# say a minimum or a range. (N.B. When our minimum CMake >= 3.19, the -# built-in way to do this is with version ranges passed to -# find_package.) -# * Optional RECOMMEND_MIN, if supplied, gives a minimum recommended -# version, accepting but warning if it is below this number (even -# if above the true minimum version accepted). The warning message -# can give an optional explanation, passed as RECOMMEND_MIN_REASON. -# * Optional PREFER_CONFIG, if supplied, tries to use an exported config -# file from the package before using a FindPackage.cmake module. -# * Optional DEBUG turns on extra debugging information related to how -# this package is found. -# * If either the optional PREFER_STATIC_LIBS argument to this macro, *or* -# CMake variable _PREFER_STATIC_LIBS is true, then try to prefer -# static versions of any libraries found. -# -# N.B. This needs to be a macro, not a function, because the find modules -# will set(blah val PARENT_SCOPE) and we need that to be the global scope, -# not merely the scope for this function. -macro (checked_find_package pkgname) - cmake_parse_arguments(_pkg # prefix - # noValueKeywords: - "REQUIRED;PREFER_CONFIG;DEBUG;PREFER_STATIC_LIBS" - # singleValueKeywords: - "ENABLE;ISDEPOF;VERSION_MIN;VERSION_MAX;RECOMMEND_MIN;RECOMMEND_MIN_REASON" - # multiValueKeywords: - "DEFINITIONS;PRINT;DEPS;SETVARIABLES" - # argsToParse: - ${ARGN}) - string (TOLOWER ${pkgname} pkgname_lower) - string (TOUPPER ${pkgname} pkgname_upper) - set (_pkg_VERBOSE ${VERBOSE}) - if (_pkg_DEBUG) - set (_pkg_VERBOSE ON) - endif () - if (NOT _pkg_VERBOSE) - set (${pkgname}_FIND_QUIETLY true) - set (${pkgname_upper}_FIND_QUIETLY true) - endif () - if ("${pkgname}" IN_LIST REQUIRED_DEPS OR "ALL" IN_LIST REQUIRED_DEPS) - set (_pkg_REQUIRED 1) - endif () - if ("${pkgname}" IN_LIST OPTIONAL_DEPS OR "ALL" IN_LIST OPTIONAL_DEPS) - set (_pkg_REQUIRED 0) - endif () - set (_quietskip false) - check_is_enabled (${pkgname} _enable) - set (_disablereason "") - foreach (_dep ${_pkg_DEPS}) - if (_enable AND NOT ${_dep}_FOUND) - set (_enable false) - set (ENABLE_${pkgname} OFF PARENT_SCOPE) - set (_disablereason "(because ${_dep} was not found)") - endif () - endforeach () - if (_pkg_ISDEPOF) - check_is_enabled (${_pkg_ISDEPOF} _dep_enabled) - if (NOT _dep_enabled) - set (_enable false) - set (_quietskip true) - endif () - endif () - set (_config_status "") - if (_enable OR _pkg_REQUIRED) - set (save_lib_path ${CMAKE_FIND_LIBRARY_SUFFIXES}) - if (_pkg_PREFER_STATIC_LIBS OR ${pkgname}_PREFER_STATIC_LIBS) - set (CMAKE_FIND_LIBRARY_SUFFIXES .lib .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) - endif () - if (${pkgname}_FOUND OR ${pkgname_upper}_FOUND) - # was already found - elseif (_pkg_PREFER_CONFIG OR ALWAYS_PREFER_CONFIG) - find_package (${pkgname} CONFIG ${_pkg_UNPARSED_ARGUMENTS}) - if (${pkgname}_FOUND OR ${pkgname_upper}_FOUND) - set (_config_status "from CONFIG") - endif () - endif () - if (NOT (${pkgname}_FOUND OR ${pkgname_upper}_FOUND)) - find_package (${pkgname} ${_pkg_UNPARSED_ARGUMENTS}) - endif() - set (CMAKE_FIND_LIBRARY_SUFFIXES ${save_lib_path}) - unset (save_lib_path) - if ((${pkgname}_FOUND OR ${pkgname_upper}_FOUND) - AND ${pkgname}_VERSION - AND (_pkg_VERSION_MIN OR _pkg_VERSION_MAX)) - if ((_pkg_VERSION_MIN AND ${pkgname}_VERSION VERSION_LESS _pkg_VERSION_MIN) - OR (_pkg_VERSION_MAX AND ${pkgname}_VERSION VERSION_GREATER _pkg_VERSION_MAX)) - message (STATUS "${ColorRed}${pkgname} ${${pkgname}_VERSION} is outside the required range ${_pkg_VERSION_MIN}...${_pkg_VERSION_MAX} ${ColorReset}") - unset (${pkgname}_FOUND) - unset (${pkgname}_VERSION) - unset (${pkgname_upper}_FOUND) - unset (${pkgname_upper}_VERSION) - endif () - endif () - if (${pkgname}_FOUND OR ${pkgname_upper}_FOUND) - foreach (_vervar ${pkgname_upper}_VERSION ${pkgname}_VERSION_STRING - ${pkgname_upper}_VERSION_STRING) - if (NOT ${pkgname}_VERSION AND ${_vervar}) - set (${pkgname}_VERSION ${${_vervar}}) - endif () - endforeach () - message (STATUS "${ColorGreen}Found ${pkgname} ${${pkgname}_VERSION} ${_config_status}${ColorReset}") - add_compile_definitions (${_pkg_DEFINITIONS}) - foreach (_v IN LISTS _pkg_SETVARIABLES) - set (${_v} TRUE) - endforeach () - if (_pkg_RECOMMEND_MIN) - if (${${pkgname}_VERSION} VERSION_LESS ${_pkg_RECOMMEND_MIN}) - message (STATUS "${ColorYellow}Recommend ${pkgname} >= ${_pkg_RECOMMEND_MIN} ${_pkg_RECOMMEND_MIN_REASON} ${ColorReset}") - endif () - endif () - else () - message (STATUS "${ColorRed}${pkgname} library not found ${ColorReset}") - if (${pkgname}_ROOT) - message (STATUS "${ColorRed} ${pkgname}_ROOT was: ${${pkgname}_ROOT} ${ColorReset}") - elseif ($ENV{${pkgname}_ROOT}) - message (STATUS "${ColorRed} ENV ${pkgname}_ROOT was: ${${pkgname}_ROOT} ${ColorReset}") - else () - message (STATUS "${ColorRed} Try setting ${pkgname}_ROOT ? ${ColorReset}") - endif () - if (EXISTS "${PROJECT_SOURCE_DIR}/src/build-scripts/build_${pkgname}.bash") - message (STATUS "${ColorRed} Maybe this will help: src/build-scripts/build_${pkgname}.bash ${ColorReset}") - elseif (EXISTS "${PROJECT_SOURCE_DIR}/src/build-scripts/build_${pkgname_upper}.bash") - message (STATUS "${ColorRed} Maybe this will help: src/build-scripts/build_${pkgname_upper}.bash ${ColorReset}") - elseif (EXISTS "${PROJECT_SOURCE_DIR}/src/build-scripts/build_${pkgname_lower}.bash") - message (STATUS "${ColorRed} Maybe this will help: src/build-scripts/build_${pkgname_lower}.bash ${ColorReset}") - elseif (EXISTS "${PROJECT_SOURCE_DIR}/src/build-scripts/build_lib${pkgname_lower}.bash") - message (STATUS "${ColorRed} Maybe this will help: src/build-scripts/build_lib${pkgname_lower}.bash ${ColorReset}") - endif () - if (_pkg_REQUIRED) - message (FATAL_ERROR "${ColorRed}${pkgname} is required, aborting.${ColorReset}") - endif () - endif() - if (_pkg_VERBOSE AND (${pkgname}_FOUND OR ${pkgname_upper}_FOUND OR _pkg_DEBUG)) - if (_pkg_DEBUG) - dump_matching_variables (${pkgname}) - endif () - set (_vars_to_print ${pkgname}_INCLUDES ${pkgname_upper}_INCLUDES - ${pkgname}_INCLUDE_DIR ${pkgname_upper}_INCLUDE_DIR - ${pkgname}_INCLUDE_DIRS ${pkgname_upper}_INCLUDE_DIRS - ${pkgname}_LIBRARIES ${pkgname_upper}_LIBRARIES - ${_pkg_PRINT}) - list (REMOVE_DUPLICATES _vars_to_print) - foreach (_v IN LISTS _vars_to_print) - if (NOT "${${_v}}" STREQUAL "") - message (STATUS " ${_v} = ${${_v}}") - endif () - endforeach () - endif () - else () - if (NOT _quietskip) - message (STATUS "${ColorRed}Not using ${pkgname} -- disabled ${_disablereason} ${ColorReset}") - endif () - endif () -endmacro() - diff --git a/src/cmake/colors.cmake b/src/cmake/colors.cmake index 0b0621e59..2ea817f03 100644 --- a/src/cmake/colors.cmake +++ b/src/cmake/colors.cmake @@ -9,4 +9,9 @@ set (ColorReset "${ColorEsc}[m") set (ColorRed "${ColorEsc}[31m") set (ColorGreen "${ColorEsc}[32m") set (ColorYellow "${ColorEsc}[33m") +set (ColorBlue "${ColorEsc}[34m") +set (ColorMagenta "${ColorEsc}[35m") +set (ColorBoldRed "${ColorEsc}[1;31m") +set (ColorBoldGreen "${ColorEsc}[1;32m") +set (ColorBoldYellow "${ColorEsc}[1;33m") set (ColorBoldWhite "${ColorEsc}[1;37m") diff --git a/src/cmake/dependency_utils.cmake b/src/cmake/dependency_utils.cmake new file mode 100644 index 000000000..e83e980e6 --- /dev/null +++ b/src/cmake/dependency_utils.cmake @@ -0,0 +1,620 @@ +# Copyright Contributors to the Open Shading Language project. +# SPDX-License-Identifier: BSD-3-Clause +# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage + + +set_cache (${PROJECT_NAME}_REQUIRED_DEPS "" + "Additional dependencies to consider required (semicolon-separated list, or ALL)") +set_cache (${PROJECT_NAME}_OPTIONAL_DEPS "" + "Additional dependencies to consider optional (semicolon-separated list, or ALL)") +set_option (${PROJECT_NAME}_ALWAYS_PREFER_CONFIG + "Prefer a dependency's exported config file if it's available" OFF) + +set_cache (${PROJECT_NAME}_BUILD_MISSING_DEPS "" + "Try to download and build any of these missing dependencies (or 'all')") +set_cache (${PROJECT_NAME}_BUILD_LOCAL_DEPS "" + "Force local builds of these dependencies if possible (or 'all')") + +set_cache (${PROJECT_NAME}_LOCAL_DEPS_ROOT "${PROJECT_BINARY_DIR}/deps" + "Directory were we do local builds of dependencies") +list (APPEND CMAKE_PREFIX_PATH ${${PROJECT_NAME}_LOCAL_DEPS_ROOT}/dist) +include_directories(BEFORE ${${PROJECT_NAME}_LOCAL_DEPS_ROOT}/include) + +# Build type for locally built dependencies. Default to the same build type +# as the current project. +set_cache (${PROJECT_NAME}_DEPENDENCY_BUILD_TYPE ${CMAKE_BUILD_TYPE} + "Build type for locally built dependencies") +set_option (${PROJECT_NAME}_DEPENDENCY_BUILD_VERBOSE + "Make dependency builds extra verbose" OFF) +if (MSVC) + # I haven't been able to get Windows local dependency builds to work with + # static libraries, so default to shared libraries on Windows until we can + # figure it out. + set_cache (LOCAL_BUILD_SHARED_LIBS_DEFAULT ON + DOC "Should a local dependency build, if necessary, build shared libraries" ADVANCED) +else () + # On non-Windows, default to static libraries for local builds. + set_cache (LOCAL_BUILD_SHARED_LIBS_DEFAULT OFF + DOC "Should a local dependency build, if necessary, build shared libraries" ADVANCED) +endif () + + +# Track all build deps we find with checked_find_package +set (CFP_ALL_BUILD_DEPS_FOUND "") +set (CFP_EXTERNAL_BUILD_DEPS_FOUND "") + +# Track all build deps we failed to find with checked_find_package +set (CFP_ALL_BUILD_DEPS_NOTFOUND "") +set (CFP_LOCALLY_BUILDABLE_DEPS_NOTFOUND "") + +# Track all build deps we found but were of inadequate version +set (CFP_ALL_BUILD_DEPS_BADVERSION "") +set (CFP_LOCALLY_BUILDABLE_DEPS_BADVERSION "") + +# Which dependencies did we build locally +set (CFP_LOCALLY_BUILT_DEPS "") + + + +# Utility function to list the names and values of all variables matching +# the pattern (case-insensitive) +function (dump_matching_variables pattern) + string (TOLOWER ${pattern} _pattern_lower) + get_cmake_property(_allvars VARIABLES) + list (SORT _allvars) + foreach (_var IN LISTS _allvars) + string (TOLOWER ${_var} _var_lower) + if (_var_lower MATCHES ${_pattern_lower}) + message (STATUS " ${_var} = ${${_var}}") + endif () + endforeach () +endfunction () + + +# Helper: Print a report about missing dependencies and give insructions on +# how to turn on automatic local dependency building. +function (print_package_notfound_report) + message (STATUS) + message (STATUS "${ColorBoldYellow}=========================================================================${ColorReset}") + message (STATUS "${ColorBoldYellow}= Dependency report =${ColorReset}") + message (STATUS "${ColorBoldYellow}=========================================================================${ColorReset}") + message (STATUS) + if (CFP_EXTERNAL_BUILD_DEPS_FOUND) + message (STATUS "${ColorBoldWhite}The following dependencies were found externally:${ColorReset}") + list (SORT CFP_EXTERNAL_BUILD_DEPS_FOUND CASE INSENSITIVE) + list (REMOVE_DUPLICATES CFP_EXTERNAL_BUILD_DEPS_FOUND) + foreach (_pkg IN LISTS CFP_EXTERNAL_BUILD_DEPS_FOUND) + message (STATUS " ${_pkg} ${${_pkg}_VERSION}") + endforeach () + endif () + if (CFP_ALL_BUILD_DEPS_BADVERSION) + message (STATUS "${ColorBoldWhite}The following dependencies were found but were too old:${ColorReset}") + list (SORT CFP_ALL_BUILD_DEPS_BADVERSION CASE INSENSITIVE) + list (REMOVE_DUPLICATES CFP_ALL_BUILD_DEPS_BADVERSION) + foreach (_pkg IN LISTS CFP_ALL_BUILD_DEPS_BADVERSION) + if (_pkg IN_LIST CFP_LOCALLY_BUILT_DEPS) + message (STATUS " ${_pkg} ${${_pkg}_NOT_FOUND_EXPLANATION} ${ColorMagenta}(${${_pkg}_VERSION} BUILT LOCALLY)${ColorReset}") + else () + message (STATUS " ${_pkg} ${${_pkg}_NOT_FOUND_EXPLANATION}") + endif () + endforeach () + endif () + if (CFP_ALL_BUILD_DEPS_NOTFOUND) + message (STATUS "${ColorBoldWhite}The following dependencies were not found:${ColorReset}") + list (SORT CFP_ALL_BUILD_DEPS_NOTFOUND CASE INSENSITIVE) + list (REMOVE_DUPLICATES CFP_ALL_BUILD_DEPS_NOTFOUND) + foreach (_pkg IN LISTS CFP_ALL_BUILD_DEPS_NOTFOUND) + if (_pkg IN_LIST CFP_LOCALLY_BUILT_DEPS) + message (STATUS " ${_pkg} ${_${_pkg}_version_range} ${${_pkg}_NOT_FOUND_EXPLANATION} ${ColorMagenta}(${${_pkg}_VERSION} BUILT LOCALLY)${ColorReset}") + else () + message (STATUS " ${_pkg} ${_${_pkg}_version_range} ${${_pkg}_NOT_FOUND_EXPLANATION}") + endif () + endforeach () + endif () + if (CFP_LOCALLY_BUILDABLE_DEPS_NOTFOUND OR CFP_LOCALLY_BUILDABLE_DEPS_BADVERSION) + message (STATUS) + message (STATUS "${ColorBoldWhite}For some of these, we can build them locally:${ColorReset}") + foreach (_pkg IN LISTS CFP_LOCALLY_BUILDABLE_DEPS_NOTFOUND CFP_LOCALLY_BUILDABLE_DEPS_BADVERSION) + message (STATUS " ${_pkg}") + endforeach () + message (STATUS "${ColorBoldWhite}To build them automatically if not found, build again with option:${ColorReset}") + message (STATUS " ${ColorBoldGreen}-D${PROJECT_NAME}_BUILD_MISSING_DEPS=all${ColorReset}") + endif () + message (STATUS) + message (STATUS "${ColorBoldYellow}=========================================================================${ColorReset}") + message (STATUS) +endfunction () + + + +# Helper: called if a package is not found, print error messages, including +# a fatal error if the package was required. +function (handle_package_notfound pkgname required) + message (STATUS "${ColorRed}${pkgname} library not found ${ColorReset}") + if (${pkgname}_ROOT) + message (STATUS " ${pkgname}_ROOT was: ${${pkgname}_ROOT}") + elseif ($ENV{${pkgname}_ROOT}) + message (STATUS " ENV ${pkgname}_ROOT was: ${${pkgname}_ROOT}") + else () + message (STATUS " Try setting ${pkgname}_ROOT ?") + endif () + if (EXISTS "${PROJECT_SOURCE_DIR}/src/build-scripts/build_${pkgname}.bash") + message (STATUS " Maybe this will help: src/build-scripts/build_${pkgname}.bash") + elseif (EXISTS "${PROJECT_SOURCE_DIR}/src/build-scripts/build_${pkgname_upper}.bash") + message (STATUS " Maybe this will help: src/build-scripts/build_${pkgname_upper}.bash") + elseif (EXISTS "${PROJECT_SOURCE_DIR}/src/build-scripts/build_${pkgname_lower}.bash") + message (STATUS " Maybe this will help: src/build-scripts/build_${pkgname_lower}.bash") + elseif (EXISTS "${PROJECT_SOURCE_DIR}/src/build-scripts/build_lib${pkgname_lower}.bash") + message (STATUS " Maybe this will help: src/build-scripts/build_lib${pkgname_lower}.bash") + endif () + if (required) + print_package_notfound_report() + message (FATAL_ERROR "${pkgname} is required, aborting.") + endif () +endfunction () + + +# Check whether the package's version (in pkgversion) lies within versionmin +# and versionmax (inclusive). Store TRUE result variable if the version was in +# range, FALSE if it was out of range. If it did not match, clear a bunch of +# variables that may have been set by the find_package call (including +# clearing the package's FOUND variable). +function (reject_out_of_range_versions pkgname pkgversion versionmin versionmax result) + set (${result} FALSE PARENT_SCOPE) + string (TOUPPER ${pkgname} pkgname_upper) + # message (STATUS "roorv: ${pkgname} ${pkgversion} ${versionmin} ${versionmax}") + if (NOT ${pkgname}_FOUND AND NOT ${pkgname_upper}_FOUND) + message (STATUS "${pkgname} was not found") + elseif ("${pkgversion}" STREQUAL "") + message (ERROR "${pkgname} found but version was empty") + elseif (pkgversion VERSION_LESS versionmin + OR pkgversion VERSION_GREATER versionmax) + # message (STATUS "${ColorRed}${pkgname} ${pkgversion} is outside the required range ${versionmin}...${versionmax} ${ColorReset}") + # list (APPEND CFP_ALL_BUILD_DEPS_BADVERSION ${pkgname}) + # if (${pkgname}_local_build_script_exists) + # list (APPEND CFP_LOCALLY_BUILDABLE_DEPS_BADVERSION ${pkgname}) + # endif () + if (versionmax VERSION_GREATER_EQUAL 10000) + set (${pkgname}_NOT_FOUND_EXPLANATION + "(found ${pkgversion}, needed >= ${versionmin})" PARENT_SCOPE) + else () + set (${pkgname}_NOT_FOUND_EXPLANATION + "(found ${pkgversion}, needed ${versionmin} ... ${versionmax})" PARENT_SCOPE) + endif () + unset (${pkgname}_FOUND PARENT_SCOPE) + unset (${pkgname}_VERSION PARENT_SCOPE) + unset (${pkgname}_INCLUDE PARENT_SCOPE) + unset (${pkgname}_INCLUDES PARENT_SCOPE) + unset (${pkgname}_LIBRARY PARENT_SCOPE) + unset (${pkgname}_LIBRARIES PARENT_SCOPE) + unset (${pkgname_upper}_FOUND PARENT_SCOPE) + unset (${pkgname_upper}_VERSION PARENT_SCOPE) + unset (${pkgname_upper}_INCLUDE PARENT_SCOPE) + unset (${pkgname_upper}_INCLUDES PARENT_SCOPE) + unset (${pkgname_upper}_LIBRARY PARENT_SCOPE) + unset (${pkgname_upper}_LIBRARIES PARENT_SCOPE) + else () + # Version matched the range + set (${result} TRUE PARENT_SCOPE) + # message (STATUS "${pkgname} ${pkgversion} is INSIDE the required range ${versionmin}...${versionmax}") + endif () +endfunction () + + + +# checked_find_package(Pkgname ...) is a wrapper for find_package, with the +# following extra features: +# * If either `USE_Pkgname` or the all-uppercase `USE_PKGNAME` (or +# `ENABLE_Pkgname` or `ENABLE_PKGNAME`) exists as either a CMake or +# environment variable, is nonempty by contains a non-true/nonzero +# value, do not search for or use the package. The optional ENABLE +# arguments allow you to override the name of the enabling variable. In +# other words, support for the dependency is presumed to be ON, unless +# turned off explicitly from one of these sources. +# * Print a message if the package is enabled but not found. This is based +# on ${Pkgname}_FOUND or $PKGNAME_FOUND. +# * Optional DEFINITIONS ... are passed to add_compile_definitions +# if the package is found. +# * Optional SETVARIABLES ... is a list of CMake variables to set to +# TRUE if the package is found (they will not be set or changed if the +# package is not found). +# * Optional PRINT is a list of variables that will be printed +# if the package is found, if VERBOSE is on. +# * Optional DEPS is a list of hard dependencies; for each one, if +# dep_FOUND is not true, disable this package with an error message. +# * Optional ISDEPOF names another package for which the +# present package is only needed because it's a dependency, and +# therefore if is disabled, we don't bother with this +# package either. +# * Optional VERSION_MIN and VERSION_MAX, if supplied, give minimum and +# maximum versions that will be accepted. The min is inclusive, the max +# is exclusive (i.e., check for min <= version < max). Note that this is +# not the same as providing a version number to find_package, which +# checks compatibility, not minimum. Sometimes we really do just want to +# say a minimum or a range. (N.B. When our minimum CMake >= 3.19, the +# built-in way to do this is with version ranges passed to +# find_package.) +# * Optional RECOMMEND_MIN, if supplied, gives a minimum recommended +# version, accepting but warning if it is below this number (even +# if above the true minimum version accepted). The warning message +# can give an optional explanation, passed as RECOMMEND_MIN_REASON. +# * Optional CONFIG, if supplied, only accepts the package from an +# exported config and never uses a FindPackage.cmake module. +# * Optional PREFER_CONFIG, if supplied, tries to use an exported config +# file from the package before using a FindPackage.cmake module. +# * Optional DEBUG turns on extra debugging information related to how +# this package is found. +# * Found package "name version" or "name NONE" are accumulated in the list +# CFP_ALL_BUILD_DEPS_FOUND. If the optional NO_RECORD_NOTFOUND is +# supplied, un-found packags will not be recorded. +# * Optional BUILD_LOCAL, if supplied, if followed by a token that specifies +# the conditions under which to build the package locally by including a +# script included in src/cmake/build_${pkgname}.cmake. If the condition is +# "always", it will attempt to do so unconditionally. If "missing", it +# will only do so if the package is not found. Also note that if the +# global ${PROJECT_NAME}_BUILD_LOCAL_DEPS contains the package name or +# is "all", it will behave as if set to "always", and if the variable +# ${PROJECT_NAME}_BUILD_MISSING_DEPS contains the package name or is +# "all", it will behave as if set to "missing". +# * Optional NO_FP_RANGE_CHECK avoids passing the version range to +# find_package itself. +# +# Explanation about local builds: +# +# If the package isn't found externally in the usual places or doesn't meet +# the version criteria, we check for the existance of a file at +# `src/build-scripts/build_.cmake`. If that exists, we include and +# execute it. The script can do whatever it wants, but should either (a) +# somehow set up the link targets that would have been found had the package +# had been found, or (b) set the variable `_REFIND` to a true value +# and have done something to ensure that the package will be found if we try a +# second time. For (b), typically that might mean downloading the package and +# building it locally, and then setting the `_ROOT` to where it's +# installed. +# +# N.B. This needs to be a macro, not a function, because the find modules +# will set(blah val PARENT_SCOPE) and we need that to be the global scope, +# not merely the scope for this function. +macro (checked_find_package pkgname) + # + # Various setup logic + # + cmake_parse_arguments(_pkg # prefix + # noValueKeywords: + "REQUIRED;CONFIG;PREFER_CONFIG;DEBUG;NO_RECORD_NOTFOUND;NO_FP_RANGE_CHECK" + # singleValueKeywords: + "ENABLE;ISDEPOF;VERSION_MIN;VERSION_MAX;RECOMMEND_MIN;RECOMMEND_MIN_REASON;BUILD_LOCAL" + # multiValueKeywords: + "DEFINITIONS;PRINT;DEPS;SETVARIABLES" + # argsToParse: + ${ARGN}) + string (TOLOWER ${pkgname} pkgname_lower) + string (TOUPPER ${pkgname} pkgname_upper) + set (_pkg_VERBOSE ${VERBOSE}) + if (_pkg_DEBUG) + set (_pkg_VERBOSE ON) + endif () + if (NOT _pkg_VERBOSE) + set (${pkgname}_FIND_QUIETLY true) + set (${pkgname_upper}_FIND_QUIETLY true) + endif () + if ("${pkgname}" IN_LIST ${PROJECT_NAME}_REQUIRED_DEPS OR "ALL" IN_LIST ${PROJECT_NAME}_REQUIRED_DEPS) + set (_pkg_REQUIRED 1) + endif () + if ("${pkgname}" IN_LIST ${PROJECT_NAME}_OPTIONAL_DEPS OR "ALL" IN_LIST ${PROJECT_NAME}_OPTIONAL_DEPS) + set (_pkg_REQUIRED 0) + endif () + # string (TOLOWER "${_pkg_BUILD_LOCAL}" _pkg_BUILD_LOCAL) + if ("${pkgname}" IN_LIST ${PROJECT_NAME}_BUILD_LOCAL_DEPS + OR ${PROJECT_NAME}_BUILD_LOCAL_DEPS STREQUAL "all") + set (_pkg_BUILD_LOCAL "always") + elseif ("${pkgname}" IN_LIST ${PROJECT_NAME}_BUILD_MISSING_DEPS + OR ${PROJECT_NAME}_BUILD_MISSING_DEPS STREQUAL "all") + set_if_not (_pkg_BUILD_LOCAL "missing") + endif () + set (${pkgname}_local_build_script "${PROJECT_SOURCE_DIR}/src/cmake/build_${pkgname}.cmake") + if (EXISTS ${${pkgname}_local_build_script}) + set (${pkgname}_local_build_script_exists TRUE) + endif () + if (_pkg_BUILD_LOCAL AND NOT EXISTS "${${pkgname}_local_build_script}") + unset (_pkg_BUILD_LOCAL) + endif () + set (_quietskip false) + check_is_enabled (${pkgname} _enable) + set (_disablereason "") + foreach (_dep ${_pkg_DEPS}) + if (_enable AND NOT ${_dep}_FOUND) + set (_enable false) + set (ENABLE_${pkgname} OFF PARENT_SCOPE) + set (_disablereason "(because ${_dep} was not found)") + endif () + endforeach () + if (_pkg_ISDEPOF) + check_is_enabled (${_pkg_ISDEPOF} _dep_enabled) + if (NOT _dep_enabled) + set (_enable false) + set (_quietskip true) + endif () + endif () + set (_config_status "") + unset (_${pkgname}_version_range) + if (_pkg_BUILD_LOCAL AND NOT _pkg_NO_FP_RANGE_CHECK) + # SKIP THIS -- I find it unreliable because the package's exported + # PKGConfigVersion.cmake has might have arbitrary rules. Use our own + # MIN_VERSION and MAX_VERSION parameters to manually check instead. + # + if (_pkg_VERSION_MIN AND _pkg_VERSION_MAX AND CMAKE_VERSION VERSION_GREATER_EQUAL 3.19) + set (_${pkgname}_version_range "${_pkg_VERSION_MIN}...<${_pkg_VERSION_MAX}") + elseif (_pkg_VERSION_MIN) + set (_${pkgname}_version_range "${_pkg_VERSION_MIN}") + endif () + endif () + set_if_not (_pkg_VERSION_MIN "0.0.1") + set_if_not (_pkg_VERSION_MAX "10000.0.0") + # + # Now we try to find or build + # + set (${pkgname}_FOUND FALSE) + set (${pkgname}_LOCAL_BUILD FALSE) + if (_enable OR _pkg_REQUIRED) + # Unless instructed not to, try to find the package externally + # installed. + if (${pkgname}_FOUND OR ${pkgname_upper}_FOUND OR _pkg_BUILD_LOCAL STREQUAL "always") + # was already found, or we're forcing a local build + elseif (_pkg_CONFIG OR _pkg_PREFER_CONFIG OR ${PROJECT_NAME}_ALWAYS_PREFER_CONFIG) + find_package (${pkgname} ${_${pkgname}_version_range} CONFIG ${_pkg_UNPARSED_ARGUMENTS}) + reject_out_of_range_versions (${pkgname} "${${pkgname}_VERSION}" + ${_pkg_VERSION_MIN} ${_pkg_VERSION_MAX} + _pkg_version_in_range) + if (${pkgname}_FOUND OR ${pkgname_upper}_FOUND) + set (_config_status "from CONFIG") + endif () + endif () + if (NOT ${pkgname}_FOUND AND NOT ${pkgname_upper}_FOUND AND NOT _pkg_BUILD_LOCAL STREQUAL "always" AND NOT _pkg_CONFIG) + find_package (${pkgname} ${_${pkgname}_version_range} ${_pkg_UNPARSED_ARGUMENTS}) + endif() + if (NOT ${pkgname}_FOUND AND NOT ${pkgname_upper}_FOUND) + list (APPEND CFP_ALL_BUILD_DEPS_NOTFOUND ${pkgname}) + if (${pkgname}_local_build_script_exists) + list (APPEND CFP_LOCALLY_BUILDABLE_DEPS_NOTFOUND ${pkgname}) + endif () + endif () + # Some FindPackage modules set nonstandard variables for the versions + if (NOT ${pkgname}_VERSION AND ${pkgname_upper}_VERSION) + set (${pkgname}_VERSION ${${pkgname_upper}_VERSION}) + endif () + if (NOT ${pkgname}_VERSION AND ${pkgname_upper}_VERSION_STRING) + set (${pkgname}_VERSION ${${pkgname_upper}_VERSION_STRING}) + endif () + # If the package was found but the version is outside the required + # range, unset the relevant variables so that we can try again fresh. + if ((${pkgname}_FOUND OR ${pkgname_upper}_FOUND) AND ${pkgname}_VERSION) + reject_out_of_range_versions (${pkgname} ${${pkgname}_VERSION} + ${_pkg_VERSION_MIN} ${_pkg_VERSION_MAX} + _pkg_version_in_range) + if (_pkg_version_in_range) + list (APPEND CFP_EXTERNAL_BUILD_DEPS_FOUND ${pkgname}) + else () + message (STATUS "${ColorRed}${pkgname} ${${pkgname}_VERSION} is outside the required range ${_pkg_VERSION_MIN}...${_pkg_VERSION_MAX} ${ColorReset}") + list (APPEND CFP_ALL_BUILD_DEPS_BADVERSION ${pkgname}) + if (${pkgname}_local_build_script_exists) + list (APPEND CFP_LOCALLY_BUILDABLE_DEPS_BADVERSION ${pkgname}) + endif () + endif () + endif () + # If we haven't found the package yet and are allowed to build a local + # version, and a build_.cmake exists, include it to build the + # package locally. + if (NOT ${pkgname}_FOUND AND NOT ${pkgname_upper}_FOUND + AND (_pkg_BUILD_LOCAL STREQUAL "always" OR _pkg_BUILD_LOCAL STREQUAL "missing") + AND EXISTS "${${pkgname}_local_build_script}") + message (STATUS "${ColorMagenta}Building package ${pkgname} ${${pkgname}_VERSION} locally${ColorReset}") + list(APPEND CMAKE_MESSAGE_INDENT " ") + include("${${pkgname}_local_build_script}") + list(POP_BACK CMAKE_MESSAGE_INDENT) + # set (${pkgname}_FOUND TRUE) + set (${pkgname}_LOCAL_BUILD TRUE) + list (APPEND CFP_LOCALLY_BUILT_DEPS ${pkgname}) + list (REMOVE_ITEM CFP_LOCALLY_BUILDABLE_DEPS_NOTFOUND ${pkgname}) + endif() + # If the local build instrctions set _REFIND, then try a find + # again to pick up the local one, at which point we can proceed as if + # it had been found externally all along. The local build script can + # also optionally set the following hints: + # ${pkgname}_REFIND_VERSION : the version that was just installed, + # to specifically find. + # ${pkgname}_REFIND_ARGS : additional arguments to pass to find_package + if (${pkgname}_REFIND) + message (STATUS "Refinding ${pkgname} with ${pkgname}_ROOT=${${pkgname}_ROOT}") + find_package (${pkgname} ${_pkg_UNPARSED_ARGUMENTS} ${${pkgname}_REFIND_ARGS}) + unset (${pkgname}_REFIND) + endif() + # It's all downhill from here: if we found the package, follow the + # various instructions we got about variables to set, compile + # definitions to add, etc. + if (${pkgname}_FOUND OR ${pkgname_upper}_FOUND) + foreach (_vervar ${pkgname_upper}_VERSION ${pkgname}_VERSION_STRING + ${pkgname_upper}_VERSION_STRING) + if (NOT ${pkgname}_VERSION AND ${_vervar}) + set (${pkgname}_VERSION ${${_vervar}}) + endif () + endforeach () + message (STATUS "${ColorGreen}Found ${pkgname} ${${pkgname}_VERSION} ${_config_status}${ColorReset}") + add_compile_definitions (${_pkg_DEFINITIONS}) + foreach (_v IN LISTS _pkg_SETVARIABLES) + set (${_v} TRUE) + endforeach () + if (_pkg_RECOMMEND_MIN) + if (${${pkgname}_VERSION} VERSION_LESS ${_pkg_RECOMMEND_MIN}) + message (STATUS "${ColorYellow}Recommend ${pkgname} >= ${_pkg_RECOMMEND_MIN} ${_pkg_RECOMMEND_MIN_REASON} ${ColorReset}") + endif () + endif () + string (STRIP "${pkgname} ${${pkgname}_VERSION}" app_) + list (APPEND CFP_ALL_BUILD_DEPS_FOUND "${app_}") + else () + handle_package_notfound (${pkgname} ${_pkg_REQUIRED}) + if (NOT _pkg_NO_RECORD_NOTFOUND) + list (APPEND CFP_ALL_BUILD_DEPS_FOUND "${pkgname} NONE") + endif () + endif() + if (_pkg_VERBOSE AND (${pkgname}_FOUND OR ${pkgname_upper}_FOUND OR _pkg_DEBUG)) + if (_pkg_DEBUG) + dump_matching_variables (${pkgname}) + endif () + set (_vars_to_print ${pkgname}_INCLUDES ${pkgname_upper}_INCLUDES + ${pkgname}_INCLUDE_DIR ${pkgname_upper}_INCLUDE_DIR + ${pkgname}_INCLUDE_DIRS ${pkgname_upper}_INCLUDE_DIRS + ${pkgname}_LIBRARIES ${pkgname_upper}_LIBRARIES + ${_pkg_PRINT}) + list (REMOVE_DUPLICATES _vars_to_print) + foreach (_v IN LISTS _vars_to_print) + if (NOT "${${_v}}" STREQUAL "") + message (STATUS " ${_v} = ${${_v}}") + endif () + endforeach () + endif () + else () + if (NOT _quietskip) + message (STATUS "${ColorRed}Not using ${pkgname} -- disabled ${_disablereason} ${ColorReset}") + endif () + endif () + # unset (_${pkgname}_version_range) +endmacro() + + + +# Helper to build a dependency with CMake. Given a package name, git repo and +# tag, and optional cmake args, it will clone the repo into the surrounding +# project's build area, configures, and build sit, and installs it into a +# special dist area (unless the NOINSTALL option is given). +# +# After running, it leaves the following variables set: +# ${pkgname}_LOCAL_SOURCE_DIR +# ${pkgname}_LOCAL_BUILD_DIR +# ${pkgname}_LOCAL_INSTALL_DIR +# +# Unless NOINSTALL is specified, the after the installation step, the +# installation directory will be added to the CMAKE_PREFIX_PATH and also will +# be stored in the ${pkgname}_ROOT variable. +# +macro (build_dependency_with_cmake pkgname) + cmake_parse_arguments(_pkg # prefix + # noValueKeywords: + "NOINSTALL" + # singleValueKeywords: + "GIT_REPOSITORY;GIT_TAG;VERSION" + # multiValueKeywords: + "CMAKE_ARGS" + # argsToParse: + ${ARGN}) + + message (STATUS "Building local ${pkgname} ${_pkg_VERSION} from ${_pkg_GIT_REPOSITORY}") + + set (${pkgname}_LOCAL_SOURCE_DIR "${${PROJECT_NAME}_LOCAL_DEPS_ROOT}/${pkgname}") + set (${pkgname}_LOCAL_BUILD_DIR "${${PROJECT_NAME}_LOCAL_DEPS_ROOT}/${pkgname}-build") + set (${pkgname}_LOCAL_INSTALL_DIR "${${PROJECT_NAME}_LOCAL_DEPS_ROOT}/dist") + message (STATUS "Downloading local ${_pkg_GIT_REPOSITORY}") + + set (_pkg_quiet OUTPUT_QUIET) + + # Clone the repo if we don't already have it + find_package (Git REQUIRED) + if (NOT IS_DIRECTORY ${${pkgname}_LOCAL_SOURCE_DIR}) + execute_process(COMMAND ${GIT_EXECUTABLE} clone ${_pkg_GIT_REPOSITORY} + -b ${_pkg_GIT_TAG} --depth 1 -q + ${${pkgname}_LOCAL_SOURCE_DIR} + ${_pkg_quiet}) + if (NOT IS_DIRECTORY ${${pkgname}_LOCAL_SOURCE_DIR}) + message (FATAL_ERROR "Could not download ${_pkg_GIT_REPOSITORY}") + endif () + endif () + execute_process(COMMAND ${GIT_EXECUTABLE} checkout ${_pkg_GIT_TAG} + WORKING_DIRECTORY ${${pkgname}_LOCAL_SOURCE_DIR} + ${_pkg_quiet}) + + # Configure the package + if (${PROJECT_NAME}_DEPENDENCY_BUILD_VERBOSE) + set (_pkg_cmake_verbose -DCMAKE_VERBOSE_MAKEFILE=ON + -DCMAKE_MESSAGE_LOG_LEVEL=VERBOSE + -DCMAKE_RULE_MESSAGES=ON + ) + else () + set (_pkg_cmake_verbose -DCMAKE_VERBOSE_MAKEFILE=OFF + -DCMAKE_MESSAGE_LOG_LEVEL=ERROR + -DCMAKE_RULE_MESSAGES=OFF + -Wno-dev + ) + endif () + + execute_process (COMMAND + ${CMAKE_COMMAND} + # Put things in our special local build areas + -S ${${pkgname}_LOCAL_SOURCE_DIR} + -B ${${pkgname}_LOCAL_BUILD_DIR} + -DCMAKE_INSTALL_PREFIX=${${pkgname}_LOCAL_INSTALL_DIR} + # Same build type as us + -DCMAKE_BUILD_TYPE=${${PROJECT_NAME}_DEPENDENCY_BUILD_TYPE} + # Shhhh + -DCMAKE_MESSAGE_INDENT=" " + -DCMAKE_COMPILE_WARNING_AS_ERROR=OFF + ${_pkg_cmake_verbose} + # Build args passed by caller + ${_pkg_CMAKE_ARGS} + ${pkg_quiet} + ) + + # Build the package + execute_process (COMMAND ${CMAKE_COMMAND} + --build ${${pkgname}_LOCAL_BUILD_DIR} + --config ${${PROJECT_NAME}_DEPENDENCY_BUILD_TYPE} + ${pkg_quiet} + ) + + # Install the project, unless instructed not to do so + if (NOT _pkg_NOINSTALL) + execute_process (COMMAND ${CMAKE_COMMAND} + --build ${${pkgname}_LOCAL_BUILD_DIR} + --config ${${PROJECT_NAME}_DEPENDENCY_BUILD_TYPE} + --target install + ${pkg_quiet} + ) + set (${pkgname}_ROOT ${${pkgname}_LOCAL_INSTALL_DIR}) + list (APPEND CMAKE_PREFIX_PATH ${${pkgname}_LOCAL_INSTALL_DIR}) + endif () +endmacro () + + +# Copy libraries from a locally-built dependency into our own install area. +# This is useful for dynamic libraries that we need to be part of our own +# installation. +macro (install_local_dependency_libs pkgname libname) + # We need to include the Imath dynamic libraries in our own install. + # get_target_property(_lib_files Imath::Imath INTERFACE_LINK_LIBRARIES) + set (patterns ${ARGN}) + file (GLOB _lib_files + "${${pkgname}_LOCAL_INSTALL_DIR}/lib/*${libname}*" + "${${pkgname}_LOCAL_INSTALL_DIR}/lib/${${PROJECT_NAME}_DEPENDENCY_BUILD_TYPE}/*${libname}*" + ) + install (FILES ${_lib_files} TYPE LIB) + # message("${pkgname}_LOCAL_INSTALL_DIR = ${${pkgname}_LOCAL_INSTALL_DIR}") + # message(" lib files = ${_lib_files}") + if (WIN32) + # On Windows, check for DLLs, which go in the bin directory + file (GLOB _lib_files + "${${pkgname}_LOCAL_INSTALL_DIR}/bin/*${libname}*.dll" + "${${pkgname}_LOCAL_INSTALL_DIR}/bin/${${PROJECT_NAME}_DEPENDENCY_BUILD_TYPE}/*${libname}*.dll" + ) + # message(" dll files = ${_lib_files}") + install (FILES ${_lib_files} TYPE BIN) + endif () + unset (_lib_files) +endmacro () + + +# If the target `newalias` doesn't yet exist but `realtarget` does, create an +# alias for `newalias` to mean the real target. +macro (alias_library_if_not_exists newalias realtarget) + if (NOT TARGET ${newalias} AND TARGET ${realtarget}) + add_library(${newalias} ALIAS ${realtarget}) + endif () +endmacro () diff --git a/src/cmake/set_utils.cmake b/src/cmake/set_utils.cmake new file mode 100644 index 000000000..1f86e7ef2 --- /dev/null +++ b/src/cmake/set_utils.cmake @@ -0,0 +1,123 @@ +# Copyright Contributors to the Open Shading Language project. +# SPDX-License-Identifier: BSD-3-Clause +# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage + + +# Set a variable to a value if it is not already defined. +macro (set_if_not var value) + if (NOT DEFINED ${var}) + set (${var} ${value}) + endif () +endmacro () + + +# Set a variable to a `replacement`, replacing its previous value, but only if +# `replacement` is non-empty. +macro (set_replace_if_nonempty var replacement) + if (NOT "${replacement}" STREQUAL "") + set (${var} ${replacement}) + endif () +endmacro () + + + +# Set a cmake variable `var` from an environment variable, if it is not +# already defined (or if the FORCE flag is used). By default, the env var is +# the same name as `var`, but you can specify a different env var name with +# the ENVVAR keyword. If the env var doesn't exist or is empty, and a DEFAULT +# is supplied, assign the default to the variable instead. If the VERBOSE +# CMake variable is set, or if the VERBOSE flag to this function is used, +# print a message. +macro (set_from_env var) + cmake_parse_arguments(_sfe # prefix + # noValueKeywords: + "VERBOSE;FORCE" + # singleValueKeywords: + "ENVVAR;DEFAULT;NAME" + # multiValueKeywords: + "" + # argsToParse: + ${ARGN}) + if (NOT DEFINED ${var} OR _sfe_FORCE) + set_if_not (_sfe_ENVVAR ${var}) + set_if_not (_sfe_NAME ${var}) + if (DEFINED ENV{${_sfe_ENVVAR}} AND NOT "$ENV{${_sfe_ENVVAR}}" STREQUAL "") + set (${var} $ENV{${_sfe_ENVVAR}}) + if (_sfe_VERBOSE OR VERBOSE) + message (VERBOSE "set ${_sfe_NAME} = $ENV{${_sfe_ENVVAR}} (from env)") + endif () + elseif (DEFINED _sfe_DEFAULT) + set (${var} ${_sfe_DEFAULT}) + endif () + endif () +endmacro () + + + +# Wrapper for CMake `set()` functionality with extensions: +# - If an env variable of the same name exists, it overrides the default +# value. +# - In verbose mode or if the optional VERBOSE argument is passed, print the +# value and whether it came from the env. +# - CACHE optional token makes it a cache variable. +# - ADVANCED optional token sets it as "mark_as_advanced" without the need +# for a separate call (only applies to cache variables.) +# - FILEPATH, PATH, BOOL, STRING optional token works as usual (only applies +# to cache variables). +# - `DOC ` specifies a doc string for cache variables. If omitted, +# an empty doc string will be used. +# Other extensions may be added in the future. +macro (super_set name value) + cmake_parse_arguments(_sce # prefix + # noValueKeywords: + "FORCE;ADVANCED;FILEPATH;PATH;BOOL;STRING;CACHE;VERBOSE" + # singleValueKeywords: + "DOC" + # multiValueKeywords: + "" + # argsToParse: + ${ARGN}) + set (_sce_extra_args "") + if (_sce_FILEPATH) + set (_sce_type "FILEPATH") + elseif (_sce_PATH) + set (_sce_type "PATH") + elseif (_sce_BOOL) + set (_sce_type "BOOL") + else () + set (_sce_type "STRING") + endif () + if (_sce_FORCE) + list (APPEND _sce_extra_args FORCE) + endif () + set_if_not (_sce_DOC "empty") + set_from_env (_sce_val ENVVAR ${name} NAME ${name} DEFAULT ${value}) + if (_sce_CACHE) + set (${name} ${_sce_val} CACHE ${_sce_type} "${_sce_DOC}" ${_sce_extra_args}) + else () + set (${name} ${_sce_val} ${_sce_extra_args}) + endif () + if (_sce_VERBOSE) + message (STATUS "${name} = ${${name}}") + else () + message (VERBOSE "${name} = ${${name}}") + endif () + if (_sce_ADVANCED) + mark_as_advanced (${name}) + endif () + unset (_sce_extra_args) + unset (_sce_type) + unset (_sce_val) +endmacro () + + +# `set(... CACHE ...)` workalike using super_set underneath. +macro (set_cache name value docstring) + super_set (${name} "${value}" DOC ${docstring} CACHE ${ARGN}) +endmacro () + + +# `option()` workalike using super_set underneath. +macro (set_option name docstring value) + set_cache (${name} "${value}" ${docstring} BOOL ${ARGN}) +endmacro () From 269a8977ceb4d3760b0431a572c4d50c42b4e546 Mon Sep 17 00:00:00 2001 From: Larry Gritz Date: Wed, 14 Aug 2024 09:15:01 -0700 Subject: [PATCH 15/17] build: raise C++ to 17, gcc min to 9.3, clang min to 5.0 (#1847) It's time. This is for main (1.14), and will not be backported. Signed-off-by: Larry Gritz --- .github/workflows/ci.yml | 56 ++++-------------- INSTALL.md | 8 +-- Makefile | 2 +- doc/build_install/windows/build_osl.py | 5 +- src/cmake/compiler.cmake | 13 +++- src/include/OSL/oslconfig.h.in | 45 +++++--------- src/include/OSL/oslversion.h.in | 1 + src/include/OSL/platform.h | 59 ++++++++----------- .../example-batched-deformer/CMakeLists.txt | 8 +-- testsuite/example-cuda/CMakeLists.txt | 8 +-- testsuite/example-deformer/CMakeLists.txt | 4 +- 11 files changed, 78 insertions(+), 131 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d05e08748..297544ba3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,43 +38,7 @@ jobs: fail-fast: false matrix: include: - - desc: gcc6/C++14 llvm9 py2.7 exr2.4 oiio2.3 sse2 - nametag: linux-vfx2020 - runner: ubuntu-latest - container: aswftesting/ci-osl:2019-clang9 - vfxyear: 2019 - cxx_std: 14 - openexr_ver: v2.4.3 - openimageio_ver: v2.4.13.0 - python_ver: 2.7 - pybind11_ver: v2.4.2 - setenvs: export CMAKE_VERSION=3.15.5 - - desc: clang9/C++14 llvm9 oiio-release avx2 exr2.4 py2.7 - nametag: linux-clang9-llvm9 - runner: ubuntu-20.04 - container: aswftesting/ci-osl:2019-clang9 - vfxyear: 2019 - cc_compiler: clang - cxx_compiler: clang++ - cxx_std: 14 - openexr_ver: v2.4.3 - openimageio_ver: release - python_ver: 2.7 - # pybind11_ver: v2.9.0 - simd: avx - setenvs: export CMAKE_VERSION=3.15.5 - - desc: gcc6/C++14 llvm10 py3.7 exr2.4 oiio2.2 sse4 - nametag: linux-vfx2020 - runner: ubuntu-latest - container: aswftesting/ci-osl:2020 - vfxyear: 2020 - cxx_std: 14 - openimageio_ver: v2.4.13.0 - python_ver: 3.7 - pybind11_ver: v2.5.0 - simd: sse4.2 - setenvs: export CONAN_LLVM_VERSION=10.0.1 - - desc: gcc9/C++17 llvm11 py3.7 exr2.5 oiio2.3 avx2 batch-b8avx2 + - desc: gcc9/C++17 llvm11 py3.7 exr2.5 oiio2.3 sse4 batch-b8avx2 nametag: linux-vfx2021 runner: ubuntu-latest container: aswftesting/ci-osl:2021-clang11 @@ -83,7 +47,7 @@ jobs: openimageio_ver: v2.4.13.0 python_ver: 3.7 pybind11_ver: v2.7.0 - simd: avx2,f16c + simd: sse4.2 batched: b8_AVX2_noFMA - desc: gcc9/C++17 llvm13 py3.9 exr3.1 oiio-rel avx2 nametag: linux-vfx2022 @@ -171,15 +135,15 @@ jobs: skip_tests: 1 setenvs: export OSL_CMAKE_FLAGS="-DOSL_USE_OPTIX=1" OPTIX_VERSION=7.0 OPENIMAGEIO_CMAKE_FLAGS=-DBUILD_FMT_VERSION=9.1.0 - - desc: oldest everything gcc6/C++14 llvm9 py2.7 oiio2.3 no-simd exr2.4 + - desc: oldest everything gcc9/C++17 llvm9 py3.7 oiio2.3 no-simd exr2.4 nametag: linux-oldest runner: ubuntu-latest - container: aswftesting/ci-osl:2019-clang9 - vfxyear: 2019 - cxx_std: 14 + container: aswftesting/ci-osl:2021-clang11 + vfxyear: 2021 + cxx_std: 17 openexr_ver: v2.4.3 openimageio_ver: v2.4.13.0 - python_ver: 2.7 + python_ver: 3.7 pybind11_ver: v2.7.0 simd: 0 setenvs: export PUGIXML_VERSION=v1.8 @@ -344,11 +308,11 @@ jobs: fail-fast: false matrix: include: - - desc: Debug gcc7/C++14 llvm9 py2.7 oiio2.3 exr2.4 sse4 exr2.4 + - desc: Debug gcc7/C++17 llvm9 py3.7 oiio2.3 exr2.4 sse4 exr2.4 nametag: linux-debug-gcc7-llvm9 runner: ubuntu-20.04 - cxx_compiler: g++-7 - cxx_std: 14 + cxx_compiler: g++-9 + cxx_std: 17 openexr_ver: v2.4.3 openimageio_ver: v2.4.13.0 pybind11_ver: v2.6.2 diff --git a/INSTALL.md b/INSTALL.md index 25ec63d52..20e4fc86b 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -21,11 +21,11 @@ NEW or CHANGED dependencies since the last major release are **bold**. * Build system: [CMake](https://cmake.org/) **3.15 or newer** (tested through 3.27) -* A suitable C++14 or C++17 compiler to build OSL itself, which may be any of: - - GCC 6.1 or newer (tested through gcc 12.1) - - Clang 3.4 or newer (tested through clang 17) +* A suitable C++17 compiler to build OSL itself, which may be any of: + - **GCC 9.3** or newer (tested through gcc 12.1) + - **Clang 5** or newer (tested through clang 18) - Microsoft Visual Studio 2017 or newer - - Intel C++ compiler icc version 17 or newer or LLVM-based icx compiler + - Intel C++ compiler **icc version 19** or newer or LLVM-based icx compiler version 2022 or newer. * **[OpenImageIO](http://openimageio.org) 2.4 or newer** (tested through 2.5 and master) diff --git a/Makefile b/Makefile index 4742da3f3..3c9b0dee2 100644 --- a/Makefile +++ b/Makefile @@ -349,7 +349,7 @@ help: @echo " VERBOSE=1 Show all compilation commands" @echo " STOP_ON_WARNING=0 Do not stop building if compiler warns" @echo " MYCC=xx MYCXX=yy Use custom compilers" - @echo " CMAKE_CXX_STANDARD=14 C++ standard to build with (default is 14)" + @echo " CMAKE_CXX_STANDARD=17 C++ standard to build with (default is 17)" @echo " USE_LIBCPLUSPLUS=1 For clang, use libc++" @echo " GLIBCXX_USE_CXX11_ABI=1 For gcc, use the new string ABI" @echo " EXTRA_CPP_ARGS= Additional args to the C++ command" diff --git a/doc/build_install/windows/build_osl.py b/doc/build_install/windows/build_osl.py index 86bfc34ba..62a0e59d3 100644 --- a/doc/build_install/windows/build_osl.py +++ b/doc/build_install/windows/build_osl.py @@ -1048,8 +1048,7 @@ def InstallOSL(context, force, buildArgs): extraArgs.append("-DUSE_PYTHON=0") extraArgs.append("-DOSL_BUILD_TESTS=0") - # if you are using LLVM 10 or higher C++ should be set on 14 - extraArgs.append("-DCMAKE_CXX_STANDARD=14") + extraArgs.append("-DCMAKE_CXX_STANDARD=17") # if you are using LLVM 10 or higher C++ should be set on 11 # extraArgs.append("-DCMAKE_CXX_STANDARD=11") @@ -1273,7 +1272,7 @@ def InstallOpenColorIO(context, force, buildArgs): option. This values for this option must take the form ,