Skip to content

Commit

Permalink
WIP new builder scheme
Browse files Browse the repository at this point in the history
Signed-off-by: Larry Gritz <[email protected]>
  • Loading branch information
lgritz committed Nov 16, 2024
1 parent 88dc0ba commit aedeff3
Show file tree
Hide file tree
Showing 9 changed files with 274 additions and 124 deletions.
19 changes: 19 additions & 0 deletions src/build-scripts/build_dependencies.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash

# Copyright Contributors to the OpenImageIO project.
# SPDX-License-Identifier: Apache-2.0
# https://github.com/AcademySoftwareFoundation/OpenImageIO


defs=""
for arg in "$@"
do
echo "Building $arg"
defs+=" -DBUILD_${arg}=ON"
done


if [[ "$defs" != "" ]]; then
cmake -S src/cmake/dependencies -B build/deps/depbuild -DCMAKE_INSTALL_PREFIX=build/deps/dist $defs
cmake --build build/deps/depbuild
fi
47 changes: 0 additions & 47 deletions src/cmake/build_Imath.cmake

This file was deleted.

53 changes: 0 additions & 53 deletions src/cmake/build_OpenEXR.cmake

This file was deleted.

76 changes: 76 additions & 0 deletions src/cmake/dependencies/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Copyright Contributors to the OpenImageIO project.
# SPDX-License-Identifier: Apache-2.0
# https://github.com/AcademySoftwareFoundation/OpenImageIO

cmake_minimum_required (VERSION 3.18.2)

project (OpenImageIO_Dependencies
LANGUAGES CXX C)

list (APPEND CMAKE_MODULE_PATH
"${PROJECT_SOURCE_DIR}/.."
)

# Utilities
include(set_utils)

include(ExternalProject)

option (VERBOSE "Print lots of messages while compiling" ON)
set (CMAKE_MESSAGE_LOG_LEVEL $<IF:$<BOOL:${VERBOSE}>,"VERBOSE","STATUS">
CACHE STRING "CMake log level to display")

set_cache (CMAKE_CXX_STANDARD 17 "C++ standard to use")
if (NOT CMAKE_BUILD_TYPE)
set (CMAKE_BUILD_TYPE "Release")
endif ()
message (STATUS "CMAKE_BUILD_TYPE = ${CMAKE_BUILD_TYPE}")
set_if_not (CMAKE_POSITION_INDEPENDENT_CODE ON)

if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set (CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/dist" CACHE PATH
"Installation location" FORCE)
endif()
message (STATUS "CMAKE_INSTALL_PREFIX = ${CMAKE_INSTALL_PREFIX}")

set (prefix_paths ${CMAKE_INSTALL_PREFIX} ${CMAKE_PREFIX_PATH})
set (BUILDER_COMMON_CMAKE_ARGS
-D CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-D CMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
-D CMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}
# -D CMAKE_MODULE_PATH=${CMAKE_MODULE_PATH}
-D CMAKE_IGNORE_PREFIX_PATH=${CMAKE_IGNORE_PREFIX_PATH}
-D CMAKE_FIND_FRAMEWORK=${CMAKE_FIND_FRAMEWORK}
-D CMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}
-D CMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
-D CMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-D CMAKE_POSITION_INDEPENDENT_CODE=${CMAKE_POSITION_INDEPENDENT_CODE}
-D CMAKE_COMPILE_WARNING_AS_ERROR=OFF
-D BUILD_SHARED_LIBS=${BUILD_SHARED_LIBS}
-D CMAKE_MSVC_RUNTIME_LIBRARY=${CMAKE_MSVC_RUNTIME_LIBRARY}
-D CMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE_MAKEFILE}
-D CMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}
-D CMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES}
)

set_option (BUILD_all "Build all dependencies unconditionally" OFF VERBOSE)

set (ALL_DEPS
ZLIB
Imath
OpenEXR
)

# set_cache (BUILD_Imath OFF "Build Imath library")
# if (BUILD_Imath OR BUILD_all)
# include (${PROJECT_SOURCE_DIR}/build_Imath.cmake)
# endif ()

foreach (dep IN LISTS ALL_DEPS)
set_cache (BUILD_${dep} ${BUILD_all} "Build ${dep} library" VERBOSE)
if (BUILD_${dep} OR BUILD_all)
include (${PROJECT_SOURCE_DIR}/build_${dep}.cmake)
set (${dep}_ROOT ${CMAKE_INSTALL_PREFIX})
message(STATUS "Set ${dep}_ROOT = ${${dep}_ROOT}")
endif ()
endforeach()
67 changes: 67 additions & 0 deletions src/cmake/dependencies/build_Imath.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Copyright Contributors to the OpenImageIO project.
# SPDX-License-Identifier: Apache-2.0
# https://github.com/AcademySoftwareFoundation/OpenImageIO


set_cache (Imath_BUILD_VERSION 3.1.10 "Imath version for local builds")
set_cache (Imath_GIT_REPOSITORY "https://github.com/AcademySoftwareFoundation/Imath" "Repo URL")
set_cache (Imath_GIT_TAG "v${Imath_BUILD_VERSION}" "Git tag to checkout")

set_if_not (LOCAL_BUILD_SHARED_LIBS_DEFAULT OFF)
set_cache (Imath_BUILD_SHARED_LIBS ${LOCAL_BUILD_SHARED_LIBS_DEFAULT}
DOC "Should a local Imath build, if necessary, build shared libraries" ADVANCED)
# string (MAKE_C_IDENTIFIER ${Imath_BUILD_VERSION} Imath_VERSION_IDENT)


ExternalProject_Add(Imath
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/Imath
GIT_REPOSITORY ${Imath_GIT_REPOSITORY}
GIT_TAG ${Imath_GIT_TAG}
CMAKE_ARGS
${BUILDER_COMMON_CMAKE_ARGS}
-D BUILD_SHARED_LIBS=${Imath_BUILD_SHARED_LIBS}
# Don't build unnecessary parts of Imath
-D BUILD_TESTING=OFF
-D IMATH_BUILD_EXAMPLES=OFF
-D IMATH_BUILD_PYTHON=OFF
-D IMATH_BUILD_TESTING=OFF
-D IMATH_BUILD_TOOLS=OFF
-D IMATH_INSTALL_DOCS=OFF
-D IMATH_INSTALL_PKG_CONFIG=OFF
-D IMATH_INSTALL_TOOLS=OFF
)


# string (MAKE_C_IDENTIFIER ${Imath_BUILD_VERSION} Imath_VERSION_IDENT)
#
# build_dependency_with_cmake(Imath
# VERSION ${Imath_BUILD_VERSION}
# GIT_REPOSITORY ${Imath_GIT_REPOSITORY}
# GIT_TAG ${Imath_GIT_TAG}
# CMAKE_ARGS
# -D BUILD_SHARED_LIBS=${Imath_BUILD_SHARED_LIBS}
# # Don't built unnecessary parts of Imath
# -D BUILD_TESTING=OFF
# -D IMATH_BUILD_EXAMPLES=OFF
# -D IMATH_BUILD_PYTHON=OFF
# -D IMATH_BUILD_TESTING=OFF
# -D IMATH_BUILD_TOOLS=OFF
# -D IMATH_INSTALL_DOCS=OFF
# -D IMATH_INSTALL_PKG_CONFIG=OFF
# -D IMATH_INSTALL_TOOLS=OFF
# # Give the library a custom name and symbol namespace so it can't
# # conflict with any others in the system or linked into the same app.
# # not needed -D IMATH_NAMESPACE_CUSTOM=1
# # not needed -D IMATH_INTERNAL_NAMESPACE=${PROJ_NAMESPACE_V}_Imath_${Imath_VERSION_IDENT}
# -D IMATH_LIB_SUFFIX=_v${Imath_VERSION_IDENT}_${PROJ_NAMESPACE_V}
# )
#
#
# # Signal to caller that we need to find again at the installed location
# set (Imath_REFIND TRUE)
# set (Imath_REFIND_ARGS CONFIG)
# set (Imath_REFIND_VERSION ${Imath_BUILD_VERSION})
#
# if (Imath_BUILD_SHARED_LIBS)
# install_local_dependency_libs (Imath Imath)
# endif ()
58 changes: 58 additions & 0 deletions src/cmake/dependencies/build_OpenEXR.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Copyright Contributors to the OpenImageIO project.
# SPDX-License-Identifier: Apache-2.0
# https://github.com/AcademySoftwareFoundation/OpenImageIO


set_cache (OpenEXR_BUILD_VERSION 3.2.4 "OpenEXR version for local builds")
set_cache (OpenEXR_GIT_REPOSITORY "https://github.com/AcademySoftwareFoundation/OpenEXR" "Repo URL")
set_cache (OpenEXR_GIT_TAG "v${OpenEXR_BUILD_VERSION}" "Git tag to checkout")

set_if_not (LOCAL_BUILD_SHARED_LIBS_DEFAULT OFF)
set_cache (OpenEXR_BUILD_SHARED_LIBS ${LOCAL_BUILD_SHARED_LIBS_DEFAULT}
DOC "Should a local OpenEXR build, if necessary, build shared libraries" ADVANCED)
# string (MAKE_C_IDENTIFIER ${OpenEXR_BUILD_VERSION} OpenEXR_VERSION_IDENT)


ExternalProject_Add(OpenEXR
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/OpenEXR
GIT_REPOSITORY ${OpenEXR_GIT_REPOSITORY}
GIT_TAG ${OpenEXR_GIT_TAG}
# DEPENDS Imath
CMAKE_ARGS
-D BUILD_SHARED_LIBS=${Imath_BUILD_SHARED_LIBS}
-D OPENEXR_FORCE_INTERNAL_DEFLATE=ON
# Don't built unnecessary parts of OpenEXR
-D BUILD_TESTING=OFF
-D BUILD_WEBSITE=OFF
-D OPENEXR_BUILD_EXAMPLES=OFF
-D OPENEXR_BUILD_PYTHON=OFF
-D OPENEXR_BUILD_SHARED_LIBS=OFF
-D OPENEXR_BUILD_TOOLS=OFF
-D OPENEXR_BUILD_WEBSITE=OFF
-D OPENEXR_INSTALL_DOCS=OFF
-D OPENEXR_INSTALL_PKG_CONFIG=OFF
-D OPENEXR_INSTALL_TOOLS=OFF
-D IMATH_ROOT=${Imath_ROOT}
${BUILDER_COMMON_CMAKE_ARGS}
# Give the library a custom name and symbol namespace so it can't
# conflict with any others in the system or linked into the same app.
# -D OPENEXR_NAMESPACE_CUSTOM=1
# -D ILMTHREAD_NAMESPACE_CUSTOM=1
# -D IEX_NAMESPACE_CUSTOM=1
# -D OPENEXR_INTERNAL_IMF_NAMESPACE=${PROJ_NAMESPACE_V}_Imf_${OpenEXR_VERSION_IDENT}
# -D ILMTHREAD_INTERNAL_NAMESPACE=${PROJ_NAMESPACE_V}_IlmThread_${OpenEXR_VERSION_IDENT}
# -D Iex_INTERNAL_NAMESPACE=${PROJ_NAMESPACE_V}_Iex_${OpenEXR_VERSION_IDENT}
# -D OPENEXR_LIB_SUFFIX=_v${OpenEXR_VERSION_IDENT}_${PROJ_NAMESPACE_V}
)


# # Signal to caller that we need to find again at the installed location
# set (OpenEXR_REFIND TRUE)
# set (OpenEXR_REFIND_ARGS CONFIG)
# set (OpenEXR_REFIND_VERSION ${OpenEXR_BUILD_VERSION})
#
# if (OpenEXR_BUILD_SHARED_LIBS)
# install_local_dependency_libs (OpenEXR OpenEXR)
# install_local_dependency_libs (OpenEXR IlmThread)
# install_local_dependency_libs (OpenEXR Iex)
# endif ()
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,22 @@
######################################################################

set_cache (ZLIB_BUILD_VERSION 1.3.1 "ZLIB version for local builds")
set (ZLIB_GIT_REPOSITORY "https://github.com/madler/zlib")
set (ZLIB_GIT_TAG "v${ZLIB_BUILD_VERSION}")
set_cache (ZLIB_GIT_REPOSITORY "https://github.com/madler/zlib" "Repo URL")
set_cache (ZLIB_GIT_TAG "v${ZLIB_BUILD_VERSION}" "Git tag to checkout")

set_if_not (LOCAL_BUILD_SHARED_LIBS_DEFAULT OFF)
set_cache (ZLIB_BUILD_SHARED_LIBS ${LOCAL_BUILD_SHARED_LIBS_DEFAULT}
DOC "Should execute a local ZLIB build, if necessary, build shared libraries" ADVANCED)

string (MAKE_C_IDENTIFIER ${ZLIB_BUILD_VERSION} ZLIB_VERSION_IDENT)
# string (MAKE_C_IDENTIFIER ${ZLIB_BUILD_VERSION} ZLIB_VERSION_IDENT)

build_dependency_with_cmake(ZLIB
VERSION ${ZLIB_BUILD_VERSION}
ExternalProject_Add(ZLIB
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/ZLIB
GIT_REPOSITORY ${ZLIB_GIT_REPOSITORY}
GIT_TAG ${ZLIB_GIT_TAG}
CMAKE_ARGS
${BUILDER_COMMON_CMAKE_ARGS}
-D BUILD_SHARED_LIBS=${ZLIB_BUILD_SHARED_LIBS}
-D CMAKE_POSITION_INDEPENDENT_CODE=ON
-D CMAKE_INSTALL_LIBDIR=lib
)

# Set some things up that we'll need for a subsequent find_package to work
set (ZLIB_ROOT ${ZLIB_LOCAL_INSTALL_DIR})

# Signal to caller that we need to find again at the installed location
set (ZLIB_REFIND TRUE)
set (ZLIB_VERSION ${ZLIB_BUILD_VERSION})
set (ZLIB_REFIND_VERSION ${ZLIB_BUILD_VERSION})

if (ZLIB_BUILD_SHARED_LIBS)
install_local_dependency_libs (ZLIB ZLIB)
endif ()
Loading

0 comments on commit aedeff3

Please sign in to comment.