aboutsummaryrefslogtreecommitdiffhomepage
path: root/gn/gn_to_cmake.py
diff options
context:
space:
mode:
Diffstat (limited to 'gn/gn_to_cmake.py')
-rw-r--r--gn/gn_to_cmake.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/gn/gn_to_cmake.py b/gn/gn_to_cmake.py
index 8b4f48479f..0e82d64c9f 100644
--- a/gn/gn_to_cmake.py
+++ b/gn/gn_to_cmake.py
@@ -475,8 +475,15 @@ def WriteSourceVariables(out, target, project):
source_types = {'cxx':[], 'c':[], 'asm':[],
'obj':[], 'obj_target':[], 'input':[], 'other':[]}
+ all_sources = target.properties.get('sources', [])
+
+ # As of cmake 3.11 add_library must have sources. If there are
+ # no sources, add empty.cpp as the file to compile.
+ if len(all_sources) == 0:
+ all_sources.append(posixpath.join(project.build_path, 'empty.cpp'))
+
# TODO .def files on Windows
- for source in target.properties.get('sources', []):
+ for source in all_sources:
_, ext = posixpath.splitext(source)
source_abs_path = project.GetAbsolutePath(source)
source_types[source_file_types.get(ext, 'other')].append(source_abs_path)
@@ -621,6 +628,10 @@ def WriteProject(project):
out.write('cmake_minimum_required(VERSION 2.8.8 FATAL_ERROR)\n')
out.write('cmake_policy(VERSION 2.8.8)\n\n')
+ out.write('file(WRITE "')
+ out.write(posixpath.join(project.build_path, "empty.cpp"))
+ out.write('")\n')
+
# Update the gn generated ninja build.
# If a build file has changed, this will update CMakeLists.ext if
# gn gen out/config --ide=json --json-ide-script=../../gn/gn_to_cmake.py