Skip to content

Commit 67b59a7

Browse files
ci: Staging refactor (AcademySoftwareFoundation#1159)
### ci: Staging refactor ### Linked issues none ### Summarize your change. Refactor the CMake dependency build system to eliminate repeated boilerplate by introducing two new reusable macros (`RV_STAGE_DEPENDENCY_LIBS` and `RV_ADD_IMPORTED_LIBRARY`) and applying them across all dependency files. Also aligns imported target names with upstream find_package conventions and fixes several latent bugs. There is a lot of changes in the dependencies, but the majority is removing the code that is handled by the new macro. - `RV_STAGE_DEPENDENCY_LIBS` macro: New macro that replaces ad-hoc staging patterns. - `RV_ADD_IMPORTED_LIBRARY` macro: New macro that consolidates the ADD_LIBRARY(IMPORTED) + SET_PROPERTY + TARGET_INCLUDE_DIRECTORIES pattern. - Removed rv_copy_lib_bin_folders.cmake: Superseded by RV_STAGE_DEPENDENCY_LIBS. - Centralized ProcessorCount in cmake/dependencies/CMakeLists.txt instead of per-dependency. - Removed redundant variable declarations that are already provided by RV_CREATE_STANDARD_DEPS_VARIABLES - AJA build fix: Sets -DNTV2_VERSION_BUILD=0 to prevent Jenkins build numbers from leaking into AJA library sonames. - Aligned imported target names with upstream Full list of renames: - jpeg-turbo::jpeg → libjpeg-turbo::jpeg - Tiff::Tiff → TIFF::TIFF - oiio::oiio → OpenImageIO::OpenImageIO (and oiio::oiio_util → OpenImageIO::OpenImageIO_Util) - ocio::ocio → OpenColorIO::OpenColorIO - Raw::Raw → LibRaw::raw - Webp::Webp → WebP::webp - doctest → doctest::doctest ### Describe the reason for the change. The dependency CMake files contained large amounts of duplicated code for staging libraries, creating imported targets, and setting standard variables. Each dependency re-implemented the same patterns with minor variations, making the build system harder to maintain and a source of subtle inconsistencies (e.g., some deps used POST_BUILD while others used OUTPUT-based commands). ### Describe what you have tested and on which operating system. I have tested in CI and MacOS. I will be comparing the installed files between the main branch and this branch. --------- Signed-off-by: Roger Nelson <roger.nelson@autodesk.com> Signed-off-by: Cédrik Fuoco <cedrik.fuoco@autodesk.com> Signed-off-by: Cédrik Fuoco <105517825+cedrik-fuoco-adsk@users.noreply.github.com> Co-authored-by: Roger Nelson <roger.nelson@autodesk.com>
1 parent 45417a5 commit 67b59a7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+851
-1162
lines changed

cmake/dependencies/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@
66

77
INCLUDE(rv_create_std_deps_vars)
88
INCLUDE(rv_make_std_lib_name)
9-
INCLUDE(rv_copy_lib_bin_folders)
9+
INCLUDE(rv_stage_dependency_libs)
10+
INCLUDE(rv_add_imported_library)
11+
12+
INCLUDE(ProcessorCount)
13+
PROCESSORCOUNT(_cpu_count)
1014

1115
IF(NOT TARGET dependencies)
1216
ADD_CUSTOM_TARGET(dependencies)

cmake/dependencies/aja.cmake

Lines changed: 27 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
# SPDX-License-Identifier: Apache-2.0
55
#
66

7-
INCLUDE(ProcessorCount) # require CMake 3.15+
8-
PROCESSORCOUNT(_cpu_count)
9-
107
RV_CREATE_STANDARD_DEPS_VARIABLES("RV_DEPS_AJA" "${RV_DEPS_AJA_VERSION}" "make" "")
118
RV_SHOW_STANDARD_DEPS_VARIABLES()
129

@@ -71,7 +68,15 @@ ELSEIF(RV_TARGET_WINDOWS)
7168
)
7269
ENDIF()
7370

74-
LIST(APPEND _configure_options "-DAJANTV2_DISABLE_DEMOS=ON" "-DAJANTV2_DISABLE_TOOLS=ON" "-DAJANTV2_DISABLE_TESTS=ON" "-DAJANTV2_BUILD_SHARED=ON")
71+
LIST(
72+
APPEND
73+
_configure_options
74+
"-DAJANTV2_DISABLE_DEMOS=ON"
75+
"-DAJANTV2_DISABLE_TOOLS=ON"
76+
"-DAJANTV2_DISABLE_TESTS=ON"
77+
"-DAJANTV2_BUILD_SHARED=ON"
78+
"-DNTV2_VERSION_BUILD=0"
79+
)
7580

7681
# In Debug, the MSVC runtime library needs to be set to MultiThreadedDebug. Otherwise, it will be set to MultiThreaded.
7782
IF(RV_TARGET_WINDOWS
@@ -99,29 +104,26 @@ EXTERNALPROJECT_ADD(
99104
USES_TERMINAL_BUILD TRUE
100105
)
101106

102-
RV_COPY_LIB_BIN_FOLDERS()
103-
104-
ADD_LIBRARY(aja::ntv2 SHARED IMPORTED GLOBAL)
105-
ADD_DEPENDENCIES(aja::ntv2 ${_target})
106-
SET_PROPERTY(
107-
TARGET aja::ntv2
108-
PROPERTY IMPORTED_LOCATION ${_libpath}
109-
)
110-
SET_PROPERTY(
111-
TARGET aja::ntv2
112-
PROPERTY IMPORTED_SONAME ${_libname}
113-
)
114-
IF(RV_TARGET_WINDOWS)
115-
SET_PROPERTY(
116-
TARGET aja::ntv2
117-
PROPERTY IMPORTED_IMPLIB ${_implibpath}
118-
)
119-
ENDIF()
107+
RV_STAGE_DEPENDENCY_LIBS(TARGET ${_target} LIBNAME ${_libname})
120108

121-
FILE(MAKE_DIRECTORY ${_aja_include_dir} ${_aja_ntv2_include_dir} ${_aja_ntv2_os_specific_include_dir})
122-
TARGET_INCLUDE_DIRECTORIES(
109+
RV_ADD_IMPORTED_LIBRARY(
110+
NAME
123111
aja::ntv2
124-
INTERFACE ${_aja_include_dir} ${_aja_ntv2_include_dir} ${_aja_ntv2_os_specific_include_dir}
112+
TYPE
113+
SHARED
114+
LOCATION
115+
${_libpath}
116+
SONAME
117+
${_libname}
118+
IMPLIB
119+
${_implibpath}
120+
INCLUDE_DIRS
121+
${_aja_include_dir}
122+
${_aja_ntv2_include_dir}
123+
${_aja_ntv2_os_specific_include_dir}
124+
DEPENDS
125+
${_target}
126+
ADD_TO_DEPS_LIST
125127
)
126128

127129
TARGET_LINK_LIBRARIES(
@@ -143,12 +145,3 @@ SET(RV_DEPS_AJA_COMPILE_OPTIONS
143145
${_aja_compile_options}
144146
CACHE INTERNAL "" FORCE
145147
)
146-
147-
LIST(APPEND RV_DEPS_LIST aja::ntv2)
148-
149-
ADD_DEPENDENCIES(dependencies ${_target}-stage-target)
150-
151-
SET(RV_DEPS_AJA_VERSION
152-
${_version}
153-
CACHE INTERNAL "" FORCE
154-
)

cmake/dependencies/atomic_ops.cmake

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
# SPDX-License-Identifier: Apache-2.0
55
#
66

7-
INCLUDE(ProcessorCount) # require CMake 3.15+
8-
PROCESSORCOUNT(_cpu_count)
9-
107
SET(_target
118
"RV_DEPS_ATOMIC_OPS"
129
)
@@ -79,36 +76,25 @@ EXTERNALPROJECT_ADD(
7976
USES_TERMINAL_BUILD TRUE
8077
)
8178

82-
ADD_LIBRARY(atomic_ops::atomic_ops STATIC IMPORTED GLOBAL)
83-
ADD_DEPENDENCIES(atomic_ops::atomic_ops ${_target})
84-
SET_PROPERTY(
85-
TARGET atomic_ops::atomic_ops
86-
PROPERTY IMPORTED_LOCATION ${_atomic_ops_lib}
87-
)
88-
8979
SET(_include_dir
9080
${_install_dir}/include
9181
)
92-
FILE(MAKE_DIRECTORY ${_include_dir})
93-
TARGET_INCLUDE_DIRECTORIES(
94-
atomic_ops::atomic_ops
95-
INTERFACE ${_include_dir}
96-
)
97-
LIST(APPEND RV_DEPS_LIST atomic_ops::atomic_ops)
9882

99-
ADD_CUSTOM_COMMAND(
100-
COMMENT "Installing ${_target}'s libs into ${RV_STAGE_LIB_DIR}"
101-
OUTPUT ${RV_STAGE_LIB_DIR}/${_atomic_ops_lib_name}
102-
COMMAND ${CMAKE_COMMAND} -E copy_directory ${_lib_dir} ${RV_STAGE_LIB_DIR}
103-
DEPENDS ${_target}
104-
)
105-
106-
ADD_CUSTOM_TARGET(
107-
${_target}-stage-target ALL
108-
DEPENDS ${RV_STAGE_LIB_DIR}/${_atomic_ops_lib_name}
83+
RV_ADD_IMPORTED_LIBRARY(
84+
NAME
85+
atomic_ops::atomic_ops
86+
TYPE
87+
STATIC
88+
LOCATION
89+
${_atomic_ops_lib}
90+
INCLUDE_DIRS
91+
${_include_dir}
92+
DEPENDS
93+
${_target}
94+
ADD_TO_DEPS_LIST
10995
)
11096

111-
ADD_DEPENDENCIES(dependencies ${_target}-stage-target)
97+
RV_STAGE_DEPENDENCY_LIBS(TARGET ${_target} OUTPUTS ${RV_STAGE_LIB_DIR}/${_atomic_ops_lib_name})
11298

11399
SET(RV_DEPS_ATOMIC_OPS_VERSION
114100
${_version}

cmake/dependencies/bmd.cmake

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
# SPDX-License-Identifier: Apache-2.0
55
#
66

7-
INCLUDE(ProcessorCount) # require CMake 3.15+
8-
PROCESSORCOUNT(_cpu_count)
9-
107
SET(_target
118
"RV_DEPS_BMD"
129
)

cmake/dependencies/boost.cmake

Lines changed: 3 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99
#
1010
# Starting from CMake 3.30, FindBoost.cmake has been removed in favor of BoostConfig.cmake (Boost 1.70+). This behavior is covered by CMake policy CMP0167.
1111

12-
INCLUDE(ProcessorCount) # require CMake 3.15+
13-
PROCESSORCOUNT(_cpu_count)
14-
1512
SET(_ext_boost_version
1613
${RV_DEPS_BOOST_VERSION}
1714
)
@@ -30,19 +27,6 @@ SET(_download_url
3027
"https://archives.boost.io/release/${_version}/source/boost_${_version_with_underscore}.tar.gz"
3128
)
3229

33-
# Set _base_dir for Clean-<target>
34-
SET(_base_dir
35-
${RV_DEPS_BASE_DIR}/${_target}
36-
)
37-
38-
SET(_install_dir
39-
${RV_DEPS_BASE_DIR}/${_target}/install
40-
)
41-
42-
SET(${_target}_ROOT_DIR
43-
${_install_dir}
44-
)
45-
4630
SET(_boost_libs
4731
atomic
4832
chrono
@@ -255,31 +239,9 @@ SET_TARGET_PROPERTIES(
255239
PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${_include_dir}"
256240
)
257241

242+
# Note: On Windows, Boost's b2 puts both .lib and .dll in lib/, so we copy _lib_dir to both RV_STAGE_LIB_DIR and RV_STAGE_BIN_DIR.
258243
IF(RV_TARGET_WINDOWS)
259-
ADD_CUSTOM_COMMAND(
260-
TARGET ${_target}
261-
POST_BUILD
262-
COMMENT "Installing ${_target}'s libs and bin into ${RV_STAGE_LIB_DIR} and ${RV_STAGE_BIN_DIR}"
263-
COMMAND ${CMAKE_COMMAND} -E copy_directory ${_lib_dir} ${RV_STAGE_LIB_DIR}
264-
COMMAND ${CMAKE_COMMAND} -E copy_directory ${_lib_dir} ${RV_STAGE_BIN_DIR}
265-
)
244+
RV_STAGE_DEPENDENCY_LIBS(TARGET ${_target} EXTRA_LIB_DIRS ${RV_STAGE_BIN_DIR} OUTPUTS ${_boost_stage_output})
266245
ELSE()
267-
ADD_CUSTOM_COMMAND(
268-
COMMENT "Installing ${_target}'s libs into ${RV_STAGE_LIB_DIR}"
269-
OUTPUT ${_boost_stage_output}
270-
COMMAND ${CMAKE_COMMAND} -E copy_directory ${_lib_dir} ${RV_STAGE_LIB_DIR}
271-
DEPENDS ${_target}
272-
)
246+
RV_STAGE_DEPENDENCY_LIBS(TARGET ${_target} OUTPUTS ${_boost_stage_output})
273247
ENDIF()
274-
275-
ADD_CUSTOM_TARGET(
276-
${_target}-stage-target ALL
277-
DEPENDS ${_boost_stage_output}
278-
)
279-
280-
ADD_DEPENDENCIES(dependencies ${_target}-stage-target)
281-
282-
SET(RV_DEPS_BOOST_VERSION
283-
${_version}
284-
CACHE INTERNAL "" FORCE
285-
)

cmake/dependencies/dav1d.cmake

Lines changed: 17 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,8 @@
44
# SPDX-License-Identifier: Apache-2.0
55
#
66

7-
INCLUDE(ProcessorCount) # require CMake 3.15+
8-
PROCESSORCOUNT(_cpu_count)
9-
10-
SET(_target
11-
"RV_DEPS_DAV1D"
12-
)
13-
14-
SET(_version
15-
${RV_DEPS_DAV1D_VERSION}
16-
)
7+
RV_CREATE_STANDARD_DEPS_VARIABLES("RV_DEPS_DAV1D" "${RV_DEPS_DAV1D_VERSION}" "ninja" "meson")
8+
RV_SHOW_STANDARD_DEPS_VARIABLES()
179

1810
SET(_download_url
1911
"https://github.com/videolan/dav1d/archive/refs/tags/${_version}.zip"
@@ -22,26 +14,15 @@ SET(_download_hash
2214
${RV_DEPS_DAV1D_DOWNLOAD_HASH}
2315
)
2416

25-
SET(_install_dir
26-
${RV_DEPS_BASE_DIR}/${_target}/install
27-
)
28-
SET(_include_dir
29-
${_install_dir}/include
30-
)
17+
# _lib_dir_name is needed for the meson --libdir option
3118
IF(RHEL_VERBOSE)
3219
SET(_lib_dir_name
3320
lib64
3421
)
35-
SET(_lib_dir
36-
${_install_dir}/lib64
37-
)
3822
ELSE()
3923
SET(_lib_dir_name
4024
lib
4125
)
42-
SET(_lib_dir
43-
${_install_dir}/lib
44-
)
4526
ENDIF()
4627

4728
SET(_david_lib_name
@@ -52,13 +33,6 @@ SET(_dav1d_lib
5233
${_lib_dir}/${_david_lib_name}
5334
)
5435

55-
SET(_configure_command
56-
meson
57-
)
58-
SET(_make_command
59-
ninja
60-
)
61-
6236
IF(APPLE)
6337
# Cross-file must be specified because if Rosetta is used to compile for x86_64 from ARM64, Meson still detects ARM64 as the default architecture.
6438

@@ -92,7 +66,7 @@ EXTERNALPROJECT_ADD(
9266
DOWNLOAD_NAME ${_target}_${_version}.zip
9367
DOWNLOAD_DIR ${RV_DEPS_DOWNLOAD_DIR}
9468
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
95-
SOURCE_DIR ${RV_DEPS_BASE_DIR}/${_target}/src
69+
SOURCE_DIR ${_source_dir}
9670
INSTALL_DIR ${_install_dir}
9771
URL ${_download_url}
9872
URL_MD5 ${_download_hash}
@@ -107,56 +81,26 @@ EXTERNALPROJECT_ADD(
10781
USES_TERMINAL_BUILD TRUE
10882
)
10983

110-
ADD_LIBRARY(dav1d::dav1d STATIC IMPORTED GLOBAL)
111-
ADD_DEPENDENCIES(dav1d::dav1d ${_target})
112-
SET_PROPERTY(
113-
TARGET dav1d::dav1d
114-
PROPERTY IMPORTED_LOCATION ${_dav1d_lib}
115-
)
116-
SET_PROPERTY(
117-
TARGET dav1d::dav1d
118-
PROPERTY IMPORTED_SONAME ${_david_lib_name}
119-
)
120-
121-
FILE(MAKE_DIRECTORY ${_include_dir})
122-
TARGET_INCLUDE_DIRECTORIES(
84+
RV_ADD_IMPORTED_LIBRARY(
85+
NAME
12386
dav1d::dav1d
124-
INTERFACE ${_include_dir}
87+
TYPE
88+
STATIC
89+
LOCATION
90+
${_dav1d_lib}
91+
INCLUDE_DIRS
92+
${_include_dir}
93+
DEPENDS
94+
${_target}
95+
ADD_TO_DEPS_LIST
12596
)
126-
LIST(APPEND RV_DEPS_LIST dav1d::dav1d)
12797

12898
IF(RV_TARGET_WINDOWS)
129-
ADD_CUSTOM_COMMAND(
130-
TARGET ${_target}
131-
POST_BUILD
132-
COMMENT "Installing ${_target}'s libs and bin into ${RV_STAGE_LIB_DIR} and ${RV_STAGE_BIN_DIR}"
133-
COMMAND ${CMAKE_COMMAND} -E copy_directory ${_install_dir}/lib ${RV_STAGE_LIB_DIR}
134-
COMMAND ${CMAKE_COMMAND} -E copy_directory ${_install_dir}/bin ${RV_STAGE_BIN_DIR}
135-
)
136-
ADD_CUSTOM_TARGET(
137-
${_target}-stage-target ALL
138-
DEPENDS ${RV_STAGE_LIB_DIR}/${_david_lib_name}
139-
)
99+
RV_STAGE_DEPENDENCY_LIBS(TARGET ${_target} BIN_DIR ${_install_dir}/bin OUTPUTS ${RV_STAGE_LIB_DIR}/${_david_lib_name})
140100
ELSE()
141-
ADD_CUSTOM_COMMAND(
142-
COMMENT "Installing ${_target}'s libs into ${RV_STAGE_LIB_DIR}"
143-
OUTPUT ${RV_STAGE_LIB_DIR}/${_david_lib_name}
144-
COMMAND ${CMAKE_COMMAND} -E copy_directory ${_lib_dir} ${RV_STAGE_LIB_DIR}
145-
DEPENDS ${_target}
146-
)
147-
ADD_CUSTOM_TARGET(
148-
${_target}-stage-target ALL
149-
DEPENDS ${RV_STAGE_LIB_DIR}/${_david_lib_name}
150-
)
101+
RV_STAGE_DEPENDENCY_LIBS(TARGET ${_target} OUTPUTS ${RV_STAGE_LIB_DIR}/${_david_lib_name})
151102
ENDIF()
152103

153-
ADD_DEPENDENCIES(dependencies ${_target}-stage-target)
154-
155-
SET(RV_DEPS_DAV1D_VERSION
156-
${_version}
157-
CACHE INTERNAL "" FORCE
158-
)
159-
160104
# FFmpeg customization adding dav1d codec support to FFmpeg
161105
SET_PROPERTY(
162106
GLOBAL APPEND

cmake/dependencies/doctest.cmake

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ EXTERNALPROJECT_ADD(
4343
LOG_DOWNLOAD ON
4444
)
4545

46-
ADD_LIBRARY(doctest INTERFACE)
47-
ADD_DEPENDENCIES(doctest ${_target})
46+
ADD_LIBRARY(doctest::doctest INTERFACE IMPORTED GLOBAL)
47+
ADD_DEPENDENCIES(doctest::doctest ${_target})
4848
TARGET_INCLUDE_DIRECTORIES(
49-
doctest
49+
doctest::doctest
5050
INTERFACE "${RV_DEPS_BASE_DIR}/${_target}/src/${_target}"
5151
)

0 commit comments

Comments
 (0)