From 0fb587b23858d25e76b4a852836b45ebfd5078eb Mon Sep 17 00:00:00 2001 From: michaeldsmith <37905569+michaeldsmith@users.noreply.github.com> Date: Mon, 2 Jan 2023 11:42:13 -0800 Subject: [PATCH] Issues/0106 - fix windows compile errors (#107) * add windows github workflows * fixes windows compile errors, closes #106 * use OpenVDB's FindIlmBase.cmake and FindOpenEXR.cmake * fix for run-time check in \CTL\ctlrender\tiff_file.cc - Line 613, "The variable 'channel' is being used without being initialized" --- .github/workflows/windows_debug.yml | 135 ++++++ .github/workflows/windows_release.yml | 135 ++++++ .github/workflows/windows_vcpkg_debug.yml | 53 +++ .github/workflows/windows_vcpkg_release.yml | 94 ++++ cmake/modules/FindIlmBase.cmake | 495 +++++++++++++++++--- cmake/modules/FindOpenEXR.cmake | 484 ++++++++++++++++--- ctlrender/main.cc | 26 +- ctlrender/main.hh | 4 +- ctlrender/tiff_file.cc | 12 +- ctlrender/transform.cc | 4 + lib/IlmCtl/CtlExc.cpp | 6 +- lib/IlmCtl/CtlInterpreter.cpp | 23 +- lib/IlmCtl/CtlRcPtr.cpp | 5 +- lib/IlmCtl/CtlRcPtr.h | 8 +- lib/IlmCtl/CtlStdType.cpp | 1 + lib/IlmCtl/CtlType.cpp | 4 +- lib/IlmCtl/CtlType.h | 4 +- lib/IlmCtl/CtlTypeStorage.cpp | 58 +-- lib/IlmCtl/CtlTypeStorage.h | 52 +- lib/IlmCtlSimd/CtlSimdInterpreter.cpp | 12 +- lib/IlmImfCtl/ImfCtlApplyTransforms.cpp | 14 +- lib/dpx/dpx_rw.cc | 4 + lib/dpx/dpx_util.cc | 6 +- unittest/ctlrender/CMakeLists.txt | 14 +- vcpkg.json | 9 + 25 files changed, 1430 insertions(+), 232 deletions(-) create mode 100644 .github/workflows/windows_debug.yml create mode 100644 .github/workflows/windows_release.yml create mode 100644 .github/workflows/windows_vcpkg_debug.yml create mode 100644 .github/workflows/windows_vcpkg_release.yml create mode 100644 vcpkg.json diff --git a/.github/workflows/windows_debug.yml b/.github/workflows/windows_debug.yml new file mode 100644 index 00000000..85256f3f --- /dev/null +++ b/.github/workflows/windows_debug.yml @@ -0,0 +1,135 @@ +name: Windows-Debug + +on: + push: + paths-ignore: + - 'README.md' + - 'doc/**' + pull_request: + paths-ignore: + - 'README.md' + - 'doc/**' + +env: + # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) + BUILD_TYPE: Debug + +jobs: + + build-openexr2: + # The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac. + # You can convert this to a matrix build if you need cross-platform coverage. + # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix + runs-on: windows-latest + + steps: + + - name: install dependencies - zlib + run: | + cd .. + git clone https://github.com/madler/zlib.git && + cd zlib && + mkdir build && + mkdir install && + cd build && + cmake .. -D"CMAKE_INSTALL_PREFIX=../install" -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} && + cmake --build . --config ${{env.BUILD_TYPE}} && + cmake --build . --target install --config ${{env.BUILD_TYPE}} + + - name: install dependencies - openexr + run: | + cd .. + git clone https://github.com/AcademySoftwareFoundation/openexr.git && + cd openexr && + git checkout RB-2.5 && + mkdir build && + mkdir install && + cd build && + cmake .. -D"CMAKE_INSTALL_PREFIX=../install" -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_TESTING=OFF -DOPENEXR_BUILD_TOOLS=OFF -DOPENEXR_INSTALL_EXAMPLES=OFF -D "CMAKE_PREFIX_PATH=${{github.workspace}}/../zlib/install/" && + cmake --build . --config ${{env.BUILD_TYPE}} && + cmake --build . --target install --config ${{env.BUILD_TYPE}} + + - uses: actions/checkout@v3 + + - name: Configure CMake + # # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. + # # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type + run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -D "CMAKE_PREFIX_PATH=${{github.workspace}}/../openexr/install/;${{github.workspace}}/../zlib/install/" + + - name: Build + # Build your program with the given configuration + run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} + + - name: Install + # Build your program with the given configuration + run: cmake --build ${{github.workspace}}/build --target install --config ${{env.BUILD_TYPE}} + working-directory: ${{github.workspace}} + + # - name: Test + # working-directory: ${{github.workspace}}/build + # run: ctest -V --output-on-failure -C ${{env.BUILD_TYPE}} + + build-openexr3: + # The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac. + # You can convert this to a matrix build if you need cross-platform coverage. + # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix + runs-on: windows-latest + + steps: + + - name: install dependencies - Imath + run: | + cd .. + git clone https://github.com/AcademySoftwareFoundation/Imath.git && + cd Imath && + mkdir build && + mkdir install && + cd build && + cmake .. -D"CMAKE_INSTALL_PREFIX=../install" -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} && + cmake --build . --config ${{env.BUILD_TYPE}} && + cmake --build . --target install --config ${{env.BUILD_TYPE}} + + - name: install dependencies - zlib + run: | + cd .. + git clone https://github.com/madler/zlib.git && + cd zlib && + mkdir build && + mkdir install && + cd build && + cmake .. -D"CMAKE_INSTALL_PREFIX=../install" -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} && + cmake --build . --config ${{env.BUILD_TYPE}} && + cmake --build . --target install --config ${{env.BUILD_TYPE}} + + - name: install dependencies - openexr + run: | + cd .. + git clone https://github.com/AcademySoftwareFoundation/openexr.git && + cd openexr && + git checkout RB-3.1 && + mkdir build && + mkdir install && + cd build && + cmake .. -D"CMAKE_INSTALL_PREFIX=../install" -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_TESTING=OFF -DOPENEXR_BUILD_TOOLS=OFF -DOPENEXR_INSTALL_EXAMPLES=OFF -D "CMAKE_PREFIX_PATH=${{github.workspace}}/../Imath/install/;${{github.workspace}}/../zlib/install/;${{github.workspace}}/../openexr/install/" && + cmake --build . --config ${{env.BUILD_TYPE}} && + cmake --build . --target install --config ${{env.BUILD_TYPE}} + + - uses: actions/checkout@v3 + + - name: Configure CMake + # # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. + # # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type + run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -D "CMAKE_PREFIX_PATH=${{github.workspace}}/../Imath/install/;${{github.workspace}}/../zlib/install/;${{github.workspace}}/../openexr/install/" + + - name: Build + # Build your program with the given configuration + run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} + + - name: Install + # Build your program with the given configuration + run: cmake --build ${{github.workspace}}/build --target install --config ${{env.BUILD_TYPE}} + working-directory: ${{github.workspace}} + + # - name: Test + # working-directory: ${{github.workspace}}/build + # run: ctest -V --output-on-failure -C ${{env.BUILD_TYPE}} \ No newline at end of file diff --git a/.github/workflows/windows_release.yml b/.github/workflows/windows_release.yml new file mode 100644 index 00000000..69bcb3e6 --- /dev/null +++ b/.github/workflows/windows_release.yml @@ -0,0 +1,135 @@ +name: Windows-Release + +on: + push: + paths-ignore: + - 'README.md' + - 'doc/**' + pull_request: + paths-ignore: + - 'README.md' + - 'doc/**' + +env: + # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) + BUILD_TYPE: Release + +jobs: + + build-openexr2: + # The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac. + # You can convert this to a matrix build if you need cross-platform coverage. + # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix + runs-on: windows-latest + + steps: + + - name: install dependencies - zlib + run: | + cd .. + git clone https://github.com/madler/zlib.git && + cd zlib && + mkdir build && + mkdir install && + cd build && + cmake .. -D"CMAKE_INSTALL_PREFIX=../install" -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} && + cmake --build . --config ${{env.BUILD_TYPE}} && + cmake --build . --target install --config ${{env.BUILD_TYPE}} + + - name: install dependencies - openexr + run: | + cd .. + git clone https://github.com/AcademySoftwareFoundation/openexr.git && + cd openexr && + git checkout RB-2.5 && + mkdir build && + mkdir install && + cd build && + cmake .. -D"CMAKE_INSTALL_PREFIX=../install" -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_TESTING=OFF -DOPENEXR_BUILD_TOOLS=OFF -DOPENEXR_INSTALL_EXAMPLES=OFF -D "CMAKE_PREFIX_PATH=${{github.workspace}}/../zlib/install/" && + cmake --build . --config ${{env.BUILD_TYPE}} && + cmake --build . --target install --config ${{env.BUILD_TYPE}} + + - uses: actions/checkout@v3 + + - name: Configure CMake + # # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. + # # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type + run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -D "CMAKE_PREFIX_PATH=${{github.workspace}}/../openexr/install/;${{github.workspace}}/../zlib/install/" + + - name: Build + # Build your program with the given configuration + run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} + + - name: Install + # Build your program with the given configuration + run: cmake --build ${{github.workspace}}/build --target install --config ${{env.BUILD_TYPE}} + working-directory: ${{github.workspace}} + + # - name: Test + # working-directory: ${{github.workspace}}/build + # run: ctest -V --output-on-failure -C ${{env.BUILD_TYPE}} + + build-openexr3: + # The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac. + # You can convert this to a matrix build if you need cross-platform coverage. + # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix + runs-on: windows-latest + + steps: + + - name: install dependencies - Imath + run: | + cd .. + git clone https://github.com/AcademySoftwareFoundation/Imath.git && + cd Imath && + mkdir build && + mkdir install && + cd build && + cmake .. -D"CMAKE_INSTALL_PREFIX=../install" -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} && + cmake --build . --config ${{env.BUILD_TYPE}} && + cmake --build . --target install --config ${{env.BUILD_TYPE}} + + - name: install dependencies - zlib + run: | + cd .. + git clone https://github.com/madler/zlib.git && + cd zlib && + mkdir build && + mkdir install && + cd build && + cmake .. -D"CMAKE_INSTALL_PREFIX=../install" -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} && + cmake --build . --config ${{env.BUILD_TYPE}} && + cmake --build . --target install --config ${{env.BUILD_TYPE}} + + - name: install dependencies - openexr + run: | + cd .. + git clone https://github.com/AcademySoftwareFoundation/openexr.git && + cd openexr && + git checkout RB-3.1 && + mkdir build && + mkdir install && + cd build && + cmake .. -D"CMAKE_INSTALL_PREFIX=../install" -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_TESTING=OFF -DOPENEXR_BUILD_TOOLS=OFF -DOPENEXR_INSTALL_EXAMPLES=OFF -D "CMAKE_PREFIX_PATH=${{github.workspace}}/../Imath/install/;${{github.workspace}}/../zlib/install/;${{github.workspace}}/../openexr/install/" && + cmake --build . --config ${{env.BUILD_TYPE}} && + cmake --build . --target install --config ${{env.BUILD_TYPE}} + + - uses: actions/checkout@v3 + + - name: Configure CMake + # # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. + # # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type + run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -D "CMAKE_PREFIX_PATH=${{github.workspace}}/../Imath/install/;${{github.workspace}}/../zlib/install/;${{github.workspace}}/../openexr/install/" + + - name: Build + # Build your program with the given configuration + run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} + + - name: Install + # Build your program with the given configuration + run: cmake --build ${{github.workspace}}/build --target install --config ${{env.BUILD_TYPE}} + working-directory: ${{github.workspace}} + + # - name: Test + # working-directory: ${{github.workspace}}/build + # run: ctest -V --output-on-failure -C ${{env.BUILD_TYPE}} \ No newline at end of file diff --git a/.github/workflows/windows_vcpkg_debug.yml b/.github/workflows/windows_vcpkg_debug.yml new file mode 100644 index 00000000..c967d513 --- /dev/null +++ b/.github/workflows/windows_vcpkg_debug.yml @@ -0,0 +1,53 @@ +name: Windows-vcpkg-Debug + +on: + push: + paths-ignore: + - 'README.md' + - 'doc/**' + pull_request: + paths-ignore: + - 'README.md' + - 'doc/**' + +env: + # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) + BUILD_TYPE: Debug + +jobs: + + build: + # The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac. + # You can convert this to a matrix build if you need cross-platform coverage. + # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix + runs-on: windows-latest + + steps: + + - name: install dependencies - imath + run: vcpkg install imath + + - name: install dependencies - openexr + run: vcpkg install openexr + + - name: install dependencies - tiff + run: vcpkg install tiff + + - name: check vcpkg install status + run: vcpkg list + + - uses: actions/checkout@v3 + + - name: Configure CMake + # # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. + # # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type + run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -D "CMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake" + + - name: Build + # Build your program with the given configuration + run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} + + - name: Install + # Build your program with the given configuration + run: cmake --build ${{github.workspace}}/build --target install --config ${{env.BUILD_TYPE}} + working-directory: ${{github.workspace}} diff --git a/.github/workflows/windows_vcpkg_release.yml b/.github/workflows/windows_vcpkg_release.yml new file mode 100644 index 00000000..9cade0f0 --- /dev/null +++ b/.github/workflows/windows_vcpkg_release.yml @@ -0,0 +1,94 @@ +name: Windows-vcpkg-Release + +on: + push: + paths-ignore: + - 'README.md' + - 'doc/**' + pull_request: + paths-ignore: + - 'README.md' + - 'doc/**' + +env: + # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) + BUILD_TYPE: Release + +jobs: + + build: + # The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac. + # You can convert this to a matrix build if you need cross-platform coverage. + # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix + runs-on: windows-latest + + steps: + + - name: install dependencies - imath + run: vcpkg install imath + + - name: install dependencies - openexr + run: vcpkg install openexr + + - name: install dependencies - tiff + run: vcpkg install tiff + + - name: check vcpkg install status + run: vcpkg list + + - uses: actions/checkout@v3 + + - name: Configure CMake + # # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. + # # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type + run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -D "CMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake" + + - name: Build + # Build your program with the given configuration + run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} + + - name: Install + # Build your program with the given configuration + run: cmake --build ${{github.workspace}}/build --target install --config ${{env.BUILD_TYPE}} + working-directory: ${{github.workspace}} + + test: + # The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac. + # You can convert this to a matrix build if you need cross-platform coverage. + # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix + runs-on: windows-latest + + steps: + + - name: install dependencies - imath + run: vcpkg install imath + + - name: install dependencies - openexr + run: vcpkg install openexr + + - name: install dependencies - tiff + run: vcpkg install tiff + + - name: check vcpkg install status + run: vcpkg list + + - uses: actions/checkout@v3 + + - name: Configure CMake + # # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. + # # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type + run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -D "CMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake" + + - name: Build + # Build your program with the given configuration + run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} + + - name: Install + # Build your program with the given configuration + run: cmake --build ${{github.workspace}}/build --target install --config ${{env.BUILD_TYPE}} + working-directory: ${{github.workspace}} + + - name: Test + working-directory: ${{github.workspace}}/build + run: ctest -V --output-on-failure -C ${{env.BUILD_TYPE}} + diff --git a/cmake/modules/FindIlmBase.cmake b/cmake/modules/FindIlmBase.cmake index a51cdd8b..d98ad2a8 100644 --- a/cmake/modules/FindIlmBase.cmake +++ b/cmake/modules/FindIlmBase.cmake @@ -1,93 +1,448 @@ +# Copyright Contributors to the OpenVDB Project +# SPDX-License-Identifier: MPL-2.0 # -# A simple cmake find module for IlmBase -# +#[=======================================================================[.rst: + +FindIlmBase +----------- + +Find IlmBase include dirs and libraries + +Use this module by invoking find_package with the form:: + + find_package(IlmBase + [version] [EXACT] # Minimum or EXACT version + [REQUIRED] # Fail with error if IlmBase is not found + [COMPONENTS ...] # IlmBase libraries by their canonical name + # e.g. "Half" for "libHalf" + ) + +IMPORTED Targets +^^^^^^^^^^^^^^^^ + +``IlmBase::Half`` + The Half library target. +``IlmBase::Iex`` + The Iex library target. +``IlmBase::IexMath`` + The IexMath library target. +``IlmBase::IlmThread`` + The IlmThread library target. +``IlmBase::Imath`` + The Imath library target. + +Result Variables +^^^^^^^^^^^^^^^^ + +This will define the following variables: + +``IlmBase_FOUND`` + True if the system has the IlmBase library. +``IlmBase_VERSION`` + The version of the IlmBase library which was found. +``IlmBase_INCLUDE_DIRS`` + Include directories needed to use IlmBase. +``IlmBase_RELEASE_LIBRARIES`` + Libraries needed to link to the release version of IlmBase. +``IlmBase_RELEASE_LIBRARY_DIRS`` + IlmBase release library directories. +``IlmBase_DEBUG_LIBRARIES`` + Libraries needed to link to the debug version of IlmBase. +``IlmBase_DEBUG_LIBRARY_DIRS`` + IlmBase debug library directories. +``IlmBase_{COMPONENT}_FOUND`` + True if the system has the named IlmBase component. + +Deprecated - use [RELEASE|DEBUG] variants: + +``IlmBase_LIBRARIES`` + Libraries needed to link to IlmBase. +``IlmBase_LIBRARY_DIRS`` + IlmBase library directories. + +Cache Variables +^^^^^^^^^^^^^^^ -find_package(PkgConfig QUIET) -if(PKG_CONFIG_FOUND) - pkg_check_modules(PC_ILMBASE QUIET IlmBase) +The following cache variables may also be set: + +``IlmBase_INCLUDE_DIR`` + The directory containing ``IlmBase/config-auto.h``. +``IlmBase_{COMPONENT}_LIBRARY`` + Individual component libraries for IlmBase. may include target_link_libraries() debug/optimized keywords. +``IlmBase_{COMPONENT}_LIBRARY_RELEASE`` + Individual component libraries for IlmBase release +``IlmBase_{COMPONENT}_LIBRARY_DEBUG`` + Individual component libraries for IlmBase debug + +Hints +^^^^^ + +Instead of explicitly setting the cache variables, the following variables +may be provided to tell this module where to look. + +``IlmBase_ROOT`` + Preferred installation prefix. +``ILMBASE_INCLUDEDIR`` + Preferred include directory e.g. /include +``ILMBASE_LIBRARYDIR`` + Preferred library directory e.g. /lib +``ILMBASE_DEBUG_SUFFIX`` + Suffix of the debug version of ilmbase libs. Defaults to "_d". +``SYSTEM_LIBRARY_PATHS`` + Global list of library paths intended to be searched by and find_xxx call +``ILMBASE_USE_STATIC_LIBS`` + Only search for static ilmbase libraries +``DISABLE_CMAKE_SEARCH_PATHS`` + Disable CMakes default search paths for find_xxx calls in this module + +#]=======================================================================] + +#cmake_minimum_required(VERSION 3.18) +cmake_minimum_required(VERSION 3.12) +include(GNUInstallDirs) + + +mark_as_advanced( + IlmBase_INCLUDE_DIR + IlmBase_LIBRARY +) + +set(_FIND_ILMBASE_ADDITIONAL_OPTIONS "") +if(DISABLE_CMAKE_SEARCH_PATHS) + set(_FIND_ILMBASE_ADDITIONAL_OPTIONS NO_DEFAULT_PATH) endif() -if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - # Under Mac OS, if the user has installed using brew, the package config - # information is not entirely accurate in that it refers to the - # true install path but brew maintains links to /usr/local for you - # which they want you to use - if(PC_ILMBASE_FOUND AND "${PC_ILMBASE_INCLUDEDIR}" MATCHES "^/usr/local/Cellar.*") - set(_IlmBase_HINT_INCLUDE /usr/local/include) - set(_IlmBase_HINT_LIB /usr/local/lib) +set(_ILMBASE_COMPONENT_LIST + Half + Iex + IexMath + IlmThread + Imath +) + +if(IlmBase_FIND_COMPONENTS) + set(ILMBASE_COMPONENTS_PROVIDED TRUE) + set(_IGNORED_COMPONENTS "") + foreach(COMPONENT ${IlmBase_FIND_COMPONENTS}) + if(NOT ${COMPONENT} IN_LIST _ILMBASE_COMPONENT_LIST) + list(APPEND _IGNORED_COMPONENTS ${COMPONENT}) + endif() + endforeach() + + if(_IGNORED_COMPONENTS) + message(STATUS "Ignoring unknown components of IlmBase:") + foreach(COMPONENT ${_IGNORED_COMPONENTS}) + message(STATUS " ${COMPONENT}") + endforeach() + list(REMOVE_ITEM IlmBase_FIND_COMPONENTS ${_IGNORED_COMPONENTS}) endif() +else() + set(ILMBASE_COMPONENTS_PROVIDED FALSE) + set(IlmBase_FIND_COMPONENTS ${_ILMBASE_COMPONENT_LIST}) endif() -if(PC_ILMBASE_FOUND) - set(IlmBase_CFLAGS ${PC_ILMBASE_CFLAGS_OTHER}) - set(IlmBase_LIBRARY_DIRS ${PC_ILMBASE_LIBRARY_DIRS}) - set(IlmBase_LDFLAGS ${PC_ILMBASE_LDFLAGS_OTHER}) - if("${_IlmBase_HINT_INCLUDE}" STREQUAL "") - set(_IlmBase_HINT_INCLUDE ${PC_ILMBASE_INCLUDEDIR} ${PC_ILMBASE_INCLUDE_DIRS}) - set(_IlmBase_HINT_LIB ${PC_ILMBASE_LIBDIR} ${PC_ILMBASE_LIBRARY_DIRS}) +# Set _ILMBASE_ROOT based on a user provided root var. Xxx_ROOT and ENV{Xxx_ROOT} +# are prioritised over the legacy capitalized XXX_ROOT variables for matching +# CMake 3.12 behaviour +# @todo deprecate -D and ENV ILMBASE_ROOT from CMake 3.12 +if(IlmBase_ROOT) + set(_ILMBASE_ROOT ${IlmBase_ROOT}) +elseif(DEFINED ENV{IlmBase_ROOT}) + set(_ILMBASE_ROOT $ENV{IlmBase_ROOT}) +elseif(ILMBASE_ROOT) + set(_ILMBASE_ROOT ${ILMBASE_ROOT}) +elseif(DEFINED ENV{ILMBASE_ROOT}) + set(_ILMBASE_ROOT $ENV{ILMBASE_ROOT}) +endif() + +# Additionally try and use pkconfig to find IlmBase +if(USE_PKGCONFIG) + if(NOT DEFINED PKG_CONFIG_FOUND) + find_package(PkgConfig) endif() -else() - if(UNIX) - set(IlmBase_CFLAGS "-pthread") - if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - else() - set(OpenEXR_LDFLAGS "-pthread") - endif() + if(PKG_CONFIG_FOUND) + pkg_check_modules(PC_IlmBase QUIET ilmbase) endif() endif() -find_path(IlmBase_INCLUDE_DIR IlmBaseConfig.h HINTS ${_IlmBase_HINT_INCLUDE} PATH_SUFFIXES OpenEXR ) -if(IlmBase_INCLUDE_DIR AND EXISTS "${IlmBase_INCLUDE_DIR}/IlmBaseConfig.h") - set(IlmBase_VERSION ${PC_ILMBASE_VERSION}) - if("${IlmBase_VERSION}" STREQUAL "") - file(STRINGS "${IlmBase_INCLUDE_DIR}/IlmBaseConfig.h" ilmbase_version_str - REGEX "^#define[\t ]+ILMBASE_VERSION_STRING[\t ]+\".*") +# ------------------------------------------------------------------------ +# Search for IlmBase include DIR +# ------------------------------------------------------------------------ - string(REGEX REPLACE "^#define[\t ]+ILMBASE_VERSION_STRING[\t ]+\"([^ \\n]*)\".*" - "\\1" IlmBase_VERSION "${ilmbase_version_str}") - unset(ilmbase_version_str) - endif() +set(_ILMBASE_INCLUDE_SEARCH_DIRS "") +list(APPEND _ILMBASE_INCLUDE_SEARCH_DIRS + ${ILMBASE_INCLUDEDIR} + ${_ILMBASE_ROOT} + ${PC_IlmBase_INCLUDEDIR} + ${SYSTEM_LIBRARY_PATHS} +) + +# Look for a standard IlmBase header file. +find_path(IlmBase_INCLUDE_DIR IlmBaseConfig.h + ${_FIND_ILMBASE_ADDITIONAL_OPTIONS} + PATHS ${_ILMBASE_INCLUDE_SEARCH_DIRS} + PATH_SUFFIXES ${CMAKE_INSTALL_INCLUDEDIR}/OpenEXR include/OpenEXR OpenEXR +) + +if(EXISTS "${IlmBase_INCLUDE_DIR}/IlmBaseConfig.h") + # Get the ILMBASE version information from the config header + file(STRINGS "${IlmBase_INCLUDE_DIR}/IlmBaseConfig.h" + _ilmbase_version_major_string REGEX "#define ILMBASE_VERSION_MAJOR " + ) + string(REGEX REPLACE "#define ILMBASE_VERSION_MAJOR" "" + _ilmbase_version_major_string "${_ilmbase_version_major_string}" + ) + string(STRIP "${_ilmbase_version_major_string}" IlmBase_VERSION_MAJOR) + + file(STRINGS "${IlmBase_INCLUDE_DIR}/IlmBaseConfig.h" + _ilmbase_version_minor_string REGEX "#define ILMBASE_VERSION_MINOR " + ) + string(REGEX REPLACE "#define ILMBASE_VERSION_MINOR" "" + _ilmbase_version_minor_string "${_ilmbase_version_minor_string}" + ) + string(STRIP "${_ilmbase_version_minor_string}" IlmBase_VERSION_MINOR) + + unset(_ilmbase_version_major_string) + unset(_ilmbase_version_minor_string) + + set(IlmBase_VERSION ${IlmBase_VERSION_MAJOR}.${IlmBase_VERSION_MINOR}) endif() -if("${IlmBase_VERSION}" VERSION_LESS "2.0.0") - set(IlmBase_ALL_LIBRARIES Imath Half Iex IlmThread) -else() - set(IlmBase_ALL_LIBRARIES Imath Half Iex IexMath IlmThread) +# ------------------------------------------------------------------------ +# Search for ILMBASE lib DIR +# ------------------------------------------------------------------------ + +if(NOT DEFINED ILMBASE_DEBUG_SUFFIX) + set(ILMBASE_DEBUG_SUFFIX _d) endif() -foreach(ILMBASE_LIB ${IlmBase_ALL_LIBRARIES}) - string(TOUPPER ${ILMBASE_LIB} _upper_ilmbase_lib) - find_library(IlmBase_${_upper_ilmbase_lib}_LIBRARY - NAMES ${ILMBASE_LIB} lib${ILMBASE_LIB} - HINTS ${_IlmBase_HINT_LIB} - ) - if(IlmBase_${_upper_ilmbase_lib}_LIBRARY) - set(IlmBase_LIBRARY ${IlmBase_LIBRARY} ${IlmBase_${_upper_ilmbase_lib}_LIBRARY}) - mark_as_advanced(IlmBase_${_upper_ilmbase_lib}_LIBRARY) + +set(_ILMBASE_LIBRARYDIR_SEARCH_DIRS "") + +# Append to _ILMBASE_LIBRARYDIR_SEARCH_DIRS in priority order + +list(APPEND _ILMBASE_LIBRARYDIR_SEARCH_DIRS + ${ILMBASE_LIBRARYDIR} + ${_ILMBASE_ROOT} + ${PC_IlmBase_LIBDIR} + ${SYSTEM_LIBRARY_PATHS} +) + +set(IlmBase_LIB_COMPONENTS "") +list(APPEND ILM_BUILD_TYPES RELEASE DEBUG) + +foreach(COMPONENT ${IlmBase_FIND_COMPONENTS}) + foreach(BUILD_TYPE ${ILM_BUILD_TYPES}) + + set(_TMP_SUFFIX "") + if(BUILD_TYPE STREQUAL DEBUG) + set(_TMP_SUFFIX ${ILMBASE_DEBUG_SUFFIX}) + endif() + + set(_IlmBase_Version_Suffix "-${IlmBase_VERSION_MAJOR}_${IlmBase_VERSION_MINOR}") + set(_ILMBASE_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) + + if(WIN32) + if(ILMBASE_USE_STATIC_LIBS) + set(CMAKE_FIND_LIBRARY_SUFFIXES "${_TMP_SUFFIX}.lib") + endif() + list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES "${_IlmBase_Version_Suffix}${_TMP_SUFFIX}.lib") + else() + if(ILMBASE_USE_STATIC_LIBS) + set(CMAKE_FIND_LIBRARY_SUFFIXES "${_TMP_SUFFIX}.a") + else() + if(APPLE) + list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES "${_IlmBase_Version_Suffix}${_TMP_SUFFIX}.dylib") + else() + list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES "${_IlmBase_Version_Suffix}${_TMP_SUFFIX}.so") + endif() + endif() + list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES "${_IlmBase_Version_Suffix}${_TMP_SUFFIX}.a") + endif() + + # Find the lib + find_library(IlmBase_${COMPONENT}_LIBRARY_${BUILD_TYPE} ${COMPONENT} + ${_FIND_ILMBASE_ADDITIONAL_OPTIONS} + PATHS ${_ILMBASE_LIBRARYDIR_SEARCH_DIRS} + PATH_SUFFIXES ${CMAKE_INSTALL_LIBDIR} lib64 lib + ) + + if(EXISTS ${IlmBase_${COMPONENT}_LIBRARY_${BUILD_TYPE}}) + list(APPEND IlmBase_LIB_COMPONENTS ${IlmBase_${COMPONENT}_LIBRARY_${BUILD_TYPE}}) + list(APPEND IlmBase_LIB_COMPONENTS_${BUILD_TYPE} ${IlmBase_${COMPONENT}_LIBRARY_${BUILD_TYPE}}) + endif() + + # Reset library suffix + set(CMAKE_FIND_LIBRARY_SUFFIXES ${_ILMBASE_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}) + unset(_ILMBASE_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES) + unset(_IlmBase_Version_Suffix) + unset(_TMP_SUFFIX) + endforeach() + + if(IlmBase_${COMPONENT}_LIBRARY_DEBUG AND IlmBase_${COMPONENT}_LIBRARY_RELEASE) + # if the generator is multi-config or if CMAKE_BUILD_TYPE is set for + # single-config generators, set optimized and debug libraries + get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) + if(_isMultiConfig OR CMAKE_BUILD_TYPE) + set(IlmBase_${COMPONENT}_LIBRARY optimized ${IlmBase_${COMPONENT}_LIBRARY_RELEASE} debug ${IlmBase_${COMPONENT}_LIBRARY_DEBUG}) + else() + # For single-config generators where CMAKE_BUILD_TYPE has no value, + # just use the release libraries + set(IlmBase_${COMPONENT}_LIBRARY ${IlmBase_${COMPONENT}_LIBRARY_RELEASE}) + endif() + # FIXME: This probably should be set for both cases + set(IlmBase_${COMPONENT}_LIBRARIES optimized ${IlmBase_${COMPONENT}_LIBRARY_RELEASE} debug ${IlmBase_${COMPONENT}_LIBRARY_DEBUG}) endif() -endforeach() -unset(_IlmBase_HINT_INCLUDE) -unset(_IlmBase_HINT_LIB) -set(IlmBase_LIBRARIES ${IlmBase_LIBRARY} ) -set(IlmBase_INCLUDE_DIRS ${IlmBase_INCLUDE_DIR} ) + # if only the release version was found, set the debug variable also to the release version + if(IlmBase_${COMPONENT}_LIBRARY_RELEASE AND NOT IlmBase_${COMPONENT}_LIBRARY_DEBUG) + set(IlmBase_${COMPONENT}_LIBRARY_DEBUG ${IlmBase_${COMPONENT}_LIBRARY_RELEASE}) + set(IlmBase_${COMPONENT}_LIBRARY ${IlmBase_${COMPONENT}_LIBRARY_RELEASE}) + set(IlmBase_${COMPONENT}_LIBRARIES ${IlmBase_${COMPONENT}_LIBRARY_RELEASE}) + endif() -if(NOT PC_ILMBASE_FOUND) -get_filename_component(IlmBase_LDFLAGS_OTHER ${IlmBase_HALF_LIBRARY} PATH) -set(IlmBase_LDFLAGS_OTHER -L${IlmBase_LDFLAGS_OTHER}) -endif() + # if only the debug version was found, set the release variable also to the debug version + if(IlmBase_${COMPONENT}_LIBRARY_DEBUG AND NOT IlmBase_${COMPONENT}_LIBRARY_RELEASE) + set(IlmBase_${COMPONENT}_LIBRARY_RELEASE ${IlmBase_${COMPONENT}_LIBRARY_DEBUG}) + set(IlmBase_${COMPONENT}_LIBRARY ${IlmBase_${COMPONENT}_LIBRARY_DEBUG}) + set(IlmBase_${COMPONENT}_LIBRARIES ${IlmBase_${COMPONENT}_LIBRARY_DEBUG}) + endif() + + # If the debug & release library ends up being the same, omit the keywords + if("${IlmBase_${COMPONENT}_LIBRARY_RELEASE}" STREQUAL "${IlmBase_${COMPONENT}_LIBRARY_DEBUG}") + set(IlmBase_${COMPONENT}_LIBRARY ${IlmBase_${COMPONENT}_LIBRARY_RELEASE} ) + set(IlmBase_${COMPONENT}_LIBRARIES ${IlmBase_${COMPONENT}_LIBRARY_RELEASE} ) + endif() + + if(IlmBase_${COMPONENT}_LIBRARY) + set(IlmBase_${COMPONENT}_FOUND TRUE) + else() + set(IlmBase_${COMPONENT}_FOUND FALSE) + endif() +endforeach() + +# ------------------------------------------------------------------------ +# Cache and set ILMBASE_FOUND +# ------------------------------------------------------------------------ include(FindPackageHandleStandardArgs) -# handle the QUIETLY and REQUIRED arguments and set IlmBase_FOUND to TRUE -# if all listed variables are TRUE find_package_handle_standard_args(IlmBase - REQUIRED_VARS IlmBase_LIBRARY IlmBase_INCLUDE_DIR - VERSION_VAR IlmBase_VERSION - FAIL_MESSAGE "Unable to find IlmBase libraries" ) - -# older versions of cmake don't support FOUND_VAR to find_package_handle -# so just do it the hard way... -if(ILMBASE_FOUND AND NOT IlmBase_FOUND) - set(IlmBase_FOUND 1) + FOUND_VAR IlmBase_FOUND + REQUIRED_VARS + IlmBase_INCLUDE_DIR + IlmBase_LIB_COMPONENTS + #VERSION_VAR IlmBase_VERSION + HANDLE_COMPONENTS +) + +if(NOT IlmBase_FOUND) + if(IlmBase_FIND_REQUIRED) + message(FATAL_ERROR "Unable to find IlmBase") + endif() + return() endif() -mark_as_advanced(IlmBase_INCLUDE_DIR IlmBase_LIBRARY ) +# Partition release/debug lib vars + +set(IlmBase_RELEASE_LIBRARIES "") +set(IlmBase_RELEASE_LIBRARY_DIRS "") +set(IlmBase_DEBUG_LIBRARIES "") +set(IlmBase_DEBUG_LIBRARY_DIRS "") +foreach(LIB ${IlmBase_LIB_COMPONENTS_RELEASE}) + get_filename_component(_ILM_LIBDIR ${LIB} DIRECTORY) + list(APPEND IlmBase_RELEASE_LIBRARIES ${LIB}) + list(APPEND IlmBase_RELEASE_LIBRARY_DIRS ${_ILM_LIBDIR}) +endforeach() + +foreach(LIB ${IlmBase_LIB_COMPONENTS_DEBUG}) + get_filename_component(_ILM_LIBDIR ${LIB} DIRECTORY) + list(APPEND IlmBase_DEBUG_LIBRARIES ${LIB}) + list(APPEND IlmBase_DEBUG_LIBRARY_DIRS ${_ILM_LIBDIR}) +endforeach() + +list(REMOVE_DUPLICATES IlmBase_RELEASE_LIBRARY_DIRS) +list(REMOVE_DUPLICATES IlmBase_DEBUG_LIBRARY_DIRS) + +set(IlmBase_LIBRARIES ${IlmBase_RELEASE_LIBRARIES}) +set(IlmBase_LIBRARY_DIRS ${IlmBase_RELEASE_LIBRARY_DIRS}) + +# We have to add both include and include/OpenEXR to the include +# path in case OpenEXR and IlmBase are installed separately. +# +# Make sure we get the absolute path to avoid issues where +# /usr/include/OpenEXR/../ is picked up and passed to gcc from cmake +# which won't correctly compute /usr/include as an implicit system +# dir if the path is relative: +# +# https://github.com/AcademySoftwareFoundation/openvdb/issues/632 +# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70129 + +set(_IlmBase_Parent_Dir "") +get_filename_component(_IlmBase_Parent_Dir + ${IlmBase_INCLUDE_DIR}/../ ABSOLUTE) + +set(IlmBase_INCLUDE_DIRS) +list(APPEND IlmBase_INCLUDE_DIRS + ${_IlmBase_Parent_Dir} + ${IlmBase_INCLUDE_DIR} +) +unset(_IlmBase_Parent_Dir) + +# Configure imported targets + +foreach(COMPONENT ${IlmBase_FIND_COMPONENTS}) + # Configure lib type. If XXX_USE_STATIC_LIBS, we always assume a static + # lib is in use. If win32, we can't mark the import .libs as shared, so + # these are always marked as UNKNOWN. Otherwise, infer from extension. + set(ILMBASE_${COMPONENT}_LIB_TYPE UNKNOWN) + if(ILMBASE_USE_STATIC_LIBS) + set(ILMBASE_${COMPONENT}_LIB_TYPE STATIC) + elseif(UNIX) + get_filename_component(_ILMBASE_${COMPONENT}_EXT ${IlmBase_${COMPONENT}_LIBRARY_RELEASE} EXT) + if(${_ILMBASE_${COMPONENT}_EXT} STREQUAL ".a") + set(ILMBASE_${COMPONENT}_LIB_TYPE STATIC) + elseif(${_ILMBASE_${COMPONENT}_EXT} STREQUAL ".so" OR + ${_ILMBASE_${COMPONENT}_EXT} STREQUAL ".dylib") + set(ILMBASE_${COMPONENT}_LIB_TYPE SHARED) + endif() + endif() + + set(IlmBase_${COMPONENT}_DEFINITIONS) + + # Add the OPENEXR_DLL define if the library is not static on WIN32 + if(WIN32) + if(NOT ILMBASE_${COMPONENT}_LIB_TYPE STREQUAL STATIC) + list(APPEND IlmBase_${COMPONENT}_DEFINITIONS OPENEXR_DLL) + endif() + endif() + + if(NOT TARGET IlmBase::${COMPONENT}) + add_library(IlmBase::${COMPONENT} ${ILMBASE_${COMPONENT}_LIB_TYPE} IMPORTED) + set_target_properties(IlmBase::${COMPONENT} PROPERTIES + INTERFACE_COMPILE_OPTIONS "${PC_IlmBase_CFLAGS_OTHER}" + INTERFACE_COMPILE_DEFINITIONS "${IlmBase_${COMPONENT}_DEFINITIONS}" + INTERFACE_INCLUDE_DIRECTORIES "${IlmBase_INCLUDE_DIRS}") + + # Standard location + set_target_properties(IlmBase::${COMPONENT} PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" + IMPORTED_LOCATION "${IlmBase_${COMPONENT}_LIBRARY}") + + # Release location + if(EXISTS "${IlmBase_${COMPONENT}_LIBRARY_RELEASE}") + set_property(TARGET IlmBase::${COMPONENT} APPEND PROPERTY + IMPORTED_CONFIGURATIONS RELEASE) + set_target_properties(IlmBase::${COMPONENT} PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "CXX" + IMPORTED_LOCATION_RELEASE "${IlmBase_${COMPONENT}_LIBRARY_RELEASE}") + endif() + + # Debug location + if(EXISTS "${IlmBase_${COMPONENT}_LIBRARY_DEBUG}") + set_property(TARGET IlmBase::${COMPONENT} APPEND PROPERTY + IMPORTED_CONFIGURATIONS DEBUG) + set_target_properties(IlmBase::${COMPONENT} PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "CXX" + IMPORTED_LOCATION_DEBUG "${IlmBase_${COMPONENT}_LIBRARY_DEBUG}") + endif() + endif() +endforeach() diff --git a/cmake/modules/FindOpenEXR.cmake b/cmake/modules/FindOpenEXR.cmake index 40c1baa3..e6305b01 100644 --- a/cmake/modules/FindOpenEXR.cmake +++ b/cmake/modules/FindOpenEXR.cmake @@ -1,84 +1,446 @@ +# Copyright Contributors to the OpenVDB Project +# SPDX-License-Identifier: MPL-2.0 # -# A simple cmake find module for OpenEXR -# +#[=======================================================================[.rst: + +FindOpenEXR +----------- + +Find OpenEXR include dirs and libraries + +Use this module by invoking find_package with the form:: + + find_package(OpenEXR + [version] [EXACT] # Minimum or EXACT version + [REQUIRED] # Fail with error if OpenEXR is not found + [COMPONENTS ...] # OpenEXR libraries by their canonical name + # e.g. "IlmImf" for "libIlmImf" + ) + +IMPORTED Targets +^^^^^^^^^^^^^^^^ + +``OpenEXR::IlmImf`` + The IlmImf library target. +``OpenEXR::IlmImfUtil`` + The IlmImfUtil library target. + +Result Variables +^^^^^^^^^^^^^^^^ + +This will define the following variables: + +``OpenEXR_FOUND`` + True if the system has the OpenEXR library. +``OpenEXR_VERSION`` + The version of the OpenEXR library which was found. +``OpenEXR_INCLUDE_DIRS`` + Include directories needed to use OpenEXR. +``OpenEXR_RELEASE_LIBRARIES`` + Libraries needed to link to the release version of OpenEXR. +``OpenEXR_RELEASE_LIBRARY_DIRS`` + OpenEXR release library directories. +``OpenEXR_DEBUG_LIBRARIES`` + Libraries needed to link to the debug version of OpenEXR. +``OpenEXR_DEBUG_LIBRARY_DIRS`` + OpenEXR debug library directories. +``OpenEXR_DEFINITIONS`` + Definitions to use when compiling code that uses OpenEXR. +``OpenEXR_{COMPONENT}_FOUND`` + True if the system has the named OpenEXR component. + +Deprecated - use [RELEASE|DEBUG] variants: + +``OpenEXR_LIBRARIES`` + Libraries needed to link to OpenEXR. +``OpenEXR_LIBRARY_DIRS`` + OpenEXR library directories. -find_package(PkgConfig QUIET) -if(PKG_CONFIG_FOUND) - pkg_check_modules(PC_OPENEXR QUIET OpenEXR) +Cache Variables +^^^^^^^^^^^^^^^ + +The following cache variables may also be set: + +``OpenEXR_INCLUDE_DIR`` + The directory containing ``OpenEXR/config-auto.h``. +``OpenEXR_{COMPONENT}_LIBRARY`` + Individual component libraries for OpenEXR. may include target_link_libraries() debug/optimized keywords. +``OpenEXR_{COMPONENT}_LIBRARY_RELEASE`` + Individual component libraries for OpenEXR release +``OpenEXR_{COMPONENT}_LIBRARY_DEBUG`` + Individual component libraries for OpenEXR debug + +Hints +^^^^^ + +Instead of explicitly setting the cache variables, the following variables +may be provided to tell this module where to look. + +``OpenEXR_ROOT`` + Preferred installation prefix. +``OPENEXR_INCLUDEDIR`` + Preferred include directory e.g. /include +``OPENEXR_LIBRARYDIR`` + Preferred library directory e.g. /lib +``OPENEXR_DEBUG_SUFFIX`` + Suffix of the debug version of openexr libs. Defaults to "_d". +``SYSTEM_LIBRARY_PATHS`` + Global list of library paths intended to be searched by and find_xxx call +``OPENEXR_USE_STATIC_LIBS`` + Only search for static openexr libraries +``DISABLE_CMAKE_SEARCH_PATHS`` + Disable CMakes default search paths for find_xxx calls in this module + +#]=======================================================================] + +#cmake_minimum_required(VERSION 3.18) +cmake_minimum_required(VERSION 3.12) +include(GNUInstallDirs) + + +mark_as_advanced( + OpenEXR_INCLUDE_DIR + OpenEXR_LIBRARY +) + +set(_FIND_OPENEXR_ADDITIONAL_OPTIONS "") +if(DISABLE_CMAKE_SEARCH_PATHS) + set(_FIND_OPENEXR_ADDITIONAL_OPTIONS NO_DEFAULT_PATH) endif() -if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - # Under Mac OS, if the user has installed using brew, the package config - # information is not entirely accurate in that it refers to the - # true install path but brew maintains links to /usr/local for you - # which they want you to use - if(PC_OPENEXR_FOUND AND "${PC_OPENEXR_INCLUDEDIR}" MATCHES ".*/Cellar/.*") - set(_OpenEXR_HINT_INCLUDE /usr/local/include) - set(_OpenEXR_HINT_LIB /usr/local/lib) - endif() + +# Set _OPENEXR_ROOT based on a user provided root var. Xxx_ROOT and ENV{Xxx_ROOT} +# are prioritised over the legacy capitalized XXX_ROOT variables for matching +# CMake 3.12 behaviour +# @todo deprecate -D and ENV OPENEXR_ROOT from CMake 3.12 +if(OpenEXR_ROOT) + set(_OPENEXR_ROOT ${OpenEXR_ROOT}) +elseif(DEFINED ENV{OpenEXR_ROOT}) + set(_OPENEXR_ROOT $ENV{OpenEXR_ROOT}) +elseif(OPENEXR_ROOT) + set(_OPENEXR_ROOT ${OPENEXR_ROOT}) +elseif(DEFINED ENV{OPENEXR_ROOT}) + set(_OPENEXR_ROOT $ENV{OPENEXR_ROOT}) endif() -if(PC_OPENEXR_FOUND) - set(OpenEXR_CFLAGS ${PC_OPENEXR_CFLAGS_OTHER}) - set(OpenEXR_LIBRARY_DIRS ${PC_OPENEXR_LIBRARY_DIRS}) - set(OpenEXR_LDFLAGS ${PC_OPENEXR_LDFLAGS_OTHER}) - if("${_OpenEXR_HINT_INCLUDE}" STREQUAL "") - set(_OpenEXR_HINT_INCLUDE ${PC_OPENEXR_INCLUDEDIR} ${PC_OPENEXR_INCLUDE_DIRS}) - set(_OpenEXR_HINT_LIB ${PC_OPENEXR_LIBDIR} ${PC_OPENEXR_LIBRARY_DIRS}) +# Additionally try and use pkconfig to find OpenEXR +if(USE_PKGCONFIG) + if(NOT DEFINED PKG_CONFIG_FOUND) + find_package(PkgConfig) endif() + pkg_check_modules(PC_OpenEXR QUIET OpenEXR) +endif() + +# ------------------------------------------------------------------------ +# Search for OpenEXR include DIR +# ------------------------------------------------------------------------ + +set(_OPENEXR_INCLUDE_SEARCH_DIRS "") +list(APPEND _OPENEXR_INCLUDE_SEARCH_DIRS + ${OPENEXR_INCLUDEDIR} + ${_OPENEXR_ROOT} + ${PC_OpenEXR_INCLUDEDIR} + ${SYSTEM_LIBRARY_PATHS} +) + +# Look for a standard OpenEXR header file. +find_path(OpenEXR_INCLUDE_DIR OpenEXRConfig.h + ${_FIND_OPENEXR_ADDITIONAL_OPTIONS} + PATHS ${_OPENEXR_INCLUDE_SEARCH_DIRS} + PATH_SUFFIXES ${CMAKE_INSTALL_INCLUDEDIR}/OpenEXR include/OpenEXR OpenEXR +) + +if(EXISTS "${OpenEXR_INCLUDE_DIR}/OpenEXRConfig.h") + # Get the EXR version information from the config header + file(STRINGS "${OpenEXR_INCLUDE_DIR}/OpenEXRConfig.h" + _openexr_version_major_string REGEX "#define OPENEXR_VERSION_MAJOR " + ) + string(REGEX REPLACE "#define OPENEXR_VERSION_MAJOR" "" + _openexr_version_major_string "${_openexr_version_major_string}" + ) + string(STRIP "${_openexr_version_major_string}" OpenEXR_VERSION_MAJOR) + + file(STRINGS "${OpenEXR_INCLUDE_DIR}/OpenEXRConfig.h" + _openexr_version_minor_string REGEX "#define OPENEXR_VERSION_MINOR " + ) + string(REGEX REPLACE "#define OPENEXR_VERSION_MINOR" "" + _openexr_version_minor_string "${_openexr_version_minor_string}" + ) + string(STRIP "${_openexr_version_minor_string}" OpenEXR_VERSION_MINOR) + + unset(_openexr_version_major_string) + unset(_openexr_version_minor_string) + + set(OpenEXR_VERSION ${OpenEXR_VERSION_MAJOR}.${OpenEXR_VERSION_MINOR}) else() - if(UNIX) - set(OpenEXR_CFLAGS "-pthread") - if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - else() - set(OpenEXR_LDFLAGS "-pthread") + message(STATUS "FindOpenEXR.cmake - OpenEXR not found") + return() +endif() + +if(${OpenEXR_VERSION} VERSION_GREATER_EQUAL 3.0) + set(_OPENEXR_COMPONENT_LIST OpenEXR OpenEXRUtil Iex IlmThread) +else() + set(_OPENEXR_COMPONENT_LIST IlmImf IlmImfUtil) +endif() + +if(OpenEXR_FIND_COMPONENTS) + set(OPENEXR_COMPONENTS_PROVIDED TRUE) + set(_IGNORED_COMPONENTS "") + foreach(COMPONENT ${OpenEXR_FIND_COMPONENTS}) + if(NOT ${COMPONENT} IN_LIST _OPENEXR_COMPONENT_LIST) + list(APPEND _IGNORED_COMPONENTS ${COMPONENT}) endif() + endforeach() + + if(_IGNORED_COMPONENTS) + message(STATUS "Ignoring unknown components of OpenEXR:") + foreach(COMPONENT ${_IGNORED_COMPONENTS}) + message(STATUS " ${COMPONENT}") + endforeach() + list(REMOVE_ITEM OpenEXR_FIND_COMPONENTS ${_IGNORED_COMPONENTS}) endif() +else() + set(OPENEXR_COMPONENTS_PROVIDED FALSE) + set(OpenEXR_FIND_COMPONENTS ${_OPENEXR_COMPONENT_LIST}) endif() -find_path(OpenEXR_INCLUDE_DIR OpenEXRConfig.h - HINTS ${_OpenEXR_HINT_INCLUDE} - PATH_SUFFIXES OpenEXR ) -if(OpenEXR_INCLUDE_DIR AND EXISTS "${OpenEXR_INCLUDE_DIR}/OpenEXRConfig.h") - set(OpenEXR_VERSION ${PC_OPENEXR_VERSION}) - - if("${OpenEXR_VERSION}" STREQUAL "") - file(STRINGS "${OpenEXR_INCLUDE_DIR}/OpenEXRConfig.h" openexr_version_str - REGEX "^#define[\t ]+OPENEXR_VERSION_STRING[\t ]+\".*") - - string(REGEX REPLACE "^#define[\t ]+OPENEXR_VERSION_STRING[\t ]+\"([^ \\n]*)\".*" - "\\1" OpenEXR_VERSION "${openexr_version_str}") - unset(openexr_version_str) - endif() + +# ------------------------------------------------------------------------ +# Search for OPENEXR lib DIR +# ------------------------------------------------------------------------ + +if(NOT DEFINED OPENEXR_DEBUG_SUFFIX) + set(OPENEXR_DEBUG_SUFFIX _d) endif() -find_library(OpenEXR_LIBRARY NAMES IlmImf libIlmImf HINTS ${_OpenEXR_HINT_LIB}) +set(_OPENEXR_LIBRARYDIR_SEARCH_DIRS "") -find_package(IlmBase QUIET) +# Append to _OPENEXR_LIBRARYDIR_SEARCH_DIRS in priority order -unset(_OpenEXR_HINT_INCLUDE) -unset(_OpenEXR_HINT_LIB) +list(APPEND _OPENEXR_LIBRARYDIR_SEARCH_DIRS + ${OPENEXR_LIBRARYDIR} + ${_OPENEXR_ROOT} + ${PC_OpenEXR_LIBDIR} + ${SYSTEM_LIBRARY_PATHS} +) -set(OpenEXR_LIBRARIES ${OpenEXR_LIBRARY} ${IlmBase_LIBRARIES} ) -set(OpenEXR_INCLUDE_DIRS ${OpenEXR_INCLUDE_DIR} ) +set(OpenEXR_LIB_COMPONENTS "") +list(APPEND OPENEXR_BUILD_TYPES RELEASE DEBUG) -if(NOT PC_OPENEXR_FOUND) -get_filename_component(OpenEXR_LDFLAGS_OTHER ${OpenEXR_LIBRARY} PATH) -set(OpenEXR_LDFLAGS_OTHER -L${OpenEXR_LDFLAGS_OTHER}) -endif() +foreach(COMPONENT ${OpenEXR_FIND_COMPONENTS}) + foreach(BUILD_TYPE ${OPENEXR_BUILD_TYPES}) + + set(_TMP_SUFFIX "") + if(BUILD_TYPE STREQUAL DEBUG) + set(_TMP_SUFFIX ${OPENEXR_DEBUG_SUFFIX}) + endif() + + set(_OpenEXR_Version_Suffix "-${OpenEXR_VERSION_MAJOR}_${OpenEXR_VERSION_MINOR}") + set(_OPENEXR_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) + + if(WIN32) + if(OPENEXR_USE_STATIC_LIBS) + set(CMAKE_FIND_LIBRARY_SUFFIXES "${_TMP_SUFFIX}.lib") + endif() + list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES "${_OpenEXR_Version_Suffix}${_TMP_SUFFIX}.lib") + else() + if(OPENEXR_USE_STATIC_LIBS) + set(CMAKE_FIND_LIBRARY_SUFFIXES "${_TMP_SUFFIX}.a") + else() + if(APPLE) + list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES "${_OpenEXR_Version_Suffix}${_TMP_SUFFIX}.dylib") + else() + list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES "${_OpenEXR_Version_Suffix}${_TMP_SUFFIX}.so") + endif() + endif() + list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES "${_OpenEXR_Version_Suffix}${_TMP_SUFFIX}.a") + endif() + + # Find the lib + find_library(OpenEXR_${COMPONENT}_LIBRARY_${BUILD_TYPE} ${COMPONENT} + ${_FIND_OPENEXR_ADDITIONAL_OPTIONS} + PATHS ${_OPENEXR_LIBRARYDIR_SEARCH_DIRS} + PATH_SUFFIXES ${CMAKE_INSTALL_LIBDIR} lib64 lib + ) + + if(EXISTS ${OpenEXR_${COMPONENT}_LIBRARY_${BUILD_TYPE}}) + list(APPEND OpenEXR_LIB_COMPONENTS ${OpenEXR_${COMPONENT}_LIBRARY_${BUILD_TYPE}}) + list(APPEND OpenEXR_LIB_COMPONENTS_${BUILD_TYPE} ${OpenEXR_${COMPONENT}_LIBRARY_${BUILD_TYPE}}) + endif() + + # Reset library suffix + set(CMAKE_FIND_LIBRARY_SUFFIXES ${_OPENEXR_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}) + unset(_OPENEXR_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES) + unset(_OpenEXR_Version_Suffix) + unset(_TMP_SUFFIX) + endforeach() + + if(OpenEXR_${COMPONENT}_LIBRARY_DEBUG AND OpenEXR_${COMPONENT}_LIBRARY_RELEASE) + # if the generator is multi-config or if CMAKE_BUILD_TYPE is set for + # single-config generators, set optimized and debug libraries + get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) + if(_isMultiConfig OR CMAKE_BUILD_TYPE) + set(OpenEXR_${COMPONENT}_LIBRARY optimized ${OpenEXR_${COMPONENT}_LIBRARY_RELEASE} debug ${OpenEXR_${COMPONENT}_LIBRARY_DEBUG}) + else() + # For single-config generators where CMAKE_BUILD_TYPE has no value, + # just use the release libraries + set(OpenEXR_${COMPONENT}_LIBRARY ${OpenEXR_${COMPONENT}_LIBRARY_RELEASE}) + endif() + # FIXME: This probably should be set for both cases + set(OpenEXR_${COMPONENT}_LIBRARIES optimized ${OpenEXR_${COMPONENT}_LIBRARY_RELEASE} debug ${OpenEXR_${COMPONENT}_LIBRARY_DEBUG}) + endif() + + # if only the release version was found, set the debug variable also to the release version + if(OpenEXR_${COMPONENT}_LIBRARY_RELEASE AND NOT OpenEXR_${COMPONENT}_LIBRARY_DEBUG) + set(OpenEXR_${COMPONENT}_LIBRARY_DEBUG ${OpenEXR_${COMPONENT}_LIBRARY_RELEASE}) + set(OpenEXR_${COMPONENT}_LIBRARY ${OpenEXR_${COMPONENT}_LIBRARY_RELEASE}) + set(OpenEXR_${COMPONENT}_LIBRARIES ${OpenEXR_${COMPONENT}_LIBRARY_RELEASE}) + endif() + + # if only the debug version was found, set the release variable also to the debug version + if(OpenEXR_${COMPONENT}_LIBRARY_DEBUG AND NOT OpenEXR_${COMPONENT}_LIBRARY_RELEASE) + set(OpenEXR_${COMPONENT}_LIBRARY_RELEASE ${OpenEXR_${COMPONENT}_LIBRARY_DEBUG}) + set(OpenEXR_${COMPONENT}_LIBRARY ${OpenEXR_${COMPONENT}_LIBRARY_DEBUG}) + set(OpenEXR_${COMPONENT}_LIBRARIES ${OpenEXR_${COMPONENT}_LIBRARY_DEBUG}) + endif() + + # If the debug & release library ends up being the same, omit the keywords + if("${OpenEXR_${COMPONENT}_LIBRARY_RELEASE}" STREQUAL "${OpenEXR_${COMPONENT}_LIBRARY_DEBUG}") + set(OpenEXR_${COMPONENT}_LIBRARY ${OpenEXR_${COMPONENT}_LIBRARY_RELEASE} ) + set(OpenEXR_${COMPONENT}_LIBRARIES ${OpenEXR_${COMPONENT}_LIBRARY_RELEASE} ) + endif() + + if(OpenEXR_${COMPONENT}_LIBRARY) + set(OpenEXR_${COMPONENT}_FOUND TRUE) + else() + set(OpenEXR_${COMPONENT}_FOUND FALSE) + endif() +endforeach() + +# ------------------------------------------------------------------------ +# Cache and set OPENEXR_FOUND +# ------------------------------------------------------------------------ include(FindPackageHandleStandardArgs) -# handle the QUIETLY and REQUIRED arguments and set OpenEXR_FOUND to TRUE -# if all listed variables are TRUE find_package_handle_standard_args(OpenEXR - REQUIRED_VARS OpenEXR_LIBRARY OpenEXR_INCLUDE_DIR - VERSION_VAR OpenEXR_VERSION - FAIL_MESSAGE "Unable to find OpenEXR library" ) - -# older versions of cmake don't support FOUND_VAR to find_package_handle -# so just do it the hard way... -if(OPENEXR_FOUND AND NOT OpenEXR_FOUND) - set(OpenEXR_FOUND 1) + FOUND_VAR OpenEXR_FOUND + REQUIRED_VARS + OpenEXR_INCLUDE_DIR + OpenEXR_LIB_COMPONENTS + VERSION_VAR OpenEXR_VERSION + HANDLE_COMPONENTS +) + +if(NOT OpenEXR_FOUND) + if(OpenEXR_FIND_REQUIRED) + message(FATAL_ERROR "Unable to find OpenEXR") + endif() + return() endif() -mark_as_advanced(OpenEXR_INCLUDE_DIR OpenEXR_LIBRARY ) +# Partition release/debug lib vars + +set(OpenEXR_RELEASE_LIBRARIES "") +set(OpenEXR_RELEASE_LIBRARY_DIRS "") +set(OpenEXR_DEBUG_LIBRARIES "") +set(OpenEXR_DEBUG_LIBRARY_DIRS "") +foreach(LIB ${OpenEXR_LIB_COMPONENTS_RELEASE}) + get_filename_component(_EXR_LIBDIR ${LIB} DIRECTORY) + list(APPEND OpenEXR_RELEASE_LIBRARIES ${LIB}) + list(APPEND OpenEXR_RELEASE_LIBRARY_DIRS ${_EXR_LIBDIR}) +endforeach() + +foreach(LIB ${OpenEXR_LIB_COMPONENTS_DEBUG}) + get_filename_component(_EXR_LIBDIR ${LIB} DIRECTORY) + list(APPEND OpenEXR_DEBUG_LIBRARIES ${LIB}) + list(APPEND OpenEXR_DEBUG_LIBRARY_DIRS ${_EXR_LIBDIR}) +endforeach() + +list(REMOVE_DUPLICATES OpenEXR_RELEASE_LIBRARY_DIRS) +list(REMOVE_DUPLICATES OpenEXR_DEBUG_LIBRARY_DIRS) + +set(OpenEXR_LIBRARIES ${OpenEXR_RELEASE_LIBRARIES}) +set(OpenEXR_LIBRARY_DIRS ${OpenEXR_RELEASE_LIBRARY_DIRS}) + +# We have to add both include and include/OpenEXR to the include +# path in case OpenEXR and IlmBase are installed separately. +# +# Make sure we get the absolute path to avoid issues where +# /usr/include/OpenEXR/../ is picked up and passed to gcc from cmake +# which won't correctly compute /usr/include as an implicit system +# dir if the path is relative: +# +# https://github.com/AcademySoftwareFoundation/openvdb/issues/632 +# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70129 + +set(_OpenEXR_Parent_Dir "") +get_filename_component(_OpenEXR_Parent_Dir + ${OpenEXR_INCLUDE_DIR}/../ ABSOLUTE) + +set(OpenEXR_INCLUDE_DIRS) +list(APPEND OpenEXR_INCLUDE_DIRS + ${_OpenEXR_Parent_Dir} + ${OpenEXR_INCLUDE_DIR} +) +unset(_OpenEXR_Parent_Dir) + +# Configure imported target + +foreach(COMPONENT ${OpenEXR_FIND_COMPONENTS}) + # Configure lib type. If XXX_USE_STATIC_LIBS, we always assume a static + # lib is in use. If win32, we can't mark the import .libs as shared, so + # these are always marked as UNKNOWN. Otherwise, infer from extension. + set(OpenEXR_${COMPONENT}_LIB_TYPE UNKNOWN) + if(OPENEXR_USE_STATIC_LIBS) + set(OpenEXR_${COMPONENT}_LIB_TYPE STATIC) + elseif(UNIX) + get_filename_component(_OpenEXR_${COMPONENT}_EXT ${OpenEXR_${COMPONENT}_LIBRARY_RELEASE} EXT) + if(${_OpenEXR_${COMPONENT}_EXT} STREQUAL ".a") + set(OpenEXR_${COMPONENT}_LIB_TYPE STATIC) + elseif(${_OpenEXR_${COMPONENT}_EXT} STREQUAL ".so" OR + ${_OpenEXR_${COMPONENT}_EXT} STREQUAL ".dylib") + set(OpenEXR_${COMPONENT}_LIB_TYPE SHARED) + endif() + endif() + + set(OpenEXR_${COMPONENT}_DEFINITIONS) + + # Add the OPENEXR_DLL define if the library is not static on WIN32 + if(WIN32) + if(NOT OpenEXR_${COMPONENT}_LIB_TYPE STREQUAL STATIC) + list(APPEND OpenEXR_${COMPONENT}_DEFINITIONS OPENEXR_DLL) + endif() + endif() + + if(NOT TARGET OpenEXR::${COMPONENT}) + add_library(OpenEXR::${COMPONENT} ${OpenEXR_${COMPONENT}_LIB_TYPE} IMPORTED) + set_target_properties(OpenEXR::${COMPONENT} PROPERTIES + INTERFACE_COMPILE_OPTIONS "${PC_OpenEXR_CFLAGS_OTHER}" + INTERFACE_COMPILE_DEFINITIONS "${OpenEXR_${COMPONENT}_DEFINITIONS}" + INTERFACE_INCLUDE_DIRECTORIES "${OpenEXR_INCLUDE_DIRS}") + + # Standard location + set_target_properties(OpenEXR::${COMPONENT} PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" + IMPORTED_LOCATION "${OpenEXR_${COMPONENT}_LIBRARY}") + + # Release location + if(EXISTS "${OpenEXR_${COMPONENT}_LIBRARY_RELEASE}") + set_property(TARGET OpenEXR::${COMPONENT} APPEND PROPERTY + IMPORTED_CONFIGURATIONS RELEASE) + set_target_properties(OpenEXR::${COMPONENT} PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "CXX" + IMPORTED_LOCATION_RELEASE "${OpenEXR_${COMPONENT}_LIBRARY_RELEASE}") + endif() + + # Debug location + if(EXISTS "${OpenEXR_${COMPONENT}_LIBRARY_DEBUG}") + set_property(TARGET OpenEXR::${COMPONENT} APPEND PROPERTY + IMPORTED_CONFIGURATIONS DEBUG) + set_target_properties(OpenEXR::${COMPONENT} PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "CXX" + IMPORTED_LOCATION_DEBUG "${OpenEXR_${COMPONENT}_LIBRARY_DEBUG}") + endif() + endif() +endforeach() + diff --git a/ctlrender/main.cc b/ctlrender/main.cc index 152bc13e..f89e9879 100644 --- a/ctlrender/main.cc +++ b/ctlrender/main.cc @@ -56,7 +56,9 @@ #include #include #include -#include +#ifndef _WIN32 + #include +#endif #include #include "transform.hh" #include @@ -64,6 +66,24 @@ #include #include +#ifdef __linux__ +#include +#elif _WIN32 +#include +#include +#define PATH_MAX MAX_PATH +#ifndef S_ISDIR +#define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR) +#endif + +#ifndef S_ISREG +#define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG) +#endif +#define F_OK 0 + +#else +#endif + #if !defined(TRUE) #define TRUE 1 #endif @@ -180,7 +200,7 @@ int main(int argc, const char **argv) // list of input images on which to operate std::list input_image_files; - char output_path[MAXPATHLEN + 1]; + char output_path[PATH_MAX]; Compression compression = Compression::compressionNamed("PIZ"); format_t desired_format; @@ -466,7 +486,7 @@ int main(int argc, const char **argv) if (S_ISDIR(file_status.st_mode)) { memset(output_path, 0, sizeof(output_path)); - strncpy(output_path, outputFile, MAXPATHLEN); + strncpy(output_path, outputFile, PATH_MAX -1); outputFile = output_path; output_slash = output_path + strlen(output_path); if (*output_slash != '/') diff --git a/ctlrender/main.hh b/ctlrender/main.hh index a0bc0bd0..2de49901 100644 --- a/ctlrender/main.hh +++ b/ctlrender/main.hh @@ -56,7 +56,9 @@ #define CTL_UTIL_CTLRENDER_MAIN_INCLUDE #include -#include +#ifndef _WIN32 + #include +#endif #include #include diff --git a/ctlrender/tiff_file.cc b/ctlrender/tiff_file.cc index 5621016c..553a0563 100644 --- a/ctlrender/tiff_file.cc +++ b/ctlrender/tiff_file.cc @@ -58,10 +58,16 @@ #if defined(HAVE_LIBTIFF) #include #include -#include +#ifndef _WIN32 + #include +#endif #include #include -#include +#ifdef _WIN32 + #include +#else + #include +#endif void tiff_read_multiplane(TIFF *t, float scale, ctl::dpx::fb * pixels); void tiff_read_interleaved(TIFF *t, float scale, ctl::dpx::fb * pixels); @@ -562,6 +568,8 @@ void tiff_write(const char *name, float scale, uint8_t channel; const float *row; + channel = 0; + TIFFSetErrorHandler(ErrorHandler); TIFFSetWarningHandler(WarningHandler); diff --git a/ctlrender/transform.cc b/ctlrender/transform.cc index e8f1a960..92dc040f 100644 --- a/ctlrender/transform.cc +++ b/ctlrender/transform.cc @@ -68,6 +68,10 @@ #include #include +#ifdef _WIN32 + #define strcasecmp _stricmp +#endif + class CTLResult; typedef Ctl::RcPtr CTLResultPtr; diff --git a/lib/IlmCtl/CtlExc.cpp b/lib/IlmCtl/CtlExc.cpp index 233a7b7b..cc319914 100644 --- a/lib/IlmCtl/CtlExc.cpp +++ b/lib/IlmCtl/CtlExc.cpp @@ -55,7 +55,11 @@ #include #include #include -#include +#ifdef _WIN32 + #include +#else + #include +#endif #include namespace Ctl { diff --git a/lib/IlmCtl/CtlInterpreter.cpp b/lib/IlmCtl/CtlInterpreter.cpp index 765b888b..36269c4c 100755 --- a/lib/IlmCtl/CtlInterpreter.cpp +++ b/lib/IlmCtl/CtlInterpreter.cpp @@ -66,13 +66,13 @@ #include #include #include -#include #include #include #include #include #include #include +#include #ifdef WIN32 #include @@ -84,7 +84,6 @@ using namespace std; using namespace Iex; -using namespace IlmThread; #if 0 #include @@ -99,7 +98,7 @@ namespace { struct ModulePathsData { - Mutex mutex; + std::mutex mutex; vector paths; }; @@ -111,7 +110,7 @@ modulePathsInternal() static bool firstTime = true; - Lock lock(mpd.mutex); + std::lock_guard lock (mpd.mutex); // on the first attempt, load all paths from the environment variable if(firstTime) { @@ -167,7 +166,7 @@ struct Interpreter::Data { SymbolTable symtab; ModuleSet moduleSet; - Mutex mutex; + std::mutex mutex; }; @@ -196,7 +195,7 @@ Interpreter::modulePaths() vector retPaths; { ModulePathsData &mpd = modulePathsInternal(); - Lock lock(mpd.mutex); + std::lock_guard lock(mpd.mutex); retPaths = mpd.paths; } return retPaths; @@ -226,7 +225,7 @@ Interpreter::findModule (const string& moduleName) { ModulePathsData &mpd = modulePathsInternal(); - Lock lock(mpd.mutex); + std::lock_guard lock(mpd.mutex); // Users can define a separate module path besides the environment variable // per instance on ctl running. @@ -277,7 +276,7 @@ Interpreter::setModulePaths(const vector& newModPaths) { ModulePathsData &mpd = modulePathsInternal(); - Lock lock(mpd.mutex); + std::lock_guard lock(mpd.mutex); mpd.paths = newModPaths; } @@ -293,7 +292,7 @@ Interpreter::loadModule (const string &moduleName, const string &fileName, const { debug ("Interpreter::loadModule (moduleName = " << moduleName << ")"); - Lock lock (_data->mutex); + std::lock_guard lock(_data->mutex); loadModuleRecursive (moduleName, fileName, moduleSource); } @@ -406,7 +405,7 @@ void Interpreter::_loadModule(const std::string &moduleName, void Interpreter::loadFile(const std::string &fileName, const std::string &_moduleName) { - Lock lock (_data->mutex); + std::lock_guard lock(_data->mutex); std::string moduleName; char random[32]; @@ -449,7 +448,7 @@ Interpreter::loadModuleRecursive (const string &moduleName, const string &fileNa bool Interpreter::moduleIsLoaded (const std::string &moduleName) const { - Lock lock (_data->mutex); + std::lock_guard lock(_data->mutex); return moduleIsLoadedInternal (moduleName); } @@ -465,7 +464,7 @@ Interpreter::moduleIsLoadedInternal (const std::string &moduleName) const FunctionCallPtr Interpreter::newFunctionCall (const std::string &functionName) { - Lock lock (_data->mutex); + std::lock_guard lock(_data->mutex); // // Calling a CTL function with variable-size array arguments diff --git a/lib/IlmCtl/CtlRcPtr.cpp b/lib/IlmCtl/CtlRcPtr.cpp index 0883719f..eb192ebb 100644 --- a/lib/IlmCtl/CtlRcPtr.cpp +++ b/lib/IlmCtl/CtlRcPtr.cpp @@ -62,7 +62,6 @@ #include #include -using namespace IlmThread; using namespace Iex; using namespace std; @@ -70,7 +69,7 @@ namespace Ctl { namespace { const int NUM_MUTEXES = 37; -Mutex mutexes[NUM_MUTEXES]; +std::mutex mutexes[NUM_MUTEXES]; } // namespace @@ -93,7 +92,7 @@ throwRcPtrExc (const RcObject *lhs, const RcObject *rhs) } -Mutex & +std::mutex & rcPtrMutex (RcObject *ptr) { return mutexes[(unsigned long)ptr % NUM_MUTEXES]; diff --git a/lib/IlmCtl/CtlRcPtr.h b/lib/IlmCtl/CtlRcPtr.h index e55355ca..8a289604 100644 --- a/lib/IlmCtl/CtlRcPtr.h +++ b/lib/IlmCtl/CtlRcPtr.h @@ -68,7 +68,7 @@ // //----------------------------------------------------------------------- -#include +#include namespace Ctl { @@ -215,7 +215,7 @@ class RcPtr void throwRcPtrExc (const RcObject *lhs, const RcObject *rhs); -IlmThread::Mutex &rcPtrMutex (RcObject *ptr); +std::mutex &rcPtrMutex (RcObject *ptr); //--------------- @@ -228,7 +228,7 @@ RcPtr::ref () { if (_p) { - IlmThread::Lock lock (rcPtrMutex (_p)); + std::lock_guard lock (rcPtrMutex ((RcObject*)_p)); (_p->_n)++; } } @@ -243,7 +243,7 @@ RcPtr::unref () unsigned long n; { - IlmThread::Lock lock (rcPtrMutex (_p)); + std::lock_guard lock(rcPtrMutex ((RcObject*)_p)); n = --(_p->_n); } diff --git a/lib/IlmCtl/CtlStdType.cpp b/lib/IlmCtl/CtlStdType.cpp index b6aef15f..0a9495f1 100644 --- a/lib/IlmCtl/CtlStdType.cpp +++ b/lib/IlmCtl/CtlStdType.cpp @@ -53,6 +53,7 @@ /////////////////////////////////////////////////////////////////////////// #include +#include #include #include #include diff --git a/lib/IlmCtl/CtlType.cpp b/lib/IlmCtl/CtlType.cpp index ea8ea8a1..3a66557d 100644 --- a/lib/IlmCtl/CtlType.cpp +++ b/lib/IlmCtl/CtlType.cpp @@ -83,7 +83,7 @@ Type::~Type () // empty } -void Type::childElement(size_t *offset, TypePtr *type, const std::string &path, +void Type::childElement(size_t *offset, TypePtr *type, const std::string path, ...) { va_list ap; @@ -92,7 +92,7 @@ void Type::childElement(size_t *offset, TypePtr *type, const std::string &path, va_end(ap); } -void Type::childElementV(size_t *offset, TypePtr *type, const std::string &path, +void Type::childElementV(size_t *offset, TypePtr *type, const std::string path, va_list ap) { std::string segment; std::string remainder; diff --git a/lib/IlmCtl/CtlType.h b/lib/IlmCtl/CtlType.h index e4407104..d509ba24 100644 --- a/lib/IlmCtl/CtlType.h +++ b/lib/IlmCtl/CtlType.h @@ -274,10 +274,10 @@ class Type: public RcObject // identify an element in a matrix. // static void childElement(size_t *offset, TypePtr *type, - const std::string &path, ...); + const std::string path, ...); static void childElementV(size_t *offset, TypePtr *type, - const std::string &path, va_list ap); + const std::string path, va_list ap); }; diff --git a/lib/IlmCtl/CtlTypeStorage.cpp b/lib/IlmCtl/CtlTypeStorage.cpp index 0519aee3..d665e21b 100644 --- a/lib/IlmCtl/CtlTypeStorage.cpp +++ b/lib/IlmCtl/CtlTypeStorage.cpp @@ -64,7 +64,11 @@ #include #include #include -#include +#ifdef _WIN32 + #include +#else + #include +#endif #include #include #include @@ -388,7 +392,7 @@ void _set_spam(char *out, const char *in, void TypeStorage::_set(const char *src, CDataType_e src_type, size_t src_stride, size_t dst_offset, size_t count, - const std::string &path, va_list ap) { + const std::string path, va_list ap) { const char *in; char *out; size_t u; @@ -472,7 +476,7 @@ void TypeStorage::_set(const char *src, CDataType_e src_type, void TypeStorage::_get(char *dst, CDataType_e dst_type, size_t dst_stride, size_t src_offset, size_t count, - const std::string &path, va_list ap) { + const std::string path, va_list ap) { const char *in; char *out; size_t u; @@ -668,7 +672,7 @@ void TypeStorage::copy(const TypeStoragePtr &src, size_t src_offset, } void TypeStorage::set(const bool *src, size_t src_stride, size_t dst_offset, - size_t count, const std::string &path, ...) { + size_t count, const std::string path, ...) { va_list ap; va_start(ap, path); @@ -677,13 +681,13 @@ void TypeStorage::set(const bool *src, size_t src_stride, size_t dst_offset, } void TypeStorage::setv(const bool *src, size_t src_stride, size_t dst_offset, - size_t count, const std::string &path, va_list ap) { + size_t count, const std::string path, va_list ap) { _set((const char *)src, BoolTypeEnum, src_stride, dst_offset, count, path, ap); } void TypeStorage::set(const int *src, size_t src_stride, size_t dst_offset, - size_t count, const std::string &path, ...) { + size_t count, const std::string path, ...) { va_list ap; va_start(ap, path); @@ -692,14 +696,14 @@ void TypeStorage::set(const int *src, size_t src_stride, size_t dst_offset, } void TypeStorage::setv(const int *src, size_t src_stride, size_t dst_offset, - size_t count, const std::string &path, va_list ap) { + size_t count, const std::string path, va_list ap) { _set((const char *)src, IntTypeEnum, src_stride, dst_offset, count, path, ap); } void TypeStorage::set(const unsigned int *src, size_t src_stride, size_t dst_offset, size_t count, - const std::string &path, ...) { + const std::string path, ...) { va_list ap; va_start(ap, path); @@ -709,13 +713,13 @@ void TypeStorage::set(const unsigned int *src, size_t src_stride, void TypeStorage::setv(const unsigned int *src, size_t src_stride, size_t dst_offset, size_t count, - const std::string &path, va_list ap) { + const std::string path, va_list ap) { _set((const char *)src, UIntTypeEnum, src_stride, dst_offset, count, path, ap); } void TypeStorage::set(const half *src, size_t src_stride, size_t dst_offset, - size_t count, const std::string &path, + size_t count, const std::string path, ...) { va_list ap; @@ -725,7 +729,7 @@ void TypeStorage::set(const half *src, size_t src_stride, size_t dst_offset, } void TypeStorage::setv(const half *src, size_t src_stride, size_t dst_offset, - size_t count, const std::string &path, + size_t count, const std::string path, va_list ap) { _set((const char *)src, HalfTypeEnum, src_stride, dst_offset, count, path, ap); @@ -733,7 +737,7 @@ void TypeStorage::setv(const half *src, size_t src_stride, size_t dst_offset, void TypeStorage::set(const float *src, size_t src_stride, size_t dst_offset, size_t count, - const std::string &path, ...) { + const std::string path, ...) { va_list ap; va_start(ap, path); @@ -743,14 +747,14 @@ void TypeStorage::set(const float *src, size_t src_stride, void TypeStorage::setv(const float *src, size_t src_stride, size_t dst_offset, size_t count, - const std::string &path, va_list ap) { + const std::string path, va_list ap) { _set((const char *)src, FloatTypeEnum, src_stride, dst_offset, count, path, ap); } void TypeStorage::set(const std::string *src, size_t src_stride, size_t dst_offset, size_t count, - const std::string &path, ...) { + const std::string path, ...) { va_list ap; va_start(ap, path); @@ -760,14 +764,14 @@ void TypeStorage::set(const std::string *src, size_t src_stride, void TypeStorage::setv(const std::string *src, size_t src_stride, size_t dst_offset, size_t count, - const std::string &path, va_list ap) { + const std::string path, va_list ap) { _set((const char *)src, StringTypeEnum, src_stride, dst_offset, count, path, ap); } void TypeStorage::get(const bool *dst, size_t dst_stride, size_t src_offset, - size_t count, const std::string &path, + size_t count, const std::string path, ...) { va_list ap; @@ -777,13 +781,13 @@ void TypeStorage::get(const bool *dst, size_t dst_stride, size_t src_offset, } void TypeStorage::getv(const bool *dst, size_t dst_stride, size_t src_offset, - size_t count, const std::string &path, + size_t count, const std::string path, va_list ap) { _get((char *)dst, BoolTypeEnum, dst_stride, src_offset, count, path, ap); } void TypeStorage::get(const int *dst, size_t dst_stride, size_t src_offset, - size_t count, const std::string &path, + size_t count, const std::string path, ...) { va_list ap; @@ -793,14 +797,14 @@ void TypeStorage::get(const int *dst, size_t dst_stride, size_t src_offset, } void TypeStorage::getv(const int *dst, size_t dst_stride, size_t src_offset, - size_t count, const std::string &path, + size_t count, const std::string path, va_list ap) { _get((char *)dst, IntTypeEnum, dst_stride, src_offset, count, path, ap); } void TypeStorage::get(const unsigned int *dst, size_t dst_stride, size_t src_offset, size_t count, - const std::string &path, ...) { + const std::string path, ...) { va_list ap; va_start(ap, path); @@ -810,12 +814,12 @@ void TypeStorage::get(const unsigned int *dst, size_t dst_stride, void TypeStorage::getv(const unsigned int *dst, size_t dst_stride, size_t src_offset, size_t count, - const std::string &path, va_list ap) { + const std::string path, va_list ap) { _get((char *)dst, UIntTypeEnum, dst_stride, src_offset, count, path, ap); } void TypeStorage::get(const half *dst, size_t dst_stride, size_t src_offset, - size_t count, const std::string &path, ...) { + size_t count, const std::string path, ...) { va_list ap; va_start(ap, path); @@ -824,13 +828,13 @@ void TypeStorage::get(const half *dst, size_t dst_stride, size_t src_offset, } void TypeStorage::getv(const half *dst, size_t dst_stride, size_t src_offset, - size_t count, const std::string &path, va_list ap) { + size_t count, const std::string path, va_list ap) { _get((char *)dst, HalfTypeEnum, dst_stride, src_offset, count, path, ap); } void TypeStorage::get(const float *dst, size_t dst_stride, size_t src_offset, size_t count, - const std::string &path, ...) { + const std::string path, ...) { va_list ap; va_start(ap, path); @@ -840,13 +844,13 @@ void TypeStorage::get(const float *dst, size_t dst_stride, void TypeStorage::getv(const float *dst, size_t dst_stride, size_t src_offset, size_t count, - const std::string &path, va_list ap) { + const std::string path, va_list ap) { _get((char *)dst, FloatTypeEnum, dst_stride, src_offset, count, path, ap); } void TypeStorage::get(const std::string *dst, size_t dst_stride, size_t src_offset, size_t count, - const std::string &path, ...) { + const std::string path, ...) { va_list ap; va_start(ap, path); @@ -856,7 +860,7 @@ void TypeStorage::get(const std::string *dst, size_t dst_stride, void TypeStorage::getv(const std::string *dst, size_t dst_stride, size_t src_offset, size_t count, - const std::string &path, va_list ap) { + const std::string path, va_list ap) { _get((char *)dst, StringTypeEnum, dst_stride, src_offset, count, path, ap); } diff --git a/lib/IlmCtl/CtlTypeStorage.h b/lib/IlmCtl/CtlTypeStorage.h index 11e9330a..6c2eb16e 100644 --- a/lib/IlmCtl/CtlTypeStorage.h +++ b/lib/IlmCtl/CtlTypeStorage.h @@ -149,82 +149,82 @@ class TypeStorage: public RcObject { // of *varying types*. If you are setting a value in a complex/array type // you use the path mechanism described in CtlType.h void set(const bool *src, size_t src_stride=0, size_t dst_offset=0, - size_t count=1, const std::string &path=std::string(), + size_t count=1, const std::string path=std::string(), ...); void setv(const bool *src, size_t src_stride, size_t dst_offset, - size_t count, const std::string &path, va_list ap); + size_t count, const std::string path, va_list ap); void set(const int *src, size_t src_stride=0, size_t dst_offset=0, - size_t count=1, const std::string &path=std::string(), + size_t count=1, const std::string path=std::string(), ...); void setv(const int *src, size_t src_stride, size_t dst_offset, - size_t count, const std::string &path, va_list ap); + size_t count, const std::string path, va_list ap); void set(const unsigned int *src, size_t src_stride=0, size_t dst_offset=0, size_t count=1, - const std::string &path=std::string(), ...); + const std::string path=std::string(), ...); void setv(const unsigned int *src, size_t src_stride, size_t dst_offset, size_t count, - const std::string &path, va_list ap); + const std::string path, va_list ap); void set(const half *src, size_t src_stride=0, size_t dst_offset=0, - size_t count=1, const std::string &path=std::string(), + size_t count=1, const std::string path=std::string(), ...); void setv(const half *src, size_t src_stride, size_t dst_offset, - size_t count, const std::string &path, va_list ap); + size_t count, const std::string path, va_list ap); void set(const float *src, size_t src_stride=0, size_t dst_offset=0, size_t count=1, - const std::string &path=std::string(), ...); + const std::string path=std::string(), ...); void setv(const float *src, size_t src_stride, size_t dst_offset, - size_t count, const std::string &path, va_list ap); + size_t count, const std::string path, va_list ap); void set(const std::string *, size_t src_stride=0, size_t dst_offset=0, size_t count=1, - const std::string &path=std::string(), ...); + const std::string path=std::string(), ...); void setv(const std::string *src, size_t src_stride, size_t dst_offset, size_t count, - const std::string &path, va_list ap); + const std::string path, va_list ap); void get(const bool *dst, size_t dst_stride=0, size_t src_offset=0, - size_t count=1, const std::string &path=std::string(), + size_t count=1, const std::string path=std::string(), ...); void getv(const bool *dst, size_t dst_stride, size_t src_offset, - size_t count, const std::string &path, va_list ap); + size_t count, const std::string path, va_list ap); void get(const int *dst, size_t dst_stride=0, size_t src_offset=0, - size_t count=1, const std::string &path=std::string(), + size_t count=1, const std::string path=std::string(), ...); void getv(const int *dst, size_t dst_stride, size_t src_offset, - size_t count, const std::string &path, va_list ap); + size_t count, const std::string path, va_list ap); void get(const unsigned int *dst, size_t dst_stride=0, size_t src_offset=0, size_t count=1, - const std::string &path=std::string(), ...); + const std::string path=std::string(), ...); void getv(const unsigned int *dst, size_t dst_stride, size_t src_offset, size_t count, - const std::string &path, va_list ap); + const std::string path, va_list ap); void get(const half *dst, size_t dst_stride=0, size_t src_offset=0, - size_t count=1, const std::string &path=std::string(), + size_t count=1, const std::string path=std::string(), ...); void getv(const half *dst, size_t dst_stride, size_t src_offset, - size_t count, const std::string &path, va_list ap); + size_t count, const std::string path, va_list ap); void get(const float *dst, size_t dst_stride=0, size_t src_offset=0, size_t count=1, - const std::string &path=std::string(), ...); + const std::string path=std::string(), ...); void getv(const float *dst, size_t dst_stride, size_t src_offset, size_t count, - const std::string &path, va_list ap); + const std::string path, va_list ap); void get(const std::string *, size_t dst_stride=0, size_t src_offset=0, size_t count=1, - const std::string &path=std::string(), ...); + const std::string path=std::string(), ...); void getv(const std::string *dst, size_t dst_stride, size_t src_offset, size_t count, - const std::string &path, va_list ap); + const std::string path, va_list ap); private: std::string _name; @@ -232,10 +232,10 @@ class TypeStorage: public RcObject { // Does heavy lifting of set / copy functions above. void _set(const char *src, CDataType_e src_type, size_t stride, - size_t dst_offset, size_t count, const std::string &, + size_t dst_offset, size_t count, const std::string , va_list ap); void _get(char *dst, CDataType_e dst_type, size_t stride, - size_t src_offset, size_t count, const std::string &, + size_t src_offset, size_t count, const std::string , va_list ap); }; diff --git a/lib/IlmCtlSimd/CtlSimdInterpreter.cpp b/lib/IlmCtlSimd/CtlSimdInterpreter.cpp index 42ae4869..cdcf6a84 100644 --- a/lib/IlmCtlSimd/CtlSimdInterpreter.cpp +++ b/lib/IlmCtlSimd/CtlSimdInterpreter.cpp @@ -65,20 +65,18 @@ #include #include #include -#include #include #include using namespace std; using namespace Iex; -using namespace IlmThread; namespace Ctl { struct SimdInterpreter::Data { - Mutex mutex; + std::mutex mutex; unsigned long maxInstCount; unsigned long abortCount; }; @@ -119,7 +117,7 @@ SimdInterpreter::maxSamples () const void SimdInterpreter::setMaxInstCount (unsigned long count) { - Lock lock (_data->mutex); + std::lock_guard lock(_data->mutex); _data->maxInstCount = count; } @@ -127,14 +125,14 @@ SimdInterpreter::setMaxInstCount (unsigned long count) void SimdInterpreter::abortAllPrograms () { - Lock lock (_data->mutex); + std::lock_guard lock(_data->mutex); _data->abortCount += 1; } unsigned long SimdInterpreter::abortCount() { - Lock lock (_data->mutex); + std::lock_guard lock(_data->mutex); return _data->abortCount; } @@ -142,7 +140,7 @@ SimdInterpreter::abortCount() unsigned long SimdInterpreter::maxInstCount() { - Lock lock (_data->mutex); + std::lock_guard lock(_data->mutex); return _data->maxInstCount; } diff --git a/lib/IlmImfCtl/ImfCtlApplyTransforms.cpp b/lib/IlmImfCtl/ImfCtlApplyTransforms.cpp index 4f84ea7e..aa84ba00 100644 --- a/lib/IlmImfCtl/ImfCtlApplyTransforms.cpp +++ b/lib/IlmImfCtl/ImfCtlApplyTransforms.cpp @@ -66,8 +66,8 @@ #include #include #include -#include #include +#include using namespace std; using namespace Iex; @@ -353,7 +353,7 @@ class CallFunctionsTask: public Task const FrameBuffer &inFb, Header &outHeader, const FrameBuffer &outFb, - Mutex &exceptionMutex, + std::mutex &exceptionMutex, string &exceptionWhat); virtual void execute(); @@ -370,7 +370,7 @@ class CallFunctionsTask: public Task const FrameBuffer & _inFb; Header & _outHeader; const FrameBuffer & _outFb; - Mutex & _exceptionMutex; + std::mutex & _exceptionMutex; string & _exceptionWhat; }; @@ -387,7 +387,7 @@ CallFunctionsTask::CallFunctionsTask const FrameBuffer &inFb, Header &outHeader, const FrameBuffer &outFb, - Mutex &exceptionMutex, + std::mutex &exceptionMutex, string &exceptionWhat) : Task (group), @@ -450,12 +450,12 @@ CallFunctionsTask::execute() } catch (const std::exception &exc) { - Lock lock (_exceptionMutex); + std::lock_guard lock(_exceptionMutex); _exceptionWhat = exc.what(); } catch (...) { - Lock lock (_exceptionMutex); + std::lock_guard lock(_exceptionMutex); _exceptionWhat = "unrecognized exception"; } } @@ -506,7 +506,7 @@ applyTransforms // and releases the mutex. // - Mutex exceptionMutex; + std::mutex exceptionMutex; string exceptionWhat; { diff --git a/lib/dpx/dpx_rw.cc b/lib/dpx/dpx_rw.cc index 9c7b2d62..2c197806 100644 --- a/lib/dpx/dpx_rw.cc +++ b/lib/dpx/dpx_rw.cc @@ -56,6 +56,10 @@ #include "dpx_rw.hh" #include +#ifdef _WIN32 + #define strncasecmp _strnicmp +#endif + namespace ctl { namespace dpxi { diff --git a/lib/dpx/dpx_util.cc b/lib/dpx/dpx_util.cc index 2ee75dba..83f09cae 100644 --- a/lib/dpx/dpx_util.cc +++ b/lib/dpx/dpx_util.cc @@ -55,7 +55,11 @@ #include "dpx_util.hh" #include #include -#include +#ifdef _WIN32 + #include +#else + #include +#endif #include namespace ctl { diff --git a/unittest/ctlrender/CMakeLists.txt b/unittest/ctlrender/CMakeLists.txt index 3c4e6840..4a4239a6 100644 --- a/unittest/ctlrender/CMakeLists.txt +++ b/unittest/ctlrender/CMakeLists.txt @@ -1,10 +1,18 @@ -add_test( +find_program(BASH_PROGRAM bash) +if (BASH_PROGRAM) + MESSAGE( STATUS "BASH found, able to run ctlrender unit test" ) + add_test( NAME ctlrender WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ./test.sh $ + COMMAND ${BASH_PROGRAM} ./test.sh $ ) +else() + MESSAGE( STATUS "BASH not found, able to run ctlrender unit test" ) +endif (BASH_PROGRAM) + + find_package(TIFF) if ( TARGET TIFF::TIFF ) @@ -14,4 +22,4 @@ else() set_property(TEST ctlrender PROPERTY ENVIRONMENT "IS_TIFF_FOUND=0") endif() -#add_dependencies(check ctlrender) + diff --git a/vcpkg.json b/vcpkg.json new file mode 100644 index 00000000..30e9cb44 --- /dev/null +++ b/vcpkg.json @@ -0,0 +1,9 @@ +{ + "name": "ctl", + "version": "1.5.2", + "dependencies": [ + "imath", + "openexr", + "tiff" + ] +}