mirror of
https://github.com/webmproject/libwebp.git
synced 2024-11-19 20:08:28 +01:00
cmake: fix compilation w/Xcode generator
Add a stub file to object only library targets. https://cmake.org/cmake/help/v3.18/command/add_library.html#object-libraries Some native build systems (such as Xcode) may not like targets that have only object files, so consider adding at least one real source file to any target that references $<TARGET_OBJECTS:objlib>. Bug: webp:477 Change-Id: I5d404c921d84433c7a0b22e0736ab0dbe699d264
This commit is contained in:
parent
8870ba7f06
commit
8484a1204c
@ -164,6 +164,29 @@ add_definitions(-DHAVE_CONFIG_H)
|
|||||||
|
|
||||||
# ##############################################################################
|
# ##############################################################################
|
||||||
# Build the webpdecoder library.
|
# Build the webpdecoder library.
|
||||||
|
|
||||||
|
# Creates a source file with an unused stub function in $CMAKE_BINARY_DIR and
|
||||||
|
# adds it to the specified target. Currently used only with Xcode.
|
||||||
|
#
|
||||||
|
# See also:
|
||||||
|
# https://cmake.org/cmake/help/v3.18/command/add_library.html#object-libraries
|
||||||
|
# "Some native build systems (such as Xcode) may not like targets that have
|
||||||
|
# only object files, so consider adding at least one real source file to any
|
||||||
|
# target that references $<TARGET_OBJECTS:objlib>."
|
||||||
|
function(libwebp_add_stub_file TARGET)
|
||||||
|
set(stub_source_dir "${CMAKE_BINARY_DIR}")
|
||||||
|
set(stub_source_file
|
||||||
|
"${stub_source_dir}/libwebp_${TARGET}_stub.c")
|
||||||
|
set(stub_source_code
|
||||||
|
"// Generated file. DO NOT EDIT!\n"
|
||||||
|
"// C source file created for target ${TARGET}.\n"
|
||||||
|
"void libwebp_${TARGET}_stub_function(void)\;\n"
|
||||||
|
"void libwebp_${TARGET}_stub_function(void) {}\n")
|
||||||
|
file(WRITE "${stub_source_file}" ${stub_source_code})
|
||||||
|
|
||||||
|
target_sources(${TARGET} PRIVATE ${stub_source_file})
|
||||||
|
endfunction()
|
||||||
|
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
# avoid security warnings for e.g., fopen() used in the examples.
|
# avoid security warnings for e.g., fopen() used in the examples.
|
||||||
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
||||||
@ -190,6 +213,9 @@ add_library(webpdecoder
|
|||||||
$<TARGET_OBJECTS:webpdecode>
|
$<TARGET_OBJECTS:webpdecode>
|
||||||
$<TARGET_OBJECTS:webpdspdecode>
|
$<TARGET_OBJECTS:webpdspdecode>
|
||||||
$<TARGET_OBJECTS:webputilsdecode>)
|
$<TARGET_OBJECTS:webputilsdecode>)
|
||||||
|
if(XCODE)
|
||||||
|
libwebp_add_stub_file(webpdecoder)
|
||||||
|
endif()
|
||||||
target_link_libraries(webpdecoder ${WEBP_DEP_LIBRARIES})
|
target_link_libraries(webpdecoder ${WEBP_DEP_LIBRARIES})
|
||||||
target_include_directories(
|
target_include_directories(
|
||||||
webpdecoder
|
webpdecoder
|
||||||
@ -229,6 +255,9 @@ add_library(webp
|
|||||||
$<TARGET_OBJECTS:webpdsp>
|
$<TARGET_OBJECTS:webpdsp>
|
||||||
$<TARGET_OBJECTS:webpencode>
|
$<TARGET_OBJECTS:webpencode>
|
||||||
$<TARGET_OBJECTS:webputils>)
|
$<TARGET_OBJECTS:webputils>)
|
||||||
|
if(XCODE)
|
||||||
|
libwebp_add_stub_file(webp)
|
||||||
|
endif()
|
||||||
target_link_libraries(webp ${WEBP_DEP_LIBRARIES})
|
target_link_libraries(webp ${WEBP_DEP_LIBRARIES})
|
||||||
target_include_directories(webp
|
target_include_directories(webp
|
||||||
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
|
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
Loading…
Reference in New Issue
Block a user