From d89baa46e2afcbb06f43274c4f5584a04420e8e5 Mon Sep 17 00:00:00 2001 From: Duncan Ogilvie Date: Wed, 31 Mar 2021 15:46:38 +0200 Subject: [PATCH] Fix custom target support --- src/cmkrlib/gen.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/cmkrlib/gen.cpp b/src/cmkrlib/gen.cpp index 7ac01f7..24dab82 100644 --- a/src/cmkrlib/gen.cpp +++ b/src/cmkrlib/gen.cpp @@ -450,6 +450,7 @@ int generate_cmake(const char *path, bool root) { } if (!target.sources.empty()) { + // TODO: add duplicate checking std::vector sources; for (const auto &src : target.sources) { auto path = fs::path(src); @@ -462,7 +463,10 @@ int generate_cmake(const char *path, bool root) { throw std::runtime_error(target.name + " sources wildcard found 0 files"); } if (target.type != cmake::target_interface) { - sources.push_back("cmake.toml"); + // Do not add cmake.toml twice + if (std::find(sources.begin(), sources.end(), "cmake.toml") == sources.end()) { + sources.push_back("cmake.toml"); + } } cmd("set")(target.name + "_SOURCES", sources).endl(); } @@ -497,9 +501,9 @@ int generate_cmake(const char *path, bool root) { target_scope = "INTERFACE"; break; case cmake::target_custom: - // TODO: add proper support + // TODO: add proper support, this is hacky add_command = "add_custom_target"; - target_type = ""; + target_type = "SOURCES"; target_scope = "PUBLIC"; break; default: