Skip to content

Commit

Permalink
add ZLIB to CMakeLists.txt target_link_libraries() (#162)
Browse files Browse the repository at this point in the history
* add ZLIB to CMAKE target_link_libraries() as discussed in issue #134

* add debugging message for ZLIB in CMAKE

* add mac openexr2 static and docker openexr2 static to github workflow
  • Loading branch information
michaeldsmith authored Jul 12, 2024
1 parent fef45f2 commit b30c769
Show file tree
Hide file tree
Showing 8 changed files with 260 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/docker_linuxes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -201,3 +201,13 @@ jobs:

- name: Run unit tests (ctest) within the Docker image
run: docker run ctl:latest sh -c "cd ./build && ctest"

ubuntu-openexr2-static:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build the Docker image
run: docker build --no-cache --rm -f ./docker/Dockerfile_ubuntu_22.04_openexr2_static -t ctl:latest .

- name: Run unit tests (ctest) within the Docker image
run: docker run ctl:latest sh -c "cd ./build && ctest"
184 changes: 184 additions & 0 deletions .github/workflows/mac_release_static.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
name: macOS-Release-shared

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:

runs-on: macos-latest

steps:

# - name: uninstall openexr
# run: brew uninstall --ignore-dependencies openexr

# - name: uninstall imath
# run: brew uninstall --ignore-dependencies imath

- name: install dependencies - openexr v2.5
run: |
cd ..
git clone https://github.com/AcademySoftwareFoundation/openexr.git &&
cd openexr &&
git checkout RB-2.5 &&
mkdir build &&
cd build &&
cmake -DBUILD_SHARED_LIBS=OFF .. &&
make &&
sudo make install
- uses: actions/checkout@v4

- 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}} -DBUILD_SHARED_LIBS=OFF

- name: Build
# Build your program with the given configuration
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}

build-openexr3:
runs-on: macos-latest

steps:

- name: install dependencies - imath
run: |
cd ..
git clone https://github.com/AcademySoftwareFoundation/Imath.git &&
cd Imath &&
mkdir build &&
cd build &&
cmake -DBUILD_SHARED_LIBS=OFF .. &&
make &&
sudo make install
- name: install dependencies - openexr v3.1
run: |
cd ..
git clone https://github.com/AcademySoftwareFoundation/openexr.git &&
cd openexr &&
git checkout RB-3.1 &&
mkdir build &&
cd build &&
cmake -DBUILD_SHARED_LIBS=OFF .. &&
make &&
sudo make install
- uses: actions/checkout@v4

- 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}} -DBUILD_SHARED_LIBS=OFF

- name: Build
# Build your program with the given configuration
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}

test-openexr2:

runs-on: macos-latest

steps:

# - name: uninstall openexr
# run: brew uninstall --ignore-dependencies openexr

# - name: uninstall imath
# run: brew uninstall --ignore-dependencies imath

- name: install dependencies - openexr v2.5
run: |
cd ..
git clone https://github.com/AcademySoftwareFoundation/openexr.git &&
cd openexr &&
git checkout RB-2.5 &&
mkdir build &&
cd build &&
cmake -DBUILD_SHARED_LIBS=OFF .. &&
make &&
sudo make install
- uses: actions/checkout@v4

- 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}} -DBUILD_SHARED_LIBS=OFF

- name: Build
# Build your program with the given configuration
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}

- name: Install
run: sudo cmake --install ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}

- name: Test
working-directory: ${{github.workspace}}/build
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest -V --output-on-failure

test-openexr3:
runs-on: macos-latest

steps:

- name: install dependencies - imath
run: |
cd ..
git clone https://github.com/AcademySoftwareFoundation/Imath.git &&
cd Imath &&
mkdir build &&
cd build &&
cmake -DBUILD_SHARED_LIBS=OFF .. &&
make &&
sudo make install
- name: install dependencies - openexr v3.1
run: |
cd ..
git clone https://github.com/AcademySoftwareFoundation/openexr.git &&
cd openexr &&
git checkout RB-3.1 &&
mkdir build &&
cd build &&
cmake -DBUILD_SHARED_LIBS=OFF .. &&
make &&
sudo make install
- uses: actions/checkout@v4

- 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}} -DBUILD_SHARED_LIBS=OFF

- name: Build
# Build your program with the given configuration
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}

- name: Install
run: sudo cmake --install ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}

- name: Test
working-directory: ${{github.workspace}}/build
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest -V --output-on-failure

14 changes: 14 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,20 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
"Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()

# ZLIB is automatically added by OpenEXR 3.x but needs to be added for OpenEXR 2.x
find_package(ZLIB)
if(TARGET ZLIB::ZLIB)
message( STATUS "found ZLIB" )
message( STATUS " ZLIB_VERSION : ${ZLIB_VERSION}" )
message( STATUS " ZLIB_INCLUDE_DIRS : ${ZLIB_INCLUDE_DIRS}" )
message( STATUS " ZLIB_LIBRARIES : ${ZLIB_LIBRARIES}" )
message( STATUS " ZLIB_INCLUDE_DIR : ${ZLIB_INCLUDE_DIR}" )
message( STATUS " ZLIB_LIBRARY : ${ZLIB_LIBRARY}" )
else()
message( STATUS "ZLIB was not found")
message( STAUTS " ZLIB is automatically linked when using OpenEXR 3.x but CTL needs to link to ZLIB if using OpenEXR 2.x" )
endif()

find_package(OpenEXR 3 CONFIG QUIET)
if(OpenEXR_FOUND)
message(STATUS "Found OpenEXR ${OpenEXR_VERSION}")
Expand Down
2 changes: 2 additions & 0 deletions OpenEXR_CTL/exr_ctl_exr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ target_link_libraries (exr_ctl_exr
$<$<TARGET_EXISTS:IlmBase::Half>:IlmBase::Half>
$<$<TARGET_EXISTS:IlmBase::IlmThread>:IlmBase::IlmThread>
$<$<TARGET_EXISTS:IlmBase::Iex>:IlmBase::Iex>
# ZLIB for OpenEXR 2.x:
$<$<TARGET_EXISTS:ZLIB::ZLIB>:ZLIB::ZLIB>
)
#target_link_libraries( exr_ctl_exr ${IlmBase_LIBRARIES} ${IlmBase_LDFLAGS_OTHER} )
#target_link_libraries( exr_ctl_exr ${OpenEXR_LIBRARIES} ${OpenEXR_LDFLAGS_OTHER} )
Expand Down
2 changes: 2 additions & 0 deletions OpenEXR_CTL/exrdpx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ target_link_libraries (exrdpx
$<$<TARGET_EXISTS:IlmBase::Half>:IlmBase::Half>
$<$<TARGET_EXISTS:IlmBase::IlmThread>:IlmBase::IlmThread>
$<$<TARGET_EXISTS:IlmBase::Iex>:IlmBase::Iex>
# ZLIB for OpenEXR 2.x:
$<$<TARGET_EXISTS:ZLIB::ZLIB>:ZLIB::ZLIB>
)
#target_link_libraries( exrdpx ${IlmBase_LIBRARIES} ${IlmBase_LDFLAGS_OTHER} )
#target_link_libraries( exrdpx ${OpenEXR_LIBRARIES} ${OpenEXR_LDFLAGS_OTHER} )
Expand Down
2 changes: 2 additions & 0 deletions ctlrender/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ target_link_libraries(ctlrender
$<$<TARGET_EXISTS:IlmBase::Half>:IlmBase::Half>
$<$<TARGET_EXISTS:IlmBase::IlmThread>:IlmBase::IlmThread>
$<$<TARGET_EXISTS:IlmBase::Iex>:IlmBase::Iex>
# ZLIB for OpenEXR 2.x:
$<$<TARGET_EXISTS:ZLIB::ZLIB>:ZLIB::ZLIB>
)

if( OpenEXR_FOUND )
Expand Down
44 changes: 44 additions & 0 deletions docker/Dockerfile_ubuntu_22.04_openexr2_static
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
FROM ubuntu:22.04

RUN apt-get update

# disable interactive install
ENV DEBIAN_FRONTEND noninteractive

# install developement tools
RUN apt-get -y install cmake
RUN apt-get -y install g++
RUN apt-get -y install git

# install CTL dependencies
#RUN apt-get -y install libopenexr-dev
#RUN apt-get -y install libtiff-dev

# install CTL dependencies - zlib
RUN apt-get -y install zlib1g-dev

# install CTL dependecies - openexr
WORKDIR /usr/src/
RUN git clone https://github.com/AcademySoftwareFoundation/openexr.git
WORKDIR /usr/src/openexr
RUN git checkout RB-2.5
WORKDIR /usr/src/openexr/build
RUN cmake .. -DBUILD_SHARED_LIBS=OFF -DBUILD_TESTING=OFF -DOPENEXR_BUILD_TOOLS=OFF -DOPENEXR_INSTALL_EXAMPLES=OFF
RUN make
RUN make install

# build CTL
WORKDIR /usr/src/CTL
COPY . .
WORKDIR /usr/src/CTL/build
RUN rm -R * || true
RUN cmake -DBUILD_SHARED_LIBS=OFF ..
RUN make
RUN make install

# add /usr/local/lib to the LD_LIBRARY_PATH
# ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib

# finalize docker environment
WORKDIR /usr/src/CTL

2 changes: 2 additions & 0 deletions unittest/IlmImfCtl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ target_link_libraries( IlmImfCtlTest
$<$<TARGET_EXISTS:IlmBase::Half>:IlmBase::Half>
$<$<TARGET_EXISTS:IlmBase::IlmThread>:IlmBase::IlmThread>
$<$<TARGET_EXISTS:IlmBase::Iex>:IlmBase::Iex>
# ZLIB for OpenEXR 2.x:
$<$<TARGET_EXISTS:ZLIB::ZLIB>:ZLIB::ZLIB>
)

add_test( IlmImfCtl IlmImfCtlTest )
Expand Down

0 comments on commit b30c769

Please sign in to comment.