Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Scripts/cmake/o3de_package_utilities.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,22 @@ macro(o3de_import_existing_config_files package_name search_dir)
# for other platforms, we set the xxxx_ROOT value.
set(_old_find_root_path ${CMAKE_FIND_ROOT_PATH})
set(CMAKE_FIND_ROOT_PATH ${search_dir} ${CMAKE_FIND_ROOT_PATH})

set(_old_ignore_prefix_path ${CMAKE_IGNORE_PREFIX_PATH})
set(CMAKE_IGNORE_PREFIX_PATH ${CMAKE_CURRENT_LIST_DIR})
Comment on lines +133 to +134

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note, this prevents an infinite recursion problem, where this file would find package and its own folder is added to the package prefix paths.


set(${package_name}_ROOT ${search_dir})
# its also possible that an older version of _DIR has been cached.
unset(${package_name}_DIR CACHE)
unset(${package_name}_DIR)
find_package(${package_name} CONFIG REQUIRED)
# reset these variables back to what they were.
set(CMAKE_FIND_ROOT_PATH ${_old_find_root_path})
if (_old_ignore_prefix_path)
set(CMAKE_IGNORE_PREFIX_PATH ${_old_ignore_prefix_path})
else()
unset(CMAKE_IGNORE_PREFIX_PATH)
endif()
if (NOT ${package_name}_FOUND)
message(FATAL_ERROR "Could not import configs for ${package_name} from ${search_dir}")
endif()
Expand Down
24 changes: 17 additions & 7 deletions Scripts/extras/pull_and_build_from_git.py
Original file line number Diff line number Diff line change
Expand Up @@ -635,17 +635,27 @@ def sync_source(self):
if len(call_result.stdout.decode('utf-8', 'ignore')):
# If anything changed, then restore the entire source tree
print(f"Path '{self.src_folder}' was modified. Restoring...")
git_restore_cmd = ['git', 'restore', '--recurse-submodules', ':/']
call_result = subprocess.run(subp_args(git_restore_cmd),
shell=True,
capture_output=False,
cwd=str(self.src_folder.resolve()))
git_clean_command = ['git', 'clean', '-fd']
call_result = subprocess.run(subp_args(git_clean_command),
shell=True,
capture_output=False,
cwd=str(self.src_folder.resolve()))
if call_result.returncode != 0:
Comment on lines +638 to 643

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note, this just adds a clean -fd before the restore command, since restore won't remove untracked files.

# If we cannot restore through git, then delete the folder and re-clone
print(f"Unable to restore {self.src_folder}. Deleting and re-cloning...")
print(f"Unable to clean {self.src_folder}. Deleting and re-cloning...")
delete_folder(self.src_folder)
self.clone_to_local()

else:
git_restore_cmd = ['git', 'restore', '--recurse-submodules', ':/']
call_result = subprocess.run(subp_args(git_restore_cmd),
shell=True,
capture_output=False,
cwd=str(self.src_folder.resolve()))
if call_result.returncode != 0:
# If we cannot restore through git, then delete the folder and re-clone
print(f"Unable to restore {self.src_folder}. Deleting and re-cloning...")
delete_folder(self.src_folder)
self.clone_to_local()
# Do a re-pull
git_pull_cmd = ['git',
'pull']
Expand Down
34 changes: 0 additions & 34 deletions package-system/OpenEXR/FindImath.cmake

This file was deleted.

60 changes: 4 additions & 56 deletions package-system/OpenEXR/FindOpenEXR.cmake
Original file line number Diff line number Diff line change
@@ -1,62 +1,10 @@
#
# Copyright (c) Contributors to the Open 3D Engine Project.
# For complete copyright and license terms please see the LICENSE at the root of this distribution.
# For complete copyright and license terms please see the LICENSE at the root of this distribution.
#
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
#

if (TARGET 3rdParty::OpenEXR)
return()
endif()

include(${CMAKE_CURRENT_LIST_DIR}/o3de_package_utilities.cmake)

# OpenEXR depends on ZLIB. For maximum compatibility here, we use the
# official ZLIB library name, ie, ZLIB::ZLIB and not o3de 3rdParty::ZLIB.
# O3DE's zlib package will define both. If we're in O3DE we can also
# auto-download ZLIB.
if (NOT TARGET ZLIB::ZLIB)
if (COMMAND ly_download_associated_package)
ly_download_associated_package(ZLIB REQUIRED MODULE)
endif()
find_package(ZLIB REQUIRED)
endif()

find_package(Imath MODULE REQUIRED) # will bring in the FindImath.cmake in the same folder

# read the existing config files that OpenEXR made when it compiled:
o3de_import_existing_config_files(OpenEXR ${CMAKE_CURRENT_LIST_DIR}/OpenEXR/lib/cmake)

# map from "OpenEXR::xxxxx to 3rdParty::xxxxxx"
o3de_import_targets(NAMESPACE_FROM
OpenEXR
NAMESPACE_TO
3rdParty
COMPONENTS
OpenEXRConfig
IexConfig
IlmThreadConfig
Iex
IlmThread
OpenEXRCore
OpenEXRUtil
OpenEXR)

# fixup OpenEXR::xxxxxx it forces /EHsc when compiled on windows MSVC, when it should be doing so when targetted to it instead:
set_target_properties(OpenEXR::Iex PROPERTIES INTERFACE_COMPILE_OPTIONS "$<$<CXX_COMPILER_ID:MSVC>:/EHsc>")
set_target_properties(OpenEXR::IlmThread PROPERTIES INTERFACE_COMPILE_OPTIONS "$<$<CXX_COMPILER_ID:MSVC>:/EHsc>")
set_target_properties(OpenEXR::OpenEXRCore PROPERTIES INTERFACE_COMPILE_OPTIONS "$<$<CXX_COMPILER_ID:MSVC>:/EHsc>")
set_target_properties(OpenEXR::OpenEXR PROPERTIES INTERFACE_COMPILE_OPTIONS "$<$<CXX_COMPILER_ID:MSVC>:/EHsc>")
set_target_properties(OpenEXR::OpenEXRUtil PROPERTIES INTERFACE_COMPILE_OPTIONS "$<$<CXX_COMPILER_ID:MSVC>:/EHsc>")

# if we're not in O3DE, it's also extremely helpful to show a message to logs that indicate that this
# library was successfully picked up, as opposed to the system one.
# A good way to know if you're in O3DE or not is that O3DE sets various cache variables before
# calling find_package, specifically, LY_VERSION_ENGINE_NAME is always set very early:
if (NOT LY_VERSION_ENGINE_NAME)
message(STATUS "Using OpenEXR ${OpenEXR_VERSION} from ${CMAKE_CURRENT_LIST_DIR}")
endif()

# compat - some libraries check for OPENEXR_VERSION even though the correct check is OpenEXR_VERSION
set(OPENEXR_VERSION ${OpenEXR_VERSION})
# force this into config mode, so that it uses the config files instead of module files.
set(OpenEXR_DIR ${CMAKE_CURRENT_LIST_DIR})
find_package(OpenEXR 3.4.13 REQUIRED CONFIG)
25 changes: 4 additions & 21 deletions package-system/OpenEXR/README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,5 @@
# Ilmbase Build From Source Instructions #
## Prerequisites ##
* 3p-package-scripts (https://github.com/o3de/3p-package-scripts)

## To build

set the working directory the the root of the 3p-package-source repository (where the package_build_list* json files are located.)

# mac
python3 ../3p-package-scripts/o3de_package_scripts/build_package.py --search_path . OpenEXR-3.1.3-rev1-mac
# windows
python ..\3p-package-scripts\o3de_package_scripts\build_package.py --search_path . OpenEXR-3.1.3-rev1-windows
# linux
python3 ../3p-package-scripts/o3de_package_scripts/build_package.py --search_path . OpenEXR-3.1.3-rev1-linux

# on all platforms:

Build artifacts will be located in the packages folder.

## note about iMath library
The iMath library is built as part of OpenEXR but lives in a separate repository. The build script for OpenEXR will fetch imath and pass the same build parameters that were fed in for OpenEXR when building it. This means the command line for OpenEXR should contain both OpenEXR-specific parameters like ``OPENEXR_BUILD_TESTS`` but also more generic parameters that iMath will recognise like ``BUILD_TESTING=OFF`` to be passed through.
## OpenEXR from ASWF

The PATCH file (o3de-oexr.patch) just renames a single file in the vendored openjph library,
to make it so that the object file name does not collide, and trigger
https://github.com/AcademySoftwareFoundation/openexr/issues/2596
77 changes: 40 additions & 37 deletions package-system/OpenEXR/build_config.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
{
"git_url":"https://github.com/AcademySoftwareFoundation/openexr.git",
"git_tag":"v3.1.3",
"git_tag":"v3.4.13",
"package_name":"OpenEXR",
"package_version":"3.1.3-rev4",
"package_version":"3.4.13-rev1",
"package_url":"https://www.openexr.com/",
"package_license":"BSD-3-Clause",
"package_license_file":"LICENSE.md",
"cmake_find_source":"FindOpenEXR.cmake",
"cmake_find_target":"FindOpenEXR.cmake",
"patch_file": "o3de-oexr.patch",
"extra_files_to_copy": [
["FindImath.cmake", "FindImath.cmake"],
["../../Scripts/cmake/o3de_package_utilities.cmake", "o3de_package_utilities.cmake"]
["../../Scripts/cmake/o3de_package_utilities.cmake", "o3de_package_utilities.cmake"],
["openexr-config.cmake", "openexr-config.cmake"],
["openexr-config-version.cmake", "openexr-config-version.cmake"]
],
"cmake_install_filter":[
"*.cmake",
Expand All @@ -22,33 +24,45 @@
"cmake_generate_args_common" : [
"-DBUILD_TESTING=OFF",
"-DOPENEXR_BUILD_EXAMPLES=OFF",
"-DOPENEXR_INSTALL_EXAMPLES=OFF",
"-DOPENEXR_BUILD_TOOLS=OFF",
"-DOPENEXR_INSTALL_TOOLS=OFF",
"-DOPENEXR_RUN_FUZZ_TESTS=OFF",
"-DOPENEXR_INSTALL_DOCS=OFF",
"-DBUILD_WEBSITE=OFF",
"-DOPENEXR_BUILD_PYTHON=OFF",
"-DBUILD_TESTING=OFF",
"-DOPENEXR_INSTALL_PKG_CONFIG=OFF",
"-DOPENEXR_USE_TBB=OFF",
"-DOPENEXR_INSTALL_DEVELOPER_TOOLS=OFF",
"-DOPENEXR_BUILD_OSS_FUZZ=OFF",
"-DOPENEXR_TEST_LIBRARIES=OFF",
"-DOPENEXR_TEST_TOOLS=OFF",
"-DOPENEXR_TEST_PYTHON=OFF",
"-DBUILD_SHARED_LIBS=OFF",
"-DDOCS=OFF",
"-DPYTHON=OFF"
"-DOPENEXR_FORCE_INTERNAL_DEFLATE=ON",
"-DOPENEXR_FORCE_INTERNAL_OPENJPH=ON",
"-DOPENEXR_IS_SUBPROJECT=ON",
"-DOPENEXR_FORCE_INTERNAL_IMATH=OFF"
],
"cmake_build_args_common" : [
"--parallel"
],
"Platforms":{
"Windows":{
"Windows":{
"build_configs" : ["Debug", "Release"],
"package_version":"3.1.3-rev5",
"cmake_generate_args": ["-G\"Ninja Multi-Config\""],
"depends_on_packages" :[
["zlib-1.2.11-rev5-windows", "8847112429744eb11d92c44026fc5fc53caa4a06709382b5f13978f3c26c4cbd", ""]
],
"cmake_generate_args":[
"-G",
"\"Visual Studio 16 2019\""
["zlib-1.2.11-rev5-windows", "8847112429744eb11d92c44026fc5fc53caa4a06709382b5f13978f3c26c4cbd", ""],
["Imath-3.2.2-rev2-windows", "d2ca872921bb690ae039495f9bdf7038a4155cd0f8f272774e8159088bf433fe", ""]
],
"custom_test_cmd" : [
"test_openexr_windows.cmd"
]
},
"Android": {
"depends_on_packages" :[
["zlib-1.2.11-rev5-android", "73c9e88892c237a3fc6eafc04268ccd9d479e6d55f9df2ed58b236c8f9cf2cae", ""]
["zlib-1.2.11-rev5-android", "73c9e88892c237a3fc6eafc04268ccd9d479e6d55f9df2ed58b236c8f9cf2cae", ""],
["Imath-3.2.2-rev2-android", "c41d3b86cd2cc40f57b209c8f838506898914951290a3cc1f592a51ff71dc494", ""]
],
"build_configs" : ["Release"],
"cmake_generate_args_release": [
Expand All @@ -63,45 +77,32 @@
}
},
"Darwin":{
"Mac":{
"build_configs" : ["Release"],
"depends_on_packages" :[
["zlib-1.2.11-rev5-mac", "b6fea9c79b8bf106d4703b67fecaa133f832ad28696c2ceef45fb5f20013c096", ""]
],
"custom_toolchain_file" : "../cmake/Platform/Mac/Toolchain_mac.cmake",
"cmake_generate_args_release": [
"-G",
"Xcode"
],
"custom_test_cmd" : [
"./test_openexr_mac.sh"
]
},
"Mac-arm64":{
"git_tag":"v3.4.4",
"package_version":"3.4.4-rev1",
"build_configs" : ["Release"],
"depends_on_packages" :[
["zlib-1.3.1-rev2-mac-arm64", "52e62890329d3e003226fca88df30701cdd862a5f137eb5f75dff504377c13b3", ""]
["zlib-1.3.1-rev2-mac-arm64", "52e62890329d3e003226fca88df30701cdd862a5f137eb5f75dff504377c13b3", ""],
["Imath-3.2.2-rev2-mac-arm64", "5fc5088717927da41c33f2f100c68691a3277d7b564060fdd4743a1b0ffd50f1", ""]
],
"custom_toolchain_file" : "../cmake/Platform/Mac/Toolchain_mac.cmake",
"cmake_generate_args_release": [
"-G",
"Xcode"
],
"custom_test_cmd" : [
"./test_openexr_mac_3_4.sh"
"./test_openexr_mac.sh"
]
},
"iOS":{
"build_configs" : ["Release"],
"depends_on_packages" :[
["zlib-1.2.11-rev5-ios", "c7f10b4d0fe63192054d926f53b08e852cdf472bc2b18e2f7be5aecac1869f7f", ""]
["zlib-1.2.11-rev5-ios", "c7f10b4d0fe63192054d926f53b08e852cdf472bc2b18e2f7be5aecac1869f7f", ""],
["Imath-3.2.2-rev2-ios", "0ca26f7e9cdeaa940caac39b5a7f5db0344d7f76cca4123874e4e10a6ec0e907", ""]
],
"custom_toolchain_file" : "../cmake/Platform/iOS/Toolchain_ios.cmake",
"cmake_generate_args_release": [
"-G",
"Xcode"
"Xcode",
"-DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=BOTH"
],
"custom_test_cmd" : [
"./test_openexr_ios.sh"
Expand All @@ -112,7 +113,8 @@
"Linux":{
"build_configs" : ["release"],
"depends_on_packages" :[
["zlib-1.2.11-rev5-linux", "9be5ea85722fc27a8645a9c8a812669d107c68e6baa2ca0740872eaeb6a8b0fc", ""]
["zlib-1.2.11-rev5-linux", "9be5ea85722fc27a8645a9c8a812669d107c68e6baa2ca0740872eaeb6a8b0fc", ""],
["Imath-3.2.2-rev2-linux", "aec34a555a893c64f7a8f00262378e15d13b666a05e0298cba7025faed99117f", ""]
],
"cmake_generate_args_release":[
"-G",
Expand All @@ -126,7 +128,8 @@
"Linux-aarch64":{
"build_configs" : ["release"],
"depends_on_packages" :[
["zlib-1.2.11-rev5-linux-aarch64", "ce9d1ed2883d77ffc69c7982c078595c1f89ca55ec19d89fe7e6beb05f774775", ""]
["zlib-1.2.11-rev5-linux-aarch64", "ce9d1ed2883d77ffc69c7982c078595c1f89ca55ec19d89fe7e6beb05f774775", ""],
["Imath-3.2.2-rev2-linux-aarch64", "5494761ec31afea8e436dcd942492b9de24c538601f550294873169a3b5219ba", ""]
],
"cmake_generate_args_release":[
"-G",
Expand Down
4 changes: 4 additions & 0 deletions package-system/OpenEXR/o3de-oexr.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
diff --git a/external/OpenJPH/src/core/others/ojph_mem.c b/external/OpenJPH/src/core/others/ojph_mem_c.c
similarity index 100%
rename from external/OpenJPH/src/core/others/ojph_mem.c
rename to external/OpenJPH/src/core/others/ojph_mem_c.c
25 changes: 25 additions & 0 deletions package-system/OpenEXR/openexr-config-version.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#
# Copyright (c) Contributors to the Open 3D Engine Project.
# For complete copyright and license terms please see the LICENSE at the root of this distribution.
#
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
#

set(PACKAGE_VERSION 3.4.13)
set(PACKAGE_VERSION_EXACT False)
set(PACKAGE_VERSION_COMPATIBLE False)

if (NOT ${PACKAGE_FIND_NAME} STREQUAL "OpenEXR")
return()
endif()

if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)
return()
endif()

set(PACKAGE_VERSION_COMPATIBLE TRUE)

if (PACKAGE_FIND_VERSION VERSION_EQUAL PACKAGE_VERSION)
set(PACKAGE_VERSION_EXACT TRUE)
endif()
Loading
Loading