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
14 changes: 9 additions & 5 deletions src/build-scripts/gh-win-installdeps.bash
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,18 @@ export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$DEP_DIR/bin:$VCPKG_INSTALLATION_ROOT/i
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$DEP_DIR/lib:$VCPKG_INSTALLATION_ROOT/installed/x64-windows-release/lib"


if [[ "$PYTHON_VERSION" == "3.7" ]] ; then
export CMAKE_PREFIX_PATH="$CMAKE_PREFIX_PATH;/c/hostedtoolcache/windows/Python/3.7.9/x64"
export Python_EXECUTABLE="/c/hostedtoolcache/windows/Python/3.7.9/x64/python.exe"
export PYTHONPATH=$OpenImageIO_ROOT/lib/python${PYTHON_VERSION}/site-packages
elif [[ "$PYTHON_VERSION" == "3.9" ]] ; then
if [[ "$PYTHON_VERSION" == "3.9" ]] ; then
export CMAKE_PREFIX_PATH="$CMAKE_PREFIX_PATH;/c/hostedtoolcache/windows/Python/3.9.13/x64"
export Python_EXECUTABLE="/c/hostedtoolcache/windows/Python/3.9.13/x64/python3.exe"
export PYTHONPATH=$OpenImageIO_ROOT/lib/python${PYTHON_VERSION}/site-packages
elif [[ "$PYTHON_VERSION" == "3.12" ]] ; then
export CMAKE_PREFIX_PATH="$CMAKE_PREFIX_PATH;/c/hostedtoolcache/windows/Python/3.12.10/x64"
export Python_EXECUTABLE="/c/hostedtoolcache/windows/Python/3.12.10/x64/python3.exe"
export PYTHONPATH=$OpenImageIO_ROOT/lib/python${PYTHON_VERSION}/site-packages
elif [[ "$PYTHON_VERSION" == "3.14" ]] ; then
export CMAKE_PREFIX_PATH="$CMAKE_PREFIX_PATH;/c/hostedtoolcache/windows/Python/3.14.3/x64"
export Python_EXECUTABLE="/c/hostedtoolcache/windows/Python/3.14.3/x64/python3.exe"
export PYTHONPATH=$OpenImageIO_ROOT/lib/python${PYTHON_VERSION}/site-packages
fi
pip install numpy

Expand Down
117 changes: 87 additions & 30 deletions src/cmake/compiler.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ message (VERBOSE "CMAKE_SYSTEM_VERSION = ${CMAKE_SYSTEM_VERSION}")
message (VERBOSE "CMAKE_SYSTEM_PROCESSOR = ${CMAKE_SYSTEM_PROCESSOR}")
message (STATUS "CMAKE_CXX_COMPILER = ${CMAKE_CXX_COMPILER}")
message (STATUS "CMAKE_CXX_COMPILER_ID = ${CMAKE_CXX_COMPILER_ID}")
message (VERBOSE "CMAKE_CXX_COMPILE_FEATURES = ${CMAKE_CXX_COMPILE_FEATURES}")


###########################################################################
Expand Down Expand Up @@ -72,6 +73,8 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER MATCHES "[Cc]lan
message (VERBOSE "The compiler is Clang: ${CMAKE_CXX_COMPILER_ID} version ${APPLECLANG_VERSION_STRING}")
if (APPLECLANG_VERSION_STRING VERSION_LESS 5.0)
message (ERROR "Apple clang minimum version is 5.0")
elseif (APPLECLANG_VERSION_STRING VERSION_LESS 10.0)
message (WARNING "Apple clang minimum version is 10.0. Older versions might work, but we don't test or support them.")
endif ()
elseif (CMAKE_CXX_COMPILER_ID MATCHES "IntelLLVM")
set (CMAKE_COMPILER_IS_INTELCLANG 1)
Expand All @@ -85,12 +88,17 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER MATCHES "[Cc]lan
message (VERBOSE "The compiler is Clang: ${CMAKE_CXX_COMPILER_ID} version ${CLANG_VERSION_STRING}")
if (CLANG_VERSION_STRING VERSION_LESS 5.0)
message (ERROR "clang minimum version is 5.0")
elseif (CLANG_VERSION_STRING VERSION_LESS 10.0)
message (WARNING "clang minimum version is 10.0. Older versions might work, but we don't test or support them.")
endif ()
endif ()
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Intel")
set (CMAKE_COMPILER_IS_INTEL 1)
message (VERBOSE "Using Intel as the compiler")
endif ()
if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG)
set (COMPILER_IS_GCC_OR_ANY_CLANG TRUE)
endif ()


###########################################################################
Expand All @@ -107,12 +115,12 @@ else ()
endif()
option (EXTRA_WARNINGS "Enable lots of extra pedantic warnings" OFF)
if (NOT MSVC)
add_compile_options ("-Wall")
add_compile_options (-Wall)
if (EXTRA_WARNINGS)
add_compile_options ("-Wextra")
add_compile_options (-Wextra)
endif ()
if (STOP_ON_WARNING)
add_compile_options ("-Werror")
add_compile_options (-Werror)
endif ()
endif ()

Expand Down Expand Up @@ -232,18 +240,31 @@ endif ()
# logic here makes it work even if the user is unaware of ccache. If it's
# not found on the system, it will simply be silently not used.
option (USE_CCACHE "Use ccache if found" ON)
find_program (CCACHE_EXE ccache)
if (CCACHE_EXE AND USE_CCACHE)
if (CMAKE_COMPILER_IS_CLANG AND USE_QT AND (NOT DEFINED ENV{CCACHE_CPP2}))
message (STATUS "Ignoring ccache because clang + Qt + env CCACHE_CPP2 is not set")
else ()
if (NOT ${CXX_COMPILER_LAUNCHER} MATCHES "ccache")
set (CXX_COMPILER_LAUNCHER ${CCACHE_EXR} ${CXX_COMPILER_LAUNCHER})
endif ()
if (NOT ${C_COMPILER_LAUNCHER} MATCHES "ccache")
set (C_COMPILER_LAUNCHER ${CCACHE_EXR} ${C_COMPILER_LAUNCHER})
if (USE_CCACHE)
find_program (CCACHE_EXE ccache
PATHS "${PROJECT_SOURCE_DIR}/ext/dist/"
"${PROJECT_SOURCE_DIR}/ext/dist/bin")
if (CCACHE_EXE)
if (CMAKE_COMPILER_IS_CLANG AND USE_QT AND (NOT DEFINED ENV{CCACHE_CPP2}))
message (STATUS "Ignoring ccache because clang + Qt + env CCACHE_CPP2 is not set")
else ()
message (STATUS "CMAKE_CXX_COMPILER_LAUNCHER: ${CMAKE_CXX_COMPILER_LAUNCHER}")

if (NOT CMAKE_CXX_COMPILER_LAUNCHER MATCHES "ccache")
set (CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE_EXE})
message (STATUS "first if CMAKE_CXX_COMPILER_LAUNCHER: ${CMAKE_CXX_COMPILER_LAUNCHER}")
else ()
message (STATUS "first else CMAKE_CXX_COMPILER_LAUNCHER: '${CMAKE_CXX_COMPILER_LAUNCHER}'")
endif ()
if (NOT CMAKE_C_COMPILER_LAUNCHER MATCHES "ccache")
set (CMAKE_C_COMPILER_LAUNCHER ${CCACHE_EXE})
endif ()
message (STATUS "ccache enabled: ${CCACHE_EXE}")
message (STATUS "CCACHE_DIR env: $ENV{CCACHE_DIR}")
message (STATUS "CMAKE_CXX_COMPILER_LAUNCHER: ${CMAKE_CXX_COMPILER_LAUNCHER}")
endif ()
message (STATUS "ccache enabled: ${CCACHE_EXE}")
else ()
message (STATUS "ccache not found")
endif ()
endif ()

Expand All @@ -256,8 +277,8 @@ endif ()
# set `-j 1` or CMAKE_BUILD_PARALLEL_LEVEL to 1.
option (TIME_COMMANDS "Time each compile and link command" OFF)
if (TIME_COMMANDS)
set (CXX_COMPILER_LAUNCHER ${CMAKE_COMMAND} -E time ${CXX_COMPILER_LAUNCHER})
set (C_COMPILER_LAUNCHER ${CMAKE_COMMAND} -E time ${C_COMPILER_LAUNCHER})
set (CMAKE_CXX_COMPILER_LAUNCHER ${CMAKE_COMMAND} -E time ${CMAKE_CXX_COMPILER_LAUNCHER})
set (CMAKE_C_COMPILER_LAUNCHER ${CMAKE_COMMAND} -E time ${CMAKE_C_COMPILER_LAUNCHER})
endif ()


Expand Down Expand Up @@ -296,20 +317,38 @@ endif ()
# the proper compiler directives added to generate code for those ISA
# capabilities.
#
set (USE_SIMD "" CACHE STRING "Use SIMD directives (0, sse2, sse3, ssse3, sse4.1, sse4.2, avx, avx2, avx512f, f16c, aes)")
set_cache (USE_SIMD "" "Use SIMD directives (0, sse2, sse3, ssse3, sse4.1, sse4.2, avx, avx2, avx512f, f16c, aes)")
set (SIMD_COMPILE_FLAGS "")
message (STATUS "Compiling with SIMD level ${USE_SIMD}")
if (NOT USE_SIMD STREQUAL "")
message (STATUS "Compiling with SIMD level ${USE_SIMD}")
if (USE_SIMD STREQUAL "0")
set (SIMD_COMPILE_FLAGS ${SIMD_COMPILE_FLAGS} "-DOIIO_NO_SSE=1")
set (SIMD_COMPILE_FLAGS ${SIMD_COMPILE_FLAGS} "-DOIIO_NO_SIMD=1")
else ()
string (REPLACE "," ";" SIMD_FEATURE_LIST ${USE_SIMD})
set(_highest_msvc_arch 0)
string (REPLACE "," ";" SIMD_FEATURE_LIST "${USE_SIMD}")
foreach (feature ${SIMD_FEATURE_LIST})
message (VERBOSE "SIMD feature: ${feature}")
if (MSVC OR CMAKE_COMPILER_IS_INTEL)
set (SIMD_COMPILE_FLAGS ${SIMD_COMPILE_FLAGS} "/arch:${feature}")
if (feature STREQUAL "sse2")
list (APPEND SIMD_COMPILE_FLAGS "/D__SSE2__")
endif ()
if (feature STREQUAL "sse4.1")
list (APPEND SIMD_COMPILE_FLAGS "/D__SSE2__" "/D__SSE4_1__")
endif ()
if (feature STREQUAL "sse4.2")
list (APPEND SIMD_COMPILE_FLAGS "/D__SSE2__" "/D__SSE4_2__")
endif ()
if (feature STREQUAL "avx" AND _highest_msvc_arch LESS 1)
set(_highest_msvc_arch 1)
endif ()
if (feature STREQUAL "avx2" AND _highest_msvc_arch LESS 2)
set(_highest_msvc_arch 2)
endif ()
if (feature STREQUAL "avx512f" AND _highest_msvc_arch LESS 3)
set(_highest_msvc_arch 3)
endif ()
else ()
set (SIMD_COMPILE_FLAGS ${SIMD_COMPILE_FLAGS} "-m${feature}")
list (APPEND SIMD_COMPILE_FLAGS "-m${feature}")
endif ()
if (feature STREQUAL "fma" AND (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG))
# If fma is requested, for numerical accuracy sake, turn it
Expand All @@ -319,10 +358,25 @@ if (NOT USE_SIMD STREQUAL "")
add_compile_options ("-ffp-contract=off")
endif ()
endforeach()

# Only add a single /arch flag representing the highest level of support.
if (MSVC OR CMAKE_COMPILER_IS_INTEL)
if (_highest_msvc_arch EQUAL 1)
list (APPEND SIMD_COMPILE_FLAGS "/arch:AVX")
endif ()
if (_highest_msvc_arch EQUAL 2)
list (APPEND SIMD_COMPILE_FLAGS "/arch:AVX2")
endif ()
if (_highest_msvc_arch EQUAL 3)
list (APPEND SIMD_COMPILE_FLAGS "/arch:AVX512")
endif ()
endif ()
unset(_highest_msvc_arch)
endif ()
add_compile_options (${SIMD_COMPILE_FLAGS})
endif ()


###########################################################################
# Batched SIMD shader execution options.
#
Expand Down Expand Up @@ -395,7 +449,7 @@ endif ()
###########################################################################
# Sanitizer options
#
set (SANITIZE "" CACHE STRING "Build code using sanitizer (address, thread)")
set_cache (SANITIZE "" "Build code using sanitizer (address, thread, undefined)")
if (SANITIZE AND (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG))
message (STATUS "Compiling for sanitizer=${SANITIZE}")
string (REPLACE "," ";" SANITIZE_FEATURE_LIST ${SANITIZE})
Expand Down Expand Up @@ -433,9 +487,7 @@ if (CLANG_TIDY)
DOC "Path to clang-tidy executable")
message (STATUS "CLANG_TIDY_EXE ${CLANG_TIDY_EXE}")
if (CLANG_TIDY_EXE)
set (CMAKE_CXX_CLANG_TIDY
"${CLANG_TIDY_EXE}"
)
set (CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_EXE}")
if (CLANG_TIDY_ARGS)
list (APPEND CMAKE_CXX_CLANG_TIDY ${CLANG_TIDY_ARGS})
endif ()
Expand Down Expand Up @@ -511,21 +563,21 @@ endif ()
set (EXTRA_CPP_ARGS "" CACHE STRING "Extra C++ command line definitions")
if (EXTRA_CPP_ARGS)
message (STATUS "Extra C++ args: ${EXTRA_CPP_ARGS}")
add_compile_options ("${EXTRA_CPP_ARGS}")
add_compile_options (${EXTRA_CPP_ARGS})
endif()
set (EXTRA_DSO_LINK_ARGS "" CACHE STRING "Extra command line definitions when building DSOs")


###########################################################################
# Set the versioning for shared libraries.
#
if (${PROJECT_NAME}_SUPPORTED_RELEASE)
if (${PROJECT_NAME}_SUPPORTED_RELEASE AND NOT SKBUILD)
# Supported releases guarantee ABI back-compatibility within the release
# family, so SO versioning is major.minor.
set (SOVERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
CACHE STRING "Set the SO version for dynamic libraries")
else ()
# Development master makes no ABI stability guarantee, so we make the
# Main development branch makes no ABI stability guarantee, so we make the
# SO naming capture down to the major.minor.patch level.
set (SOVERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}
CACHE STRING "Set the SO version for dynamic libraries")
Expand All @@ -537,7 +589,7 @@ message(VERBOSE "Setting SOVERSION to: ${SOVERSION}")
# BUILD_SHARED_LIBS, if turned off, will disable building of .so/.dll
# dynamic libraries and instead only build static libraries.
#
option (BUILD_SHARED_LIBS "Build shared libraries (set to OFF to build static libs)" ON)
set_option (BUILD_SHARED_LIBS "Build shared libraries (set to OFF to build static libs)" ON)
if (NOT BUILD_SHARED_LIBS)
add_compile_definitions (${PROJECT_NAME}_STATIC_DEFINE=1)
endif ()
Expand Down Expand Up @@ -601,6 +653,11 @@ set (CMAKE_SKIP_BUILD_RPATH FALSE)
set (CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)


###########################################################################
# Generate compile_commands.json for use by editors and tools.
set (CMAKE_EXPORT_COMPILE_COMMANDS ON)


###########################################################################
# Macro to install targets to the appropriate locations. Use this instead
# of the install(TARGETS ...) signature. Note that it adds it to the
Expand Down
Loading
Loading