diff options
author | Herb Derby <herb@google.com> | 2018-05-18 15:09:41 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-05-18 20:56:24 +0000 |
commit | 5699278b679f27e1426ff1867807d689f0e806d4 (patch) | |
tree | 18a3f58b533916ae2b86c055c7077ea3d4d42bfe /gn/gn_to_cmake.py | |
parent | 861b52ea98d703786ce485389db07e58759c1792 (diff) |
Add rules for cmake 3.11 to not error
As of cmake 3.11, the add_library target must have sources
associated with it. If there are sources, just compile
the file empty.cpp.
Change-Id: I7fec03dc0f0d2e6098572ed6e9fcdfaac3811024
Reviewed-on: https://skia-review.googlesource.com/129189
Commit-Queue: Herb Derby <herb@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
Diffstat (limited to 'gn/gn_to_cmake.py')
-rw-r--r-- | gn/gn_to_cmake.py | 13 |
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 |