cc_project_template_gn

A gn, ninja, and googletest-based C++ project template
git clone https://git.bracken.jp/cc_project_template_gn.git
Log | Files | Refs | Submodules | README | LICENSE

commit 6d820ea66c80c07d3025f06866422b9a3e4de8c9
parent 0bf09a588b70364098b3ef98b7451164be6fc731
Author: Chris Bracken <chris@bracken.jp>
Date:   Tue, 20 Apr 2021 14:42:52 -0700

Add static, shared library example targets

Also demonstrates the generally poor practice of declaring a sources
list in the global namespace. If only gn had Bazel's fileset type.

Diffstat:
MBUILD.gn | 2++
Msrc/BUILD.gn | 22++++++++++++++++------
2 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/BUILD.gn b/BUILD.gn @@ -1,5 +1,7 @@ group("default") { deps = [ "//src:main", + "//src:libfoo_shared", + "//src:libfoo_static", ] } diff --git a/src/BUILD.gn b/src/BUILD.gn @@ -7,13 +7,23 @@ executable("main") { ] } +FOO_SOURCES = [ + "bar.cc", + "bar.h", + "foo.cc", + "foo.h", +] + source_set("foo_srcs") { - sources = [ - "bar.cc", - "bar.h", - "foo.cc", - "foo.h", - ] + sources = FOO_SOURCES +} + +static_library("libfoo_static") { + sources = FOO_SOURCES +} + +shared_library("libfoo_shared") { + sources = FOO_SOURCES } executable("foo_tests") {