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
diff --git a/CMakeLists.txt b/CMakeLists.txt index 5cf320a..74edf8e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt
@@ -498,6 +498,8 @@ 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
diff --git a/build/cmake/util.cmake b/build/cmake/util.cmake index d6c4322..bbb6992 100644 --- a/build/cmake/util.cmake +++ b/build/cmake/util.cmake
@@ -15,7 +15,7 @@ # 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"