-
Notifications
You must be signed in to change notification settings - Fork 211
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: use target properties instead of variables for flags, dirs, sourc…
…es, and link libraries (#1778)
- Loading branch information
Showing
24 changed files
with
631 additions
and
457 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
set(LIB_FILENAME "${AVIF_SOURCE_DIR}/ext/aom/build.libavif/${CMAKE_STATIC_LIBRARY_PREFIX}aom${CMAKE_STATIC_LIBRARY_SUFFIX}") | ||
if(NOT EXISTS "${LIB_FILENAME}") | ||
message(FATAL_ERROR "libavif: ${LIB_FILENAME} is missing, bailing out") | ||
endif() | ||
|
||
add_library(aom STATIC IMPORTED GLOBAL) | ||
set_target_properties(aom PROPERTIES IMPORTED_LOCATION "${LIB_FILENAME}" AVIF_LOCAL ON) | ||
target_include_directories(aom INTERFACE "${AVIF_SOURCE_DIR}/ext/aom") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Building the avm repository generates files such as "libaom.a" because it is a fork of aom. | ||
set(LIB_FILENAME "${AVIF_SOURCE_DIR}/ext/avm/build.libavif/${CMAKE_STATIC_LIBRARY_PREFIX}aom${CMAKE_STATIC_LIBRARY_SUFFIX}") | ||
if(NOT EXISTS "${LIB_FILENAME}") | ||
message(FATAL_ERROR "libavif: ${LIB_FILENAME} (from avm) is missing, bailing out") | ||
endif() | ||
|
||
add_library(aom STATIC IMPORTED GLOBAL) | ||
set_target_properties(aom PROPERTIES IMPORTED_LOCATION "${LIB_FILENAME}" AVIF_LOCAL ON) | ||
target_include_directories(aom INTERFACE "${AVIF_SOURCE_DIR}/ext/avm") | ||
# ext/avm/aom/aom_encoder.h includes config/aom_config.h which is generated by the local build of avm. | ||
target_include_directories(aom INTERFACE "${AVIF_SOURCE_DIR}/ext/avm/build.libavif") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
set(AVIF_DAV1D_BUILD_DIR "${AVIF_SOURCE_DIR}/ext/dav1d/build") | ||
# If ${ANDROID_ABI} is set, look for the library under that subdirectory. | ||
if(DEFINED ANDROID_ABI) | ||
set(AVIF_DAV1D_BUILD_DIR "${AVIF_DAV1D_BUILD_DIR}/${ANDROID_ABI}") | ||
endif() | ||
set(LIB_FILENAME "${AVIF_DAV1D_BUILD_DIR}/src/libdav1d${CMAKE_STATIC_LIBRARY_SUFFIX}") | ||
if(NOT EXISTS "${LIB_FILENAME}") | ||
if("${CMAKE_STATIC_LIBRARY_SUFFIX}" STREQUAL ".a") | ||
message(FATAL_ERROR "libavif: ${LIB_FILENAME} is missing, bailing out") | ||
else() | ||
# On windows, meson will produce a libdav1d.a instead of the expected libdav1d.dll/.lib. | ||
# See https://github.com/mesonbuild/meson/issues/8153. | ||
set(LIB_FILENAME "${AVIF_SOURCE_DIR}/ext/dav1d/build/src/libdav1d.a") | ||
if(NOT EXISTS "${LIB_FILENAME}") | ||
message(FATAL_ERROR "libavif: ${LIB_FILENAME} (or libdav1d${CMAKE_STATIC_LIBRARY_SUFFIX}) is missing, bailing out") | ||
endif() | ||
endif() | ||
endif() | ||
|
||
add_library(dav1d::dav1d STATIC IMPORTED) | ||
set_target_properties(dav1d::dav1d PROPERTIES IMPORTED_LOCATION ${LIB_FILENAME} AVIF_LOCAL ON) | ||
target_include_directories( | ||
dav1d::dav1d INTERFACE "${AVIF_DAV1D_BUILD_DIR}" "${AVIF_DAV1D_BUILD_DIR}/include" "${AVIF_DAV1D_BUILD_DIR}/include/dav1d" | ||
"${AVIF_SOURCE_DIR}/ext/dav1d/include" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
set(GTEST_INCLUDE_DIRS ${AVIF_SOURCE_DIR}/ext/googletest/googletest/include) | ||
set(GTEST_LIB_FILENAME | ||
${AVIF_SOURCE_DIR}/ext/googletest/build/lib/${CMAKE_STATIC_LIBRARY_PREFIX}gtest${CMAKE_STATIC_LIBRARY_SUFFIX} | ||
) | ||
set(GTEST_MAIN_LIB_FILENAME | ||
${AVIF_SOURCE_DIR}/ext/googletest/build/lib/${CMAKE_STATIC_LIBRARY_PREFIX}gtest_main${CMAKE_STATIC_LIBRARY_SUFFIX} | ||
) | ||
if(NOT EXISTS ${GTEST_INCLUDE_DIRS}/gtest/gtest.h) | ||
message(FATAL_ERROR "googletest(AVIF_LOCAL_GTEST): ${GTEST_INCLUDE_DIRS}/gtest/gtest.h is missing, bailing out") | ||
elseif(NOT EXISTS ${GTEST_LIB_FILENAME}) | ||
message(FATAL_ERROR "googletest(AVIF_LOCAL_GTEST): ${GTEST_LIB_FILENAME} is missing, bailing out") | ||
elseif(NOT EXISTS ${GTEST_MAIN_LIB_FILENAME}) | ||
message(FATAL_ERROR "googletest(AVIF_LOCAL_GTEST): ${GTEST_MAIN_LIB_FILENAME} is missing, bailing out") | ||
else() | ||
message(STATUS "Found local ext/googletest") | ||
endif() | ||
|
||
add_library(GTest::gtest STATIC IMPORTED) | ||
set_target_properties(GTest::gtest PROPERTIES IMPORTED_LOCATION "${GTEST_LIB_FILENAME}" AVIF_LOCAL ON) | ||
|
||
if(TARGET Threads::Threads) | ||
target_link_libraries(GTest::gtest INTERFACE Threads::Threads) | ||
endif() | ||
target_include_directories(GTest::gtest INTERFACE "${GTEST_INCLUDE_DIRS}") | ||
|
||
add_library(GTest::gtest_main STATIC IMPORTED) | ||
target_link_libraries(GTest::gtest_main INTERFACE GTest::gtest) | ||
set_target_properties(GTest::gtest_main PROPERTIES IMPORTED_LOCATION "${GTEST_MAIN_LIB_FILENAME}" AVIF_LOCAL ON) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
add_subdirectory(${AVIF_SOURCE_DIR}/ext/libjpeg EXCLUDE_FROM_ALL) | ||
|
||
set_property(TARGET jpeg PROPERTY AVIF_LOCAL ON) | ||
set(JPEG_INCLUDE_DIR "${AVIF_SOURCE_DIR}/ext/libjpeg") | ||
target_include_directories(jpeg INTERFACE ${JPEG_INCLUDE_DIR}) | ||
|
||
add_library(JPEG::JPEG ALIAS jpeg) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
set(LIB_FILENAME "${AVIF_SOURCE_DIR}/ext/libxml2/install.libavif/lib/${AVIF_LIBRARY_PREFIX}xml2${CMAKE_STATIC_LIBRARY_SUFFIX}") | ||
if(NOT EXISTS "${LIB_FILENAME}") | ||
message(FATAL_ERROR "libavif: ${LIB_FILENAME} is missing, bailing out") | ||
endif() | ||
|
||
add_library(LibXml2 STATIC IMPORTED GLOBAL) | ||
set_target_properties(LibXml2 PROPERTIES IMPORTED_LOCATION "${LIB_FILENAME}" AVIF_LOCAL ON) | ||
target_include_directories(LibXml2 INTERFACE "${AVIF_SOURCE_DIR}/ext/libxml2/install.libavif/include/libxml2") | ||
add_library(LibXml2::LibXml2 ALIAS LibXml2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
set(LIBARGPARSE_FILENAME | ||
"${AVIF_SOURCE_DIR}/ext/libargparse/build/${CMAKE_STATIC_LIBRARY_PREFIX}argparse${CMAKE_STATIC_LIBRARY_SUFFIX}" | ||
) | ||
if(EXISTS "${LIBARGPARSE_FILENAME}") | ||
add_library(libargparse STATIC IMPORTED GLOBAL) | ||
set_target_properties(libargparse PROPERTIES IMPORTED_LOCATION "${LIBARGPARSE_FILENAME}" AVIF_LOCAL ON) | ||
target_include_directories(libargparse INTERFACE "${AVIF_SOURCE_DIR}/ext/libargparse/src") | ||
else() | ||
message(WARNING "${LIBARGPARSE_FILENAME} is missing, not building avifgainmaputil, please run ext/libargparse.cmd") | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
set(AVIF_LIBGAV1_BUILD_DIR "${AVIF_SOURCE_DIR}/ext/libgav1/build") | ||
# If ${ANDROID_ABI} is set, look for the library under that subdirectory. | ||
if(DEFINED ANDROID_ABI) | ||
set(AVIF_LIBGAV1_BUILD_DIR "${AVIF_LIBGAV1_BUILD_DIR}/${ANDROID_ABI}") | ||
endif() | ||
set(LIB_FILENAME "${AVIF_LIBGAV1_BUILD_DIR}/libgav1${CMAKE_STATIC_LIBRARY_SUFFIX}") | ||
if(NOT EXISTS "${LIB_FILENAME}") | ||
message(FATAL_ERROR "libavif: ${LIB_FILENAME} is missing, bailing out") | ||
endif() | ||
|
||
add_library(libgav1_static STATIC IMPORTED GLOBAL) | ||
set_target_properties(libgav1_static PROPERTIES IMPORTED_LOCATION "${LIB_FILENAME}" AVIF_LOCAL ON) | ||
target_include_directories(libgav1_static INTERFACE "${AVIF_SOURCE_DIR}/ext/libgav1/src") | ||
add_library(libgav1::libgav1 ALIAS libgav1_static) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
set(LIB_FILENAME "${CMAKE_CURRENT_SOURCE_DIR}/ext/libwebp/build/libsharpyuv${CMAKE_STATIC_LIBRARY_SUFFIX}") | ||
if(NOT EXISTS "${LIB_FILENAME}") | ||
message(FATAL_ERROR "libavif(AVIF_LIBSHARPYUV=LOCAL): ${LIB_FILENAME} is missing, bailing out") | ||
endif() | ||
|
||
add_library(sharpyuv::sharpyuv STATIC IMPORTED GLOBAL) | ||
set_target_properties(sharpyuv::sharpyuv PROPERTIES IMPORTED_LOCATION "${LIB_FILENAME}" AVIF_LOCAL ON) | ||
target_include_directories(sharpyuv::sharpyuv INTERFACE "${AVIF_SOURCE_DIR}/ext/libwebp") | ||
|
||
set(libsharpyuv_FOUND ON) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
set(AVIF_LIBYUV_BUILD_DIR "${AVIF_SOURCE_DIR}/ext/libyuv/build") | ||
|
||
# If ${ANDROID_ABI} is set, look for the library under that subdirectory. | ||
if(DEFINED ANDROID_ABI) | ||
set(AVIF_LIBYUV_BUILD_DIR "${AVIF_LIBYUV_BUILD_DIR}/${ANDROID_ABI}") | ||
endif() | ||
set(LIB_FILENAME "${AVIF_LIBYUV_BUILD_DIR}/${AVIF_LIBRARY_PREFIX}yuv${CMAKE_STATIC_LIBRARY_SUFFIX}") | ||
|
||
if(NOT EXISTS "${LIB_FILENAME}") | ||
message(FATAL_ERROR "libavif(AVIF_LIBYUV=LOCAL): ${LIB_FILENAME} is missing, bailing out") | ||
endif() | ||
|
||
message(STATUS "libavif: local libyuv found; libyuv-based fast paths enabled.") | ||
|
||
set(LIBYUV_INCLUDE_DIR "${AVIF_SOURCE_DIR}/ext/libyuv/include") | ||
|
||
add_library(yuv::yuv STATIC IMPORTED GLOBAL) | ||
set_target_properties(yuv::yuv PROPERTIES IMPORTED_LOCATION "${LIB_FILENAME}" AVIF_LOCAL ON) | ||
target_include_directories(yuv::yuv INTERFACE "${LIBYUV_INCLUDE_DIR}") | ||
|
||
set(libyuv_FOUND ON) | ||
|
||
set(LIBYUV_VERSION_H "${LIBYUV_INCLUDE_DIR}/libyuv/version.h") | ||
if(EXISTS ${LIBYUV_VERSION_H}) | ||
# message(STATUS "Reading: ${LIBYUV_VERSION_H}") | ||
file(READ ${LIBYUV_VERSION_H} LIBYUV_VERSION_H_CONTENTS) | ||
string(REGEX MATCH "#define LIBYUV_VERSION ([0-9]+)" _ ${LIBYUV_VERSION_H_CONTENTS}) | ||
set(LIBYUV_VERSION ${CMAKE_MATCH_1}) | ||
# message(STATUS "libyuv version detected: ${LIBYUV_VERSION}") | ||
endif() | ||
if(NOT LIBYUV_VERSION) | ||
message(STATUS "libyuv version detection failed.") | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
set(LIB_FILENAME "${AVIF_SOURCE_DIR}/ext/rav1e/build.libavif/usr/lib/${AVIF_LIBRARY_PREFIX}rav1e${CMAKE_STATIC_LIBRARY_SUFFIX}") | ||
if(NOT EXISTS "${LIB_FILENAME}") | ||
message(FATAL_ERROR "libavif: compiled rav1e library is missing (in ext/rav1e/build.libavif/usr/lib), bailing out") | ||
endif() | ||
|
||
add_library(rav1e::rav1e STATIC IMPORTED) | ||
set_target_properties(rav1e::rav1e PROPERTIES IMPORTED_LOCATION "${LIB_FILENAME}" IMPORTED_SONAME rav1e AVIF_LOCAL ON) | ||
target_include_directories(rav1e::rav1e INTERFACE "${AVIF_SOURCE_DIR}/ext/rav1e/build.libavif/usr/include/rav1e") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
set(LIB_FILENAME "${AVIF_SOURCE_DIR}/ext/SVT-AV1/Bin/Release/${AVIF_LIBRARY_PREFIX}SvtAv1Enc${CMAKE_STATIC_LIBRARY_SUFFIX}") | ||
if(NOT EXISTS "${LIB_FILENAME}") | ||
message(FATAL_ERROR "libavif: compiled svt library is missing (in ext/SVT-AV1/Bin/Release), bailing out") | ||
endif() | ||
|
||
add_library(SvtAv1Enc STATIC IMPORTED GLOBAL) | ||
set_target_properties(SvtAv1Enc PROPERTIES IMPORTED_LOCATION "${LIB_FILENAME}" AVIF_LOCAL ON) | ||
target_include_directories(SvtAv1Enc INTERFACE "${AVIF_SOURCE_DIR}/ext/SVT-AV1/include") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# --------------------------------------------------------------------------------------- | ||
# This insanity is for people embedding libavif or making fully static or Windows builds. | ||
# Any proper unix environment should ignore these entire following blocks. | ||
# Put the value of ZLIB_INCLUDE_DIR in the cache. This works around cmake behavior that has been updated by | ||
# cmake policy CMP0102 in cmake 3.17. Remove the CACHE workaround when we require cmake 3.17 or later. See | ||
# https://gitlab.kitware.com/cmake/cmake/-/issues/21343. | ||
set(ZLIB_INCLUDE_DIR "${AVIF_SOURCE_DIR}/ext/zlib" CACHE PATH "zlib include dir") | ||
# This include_directories() call must be before add_subdirectory(ext/zlib) to work around the | ||
# zlib/CMakeLists.txt bug fixed by https://github.com/madler/zlib/pull/818. | ||
include_directories(SYSTEM $<BUILD_INTERFACE:${ZLIB_INCLUDE_DIR}>) | ||
|
||
add_subdirectory(ext/zlib EXCLUDE_FROM_ALL) | ||
|
||
# Re-enable example and example64 targets, as these are used by tests | ||
set_property(TARGET example PROPERTY EXCLUDE_FROM_ALL FALSE) | ||
if(TARGET example64) | ||
set_property(TARGET example64 PROPERTY EXCLUDE_FROM_ALL FALSE) | ||
endif() | ||
|
||
target_include_directories(zlibstatic INTERFACE $<BUILD_INTERFACE:${ZLIB_INCLUDE_DIR}>) | ||
|
||
# This include_directories() call and the previous include_directories() call provide the zlib | ||
# include directories for add_subdirectory(ext/libpng). Because we set PNG_BUILD_ZLIB, | ||
# libpng/CMakeLists.txt won't call find_package(ZLIB REQUIRED) and will see an empty | ||
# ${ZLIB_INCLUDE_DIRS}. | ||
include_directories($<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/ext/zlib>) | ||
set(CMAKE_DEBUG_POSTFIX "") | ||
|
||
add_library(ZLIB::ZLIB ALIAS zlibstatic) | ||
|
||
# This is the only way I could avoid libpng going crazy if it found awk.exe, seems benign otherwise | ||
set(PREV_ANDROID ${ANDROID}) | ||
set(ANDROID TRUE) | ||
set(PNG_BUILD_ZLIB "${AVIF_SOURCE_DIR}/ext/zlib" CACHE STRING "" FORCE) | ||
set(PNG_SHARED OFF CACHE BOOL "") | ||
set(PNG_TESTS OFF CACHE BOOL "") | ||
set(PNG_EXECUTABLES OFF CACHE BOOL "") | ||
|
||
add_subdirectory("${AVIF_SOURCE_DIR}/ext/libpng" EXCLUDE_FROM_ALL) | ||
|
||
set(PNG_PNG_INCLUDE_DIR "${AVIF_SOURCE_DIR}/ext/libpng") | ||
include_directories($<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/ext/libpng>) | ||
set(ANDROID ${PREV_ANDROID}) | ||
|
||
set_target_properties(png_static zlibstatic PROPERTIES AVIF_LOCAL ON) | ||
add_library(PNG::PNG ALIAS png_static) |
Oops, something went wrong.