Commit db37c755 authored by Tom Finegan's avatar Tom Finegan

cmake: Fix potential file name collision in Xcode.

When a target has no C++ sources, but includes C++ object files
Xcode requires special treatment. A dummy source file is created
using the target's name to force the CMake Xcode generator to use
C++ as link language.

Append "_dummy" to the dummy source file's basename to avoid
collisions with the target's main source file when it
is target.cc.

Also adds a TODO to avoid adding the dummy source file when the
target being adjusted already has C++ sources.

Change-Id: I9795f6490e88eae6afc3a5901e6ee76a36cc801a
parent cdd64d4b
......@@ -498,6 +498,8 @@ if (HAVE_PTHREAD_H AND CONFIG_MULTITHREAD)
endif ()
if (XCODE)
# TODO(tomfinegan): Make sure target has no C++ files before doing this as
# it's not necessary in that case.
if (CONFIG_LIBYUV OR CONFIG_WEBM_IO)
# The Xcode generator does not obey LINKER_LANGUAGE. Because of the issue
# what looks like a C++ file needs to be in any target that Xcode will link
......
......@@ -15,7 +15,7 @@ set(AOM_BUILD_CMAKE_UTIL_CMAKE_ 1)
# returns the full path to the dummy source file via the $out_file_path
# parameter.
function (create_dummy_source_file basename extension out_file_path)
set(dummy_source_file "${AOM_CONFIG_DIR}/${basename}.${extension}")
set(dummy_source_file "${AOM_CONFIG_DIR}/${basename}_dummy.${extension}")
file(WRITE "${dummy_source_file}"
"// Generated file. DO NOT EDIT!\n"
"// ${target_name} needs a ${extension} file to force link language, \n"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment