-
-
Notifications
You must be signed in to change notification settings - Fork 398
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d84504b
commit 1c409f7
Showing
3 changed files
with
131 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
index 3f521e3..ca0a8f0 100644 | ||
--- a/CMakeLists.txt | ||
+++ b/CMakeLists.txt | ||
@@ -73,7 +73,6 @@ if(MSVC) | ||
endif() | ||
|
||
# Need to set PIC to allow creating shared libraries from object file libraries. | ||
-SET(CMAKE_POSITION_INDEPENDENT_CODE ON) | ||
|
||
# Build the set of objects that do not need to be compiled with flags to enable | ||
# particular architecture features. | ||
@@ -120,19 +119,16 @@ if(NOT MSVC) | ||
endif() | ||
|
||
# this creates the static library (.a) | ||
-ADD_LIBRARY( ${ly_lib_static} STATIC ${ly_lib_parts}) | ||
- | ||
-# this creates the shared library (.so) | ||
-ADD_LIBRARY( ${ly_lib_shared} SHARED ${ly_lib_parts}) | ||
-SET_TARGET_PROPERTIES( ${ly_lib_shared} PROPERTIES OUTPUT_NAME "${ly_lib_name}" ) | ||
-SET_TARGET_PROPERTIES( ${ly_lib_shared} PROPERTIES PREFIX "lib" ) | ||
-if(WIN32) | ||
- SET_TARGET_PROPERTIES( ${ly_lib_shared} PROPERTIES IMPORT_PREFIX "lib" ) | ||
+ADD_LIBRARY( ${ly_lib_static} ${ly_lib_parts}) | ||
+target_compile_features(${ly_lib_static} PUBLIC cxx_std_11) | ||
+if (BUILD_SHARED_LIBS) | ||
+ add_definitions("-DLIBYUV_BUILDING_SHARED_LIBRARY") | ||
endif() | ||
+# this creates the shared library (.so) | ||
|
||
+option(BUILD_TOOLS "Build tools" OFF) | ||
+if (BUILD_TOOLS) | ||
# this creates the cpuid tool | ||
-ADD_EXECUTABLE ( cpuid ${ly_base_dir}/util/cpuid.c ) | ||
-TARGET_LINK_LIBRARIES ( cpuid ${ly_lib_static} ) | ||
|
||
# this creates the conversion tool | ||
ADD_EXECUTABLE ( yuvconvert ${ly_base_dir}/util/yuvconvert.cc ) | ||
@@ -141,12 +137,22 @@ TARGET_LINK_LIBRARIES ( yuvconvert ${ly_lib_static} ) | ||
# this creates the yuvconstants tool | ||
ADD_EXECUTABLE ( yuvconstants ${ly_base_dir}/util/yuvconstants.c ) | ||
TARGET_LINK_LIBRARIES ( yuvconstants ${ly_lib_static} ) | ||
+include(CheckFunctionExists) | ||
+check_function_exists(round HAVE_MATH_SYSTEM) | ||
+if(NOT HAVE_MATH_SYSTEM) | ||
+ target_link_libraries(yuvconstants m) | ||
+endif() | ||
+INSTALL(TARGETS yuvconvert yuvconstants DESTINATION bin) | ||
+endif() | ||
|
||
-find_package ( JPEG ) | ||
-if (JPEG_FOUND) | ||
- include_directories( ${JPEG_INCLUDE_DIR} ) | ||
- target_link_libraries( ${ly_lib_shared} ${JPEG_LIBRARY} ) | ||
- add_definitions( -DHAVE_JPEG ) | ||
+option(LIBYUV_WITH_JPEG "Build libyuv with jpeg" OFF) | ||
+if (LIBYUV_WITH_JPEG) | ||
+ find_package(JPEG REQUIRED) | ||
+ target_link_libraries(${ly_lib_static} JPEG::JPEG ) | ||
+ target_compile_definitions(${ly_lib_static} PRIVATE HAVE_JPEG) | ||
+ if (BUILD_TOOLS) | ||
+ target_compile_definitions(yuvconvert PRIVATE HAVE_JPEG) | ||
+ endif() | ||
endif() | ||
|
||
if(UNIT_TEST) | ||
@@ -192,11 +198,8 @@ endif() | ||
|
||
|
||
# install the conversion tool, .so, .a, and all the header files | ||
-INSTALL ( PROGRAMS ${CMAKE_BINARY_DIR}/yuvconvert DESTINATION bin ) | ||
-INSTALL ( TARGETS ${ly_lib_static} DESTINATION lib ) | ||
-INSTALL ( TARGETS ${ly_lib_shared} LIBRARY DESTINATION lib RUNTIME DESTINATION bin ) | ||
+INSTALL ( TARGETS ${ly_lib_static} RUNTIME DESTINATION bin ARCHIVE DESTINATION lib LIBRARY DESTINATION lib) | ||
INSTALL ( DIRECTORY ${PROJECT_SOURCE_DIR}/include/ DESTINATION include ) | ||
|
||
# create the .deb and .rpm packages using cpack | ||
-INCLUDE ( CM_linux_packages.cmake ) | ||
|
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 @@ | ||
-- Versions from LIBYUV_VERSION definition in include/libyuv/version.h | ||
-- Pay attention to package commits incrementing this definition | ||
local table = { | ||
["1891"] = "611806a1559b92c97961f51c78805d8d9d528c08", | ||
} | ||
|
||
function main(version) | ||
return table[tostring(version)] | ||
end |
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 |
---|---|---|
@@ -1,30 +1,56 @@ | ||
package("libyuv") | ||
|
||
set_homepage("https://chromium.googlesource.com/libyuv/libyuv/") | ||
set_description("libyuv is an open source project that includes YUV scaling and conversion functionality.") | ||
set_license("BSD-3-Clause") | ||
|
||
set_urls("https://chromium.googlesource.com/libyuv/libyuv.git") | ||
add_versions("2023.10.27", "31e1d6f896615342d5d5b6bde8f7b50b3fd698dc") | ||
if on_source then | ||
on_source(function (package) | ||
package:add("urls", "https://github.com/lemenkov/libyuv.git") | ||
package:add("urls", "https://github.com/lemenkov/libyuv/archive/$(version).tar.gz", { | ||
alias = "github", version = import("version") | ||
}) | ||
|
||
package:add("urls", "https://chromium.googlesource.com/libyuv/libyuv.git") | ||
package:add("urls", "https://chromium.googlesource.com/libyuv/libyuv/+archive/$(version).tar.gz", { | ||
alias = "home", version = import("version") | ||
}) | ||
|
||
package:add("versions", "home:1891", "92eec6118d1c36c4b7dc76397351d86ec0d1da8171c63cd48d5fb130d4384c59") | ||
|
||
package:add("versions", "github:1891", "a8dddc6f45d6987cd3c08e00824792f3c72651fde29f475f572ee2292c03761f") | ||
end) | ||
end | ||
|
||
add_patches("1891", "patches/1891/cmake.patch", "72f16cfdbfe25e091add589fa1b7772c6fd6ee7b159da7ac59ac1b7d6d7f0be1") | ||
|
||
add_configs("jpeg", {description = "Build with JPEG.", default = false, type = "boolean"}) | ||
add_configs("tools", {description = "Build tools", default = false, type = "boolean"}) | ||
|
||
add_deps("cmake") | ||
|
||
on_install("windows", "linux", "macosx", "android", "cross", "bsd", "mingw", function (package) | ||
local configs = {"-DTEST=OFF"} | ||
table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release")) | ||
|
||
io.replace("CMakeLists.txt", "INSTALL ( PROGRAMS ${CMAKE_BINARY_DIR}/yuvconvert DESTINATION bin )", "", {plain = true}) | ||
import("package.tools.cmake").install(package, configs) | ||
|
||
if package:is_plat("macosx", "linux", "android") then | ||
if package:config("shared") then | ||
os.tryrm(package:installdir("lib", "*.a")) | ||
else | ||
os.tryrm(package:installdir("lib", "*.so")) | ||
end | ||
if is_plat("linux", "bsd") then | ||
add_syslinks("m") | ||
end | ||
|
||
on_load(function (package) | ||
if package:config("jpeg") then | ||
package:add("deps", "libjpeg") | ||
end | ||
|
||
if package:config("shared") then | ||
package:add("defines", "LIBYUV_USING_SHARED_LIBRARY") | ||
end | ||
end) | ||
|
||
on_install(function (package) | ||
local configs = {} | ||
table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release")) | ||
table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF")) | ||
table.insert(configs, "-DLIBYUV_WITH_JPEG=" .. (package:config("jpeg") and "ON" or "OFF")) | ||
table.insert(configs, "-DBUILD_TOOLS=" .. (package:config("tools") and "ON" or "OFF")) | ||
import("package.tools.cmake").install(package, configs) | ||
end) | ||
|
||
on_test(function (package) | ||
assert(package:has_cfuncs("I420Rotate", {includes = "libyuv/rotate.h"})) | ||
end) |