From f9e45c711d0e1f99e9eae6bf74b30bb8bd6cf904 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9drik=20Fuoco?= <105517825+cedrik-fuoco-adsk@users.noreply.github.com> Date: Thu, 19 Sep 2024 08:39:32 -0400 Subject: [PATCH] Remove vcpkg.cmake and add expat.cmake for OCIO (Windows Only) (#577) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### Remove vcpkg.cmake and add expat.cmake for OCIO ### Linked issues n/a ### Summarize your change. Remove `vcpkg.cmake` and add an `expat.cmake` to build Expat for OCIO ### Describe the reason for the change. By adding `expat.cmake,` it respect the same build structure as the other dependencies. ### Describe what you have tested and on which operating system. Windows --------- Signed-off-by: Cédrik Fuoco --- cmake/dependencies/CMakeLists.txt | 2 +- cmake/dependencies/expat.cmake | 88 +++++++++++++++++++++++++++++++ cmake/dependencies/ocio.cmake | 37 +------------ 3 files changed, 91 insertions(+), 36 deletions(-) create mode 100644 cmake/dependencies/expat.cmake diff --git a/cmake/dependencies/CMakeLists.txt b/cmake/dependencies/CMakeLists.txt index 071e3f75..e0fd4fa7 100644 --- a/cmake/dependencies/CMakeLists.txt +++ b/cmake/dependencies/CMakeLists.txt @@ -43,7 +43,7 @@ IF(NOT EXISTS "${PROJECT_SOURCE_DIR}/src/pub/CMakeLists.txt") ENDIF() IF(RV_TARGET_WINDOWS) - INCLUDE(vcpkg) + INCLUDE(expat) ENDIF() INCLUDE(qt5) INCLUDE(openssl) # Python3 requirement diff --git a/cmake/dependencies/expat.cmake b/cmake/dependencies/expat.cmake new file mode 100644 index 00000000..ef677084 --- /dev/null +++ b/cmake/dependencies/expat.cmake @@ -0,0 +1,88 @@ +# +# Copyright (C) 2024 Autodesk, Inc. All Rights Reserved. +# +# SPDX-License-Identifier: Apache-2.0 +# + +# +# Official source repository https://github.com/libexpat/libexpat +# + +INCLUDE(ProcessorCount) # require CMake 3.15+ +PROCESSORCOUNT(_cpu_count) + +RV_CREATE_STANDARD_DEPS_VARIABLES("RV_DEPS_EXPAT" "2.6.3" "" "") +RV_SHOW_STANDARD_DEPS_VARIABLES() + + +string(REPLACE "." "_" _version_underscored ${_version}) +SET(_download_url + "https://github.com/libexpat/libexpat/archive/refs/tags/R_${_version_underscored}.tar.gz" +) + +SET(_download_hash + "985086e206a01e652ca460eb069e4780" +) + +SET(_libexpat_lib_version + "2.6.3" +) + +RV_MAKE_STANDARD_LIB_NAME("libexpat" "" "SHARED" "d") + +# Remove the -S argument from _configure_options, and adjust the path for Expat. +list(REMOVE_ITEM _configure_options "-S ${_source_dir}") +# Expat source is under expat folder and not directly under repository root. +LIST(APPEND _configure_options "-S ${_source_dir}/expat") + +LIST(APPEND _configure_options "-DEXPAT_BUILD_DOCS=OFF") +LIST(APPEND _configure_options "-DEXPAT_BUILD_EXAMPLES=OFF") +LIST(APPEND _configure_options "-DEXPAT_BUILD_TESTS=OFF") +LIST(APPEND _configure_options "-DEXPAT_BUILD_TOOLS=OFF") + +EXTERNALPROJECT_ADD( + ${_target} + URL ${_download_url} + URL_MD5 ${_download_hash} + DOWNLOAD_NAME ${_target}_${_version}.tar.gz + DOWNLOAD_DIR ${RV_DEPS_DOWNLOAD_DIR} + DOWNLOAD_EXTRACT_TIMESTAMP TRUE + SOURCE_DIR ${_source_dir} + BINARY_DIR ${_build_dir} + INSTALL_DIR ${_install_dir} + CONFIGURE_COMMAND ${CMAKE_COMMAND} ${_configure_options} + BUILD_COMMAND ${_cmake_build_command} + INSTALL_COMMAND ${_cmake_install_command} + BUILD_IN_SOURCE FALSE + BUILD_ALWAYS FALSE + BUILD_BYPRODUCTS ${_byproducts} + USES_TERMINAL_BUILD TRUE +) + +RV_COPY_LIB_BIN_FOLDERS() + +ADD_DEPENDENCIES(dependencies ${_target}-stage-target) + +ADD_LIBRARY(EXPAT::EXPAT SHARED IMPORTED GLOBAL) +ADD_DEPENDENCIES(EXPAT::EXPAT ${_target}) + +# An import library (.lib) file is often used to resolve references to +# functions and variables in a DLL, enabling the linker to generate code +# for loading the DLL and calling its functions at runtime. +SET_PROPERTY( + TARGET EXPAT::EXPAT + PROPERTY IMPORTED_LOCATION "${_libpath}" +) +SET_PROPERTY( + TARGET EXPAT::EXPAT + PROPERTY IMPORTED_IMPLIB "${_implibpath}" +) + +# It is required to force directory creation at configure time otherwise CMake complains about importing a non-existing path +FILE(MAKE_DIRECTORY "${_include_dir}") +TARGET_INCLUDE_DIRECTORIES( + EXPAT::EXPAT + INTERFACE ${_include_dir} +) + +LIST(APPEND RV_DEPS_LIST EXPAT::EXPAT) \ No newline at end of file diff --git a/cmake/dependencies/ocio.cmake b/cmake/dependencies/ocio.cmake index 75f1aab9..62ed6cd0 100644 --- a/cmake/dependencies/ocio.cmake +++ b/cmake/dependencies/ocio.cmake @@ -189,9 +189,6 @@ ELSE() # Windows FILE(REMOVE ${_backup_pyopencolorio_cmakelists_path}) ENDIF() - GET_TARGET_PROPERTY(_vcpkg_location VCPKG::VCPKG IMPORTED_LOCATION) - GET_FILENAME_COMPONENT(_vcpkg_path ${_vcpkg_location} DIRECTORY) - # Some options are not multi-platform so we start clean. SET(_configure_options "" @@ -215,8 +212,7 @@ ELSE() # Windows "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}" "-DZLIB_LIBRARY=${_zlib_library}" "-DZLIB_INCLUDE_DIR=${_zlib_include_dir}" - # Using the expat build with /MD to match the CRT. - "-Dexpat_DIR=${_vcpkg_path}/packages/expat_x64-windows-static-md/share/expat" + "-Dexpat_ROOT=${RV_DEPS_EXPAT_ROOT_DIR}" "-DImath_DIR=${RV_DEPS_IMATH_ROOT_DIR}/lib/cmake/Imath" "-DPython_ROOT=${RV_DEPS_BASE_DIR}/RV_DEPS_PYTHON3/install" # Mandatory param: OCIO CMake code finds Python. @@ -264,7 +260,7 @@ ELSE() # Windows SOURCE_DIR ${_source_dir} BINARY_DIR ${_build_dir} INSTALL_DIR ${_install_dir} - DEPENDS Boost::headers RV_DEPS_PYTHON3 Imath::Imath VCPKG::VCPKG ZLIB::ZLIB + DEPENDS Boost::headers RV_DEPS_PYTHON3 Imath::Imath ZLIB::ZLIB EXPAT::EXPAT PATCH_COMMAND python3 ${_pyopencolorio_patch_script_path} ${_pyopencolorio_cmakelists_path} CONFIGURE_COMMAND ${CMAKE_COMMAND} ${_configure_options} @@ -275,35 +271,6 @@ ELSE() # Windows BUILD_BYPRODUCTS ${_byproducts} USES_TERMINAL_BUILD TRUE ) - - # To update the baseline property in the OCIO VCPKG JSON: - # See https://learn.microsoft.com/en-us/vcpkg/users/versioning#baselines - # vcpkg x-update-baseline - # Caveat: the file must be called vcpkg.json to work. - # Workaround: change ocio_vcpkg.json to vcpkg.json, update the baseline, and rename it back. - SET(_vcpkg_manifest - "${RV_PKGMANCONFIG_DIR}/ocio_vcpkg.json" - ) - EXTERNALPROJECT_ADD_STEP( - ${_target} add_vcpkg_manifest - COMMENT "Copying the VCPKG manifest" - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${_vcpkg_manifest} "${_source_dir}/vcpkg.json" - DEPENDERS configure - ) - - EXTERNALPROJECT_ADD_STEP( - ${_target} install_vcpkg_manifest - COMMENT "Installing OCIO dependencies via VCPKG" - # IMPORTANT: VCPKG Manifest mode (using a .json) does not support differents triplets per dependencies. - # This is not a problem right now because only expat is installed with vcpkg. - # Expat is installed with vcpkg because there's an expat library that comes with MSYS2 on Windows, - # and it is causing compiler error. - # OCIO installs the remaining dependencies (yaml-cpp, pystring, pybind11 and minizip-ng). - COMMAND ${_vcpkg_location} install --triplet x64-windows-static-md - DEPENDEES add_vcpkg_manifest - DEPENDERS configure - WORKING_DIRECTORY "${_source_dir}" - ) ENDIF() SET(_ocio_stage_plugins_python_dir "${RV_STAGE_PLUGINS_PYTHON_DIR}")