From 7828461a42e437df12ffb6726071356202bff6ef Mon Sep 17 00:00:00 2001 From: Duncan Ogilvie Date: Thu, 25 Mar 2021 11:22:42 +0100 Subject: [PATCH] Minor improvements to property ordering --- src/cmkrlib/cmake.cpp | 22 ++++++++++++---------- src/cmkrlib/cmake.hpp | 2 +- src/cmkrlib/gen.cpp | 2 +- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/cmkrlib/cmake.cpp b/src/cmkrlib/cmake.cpp index 2c55cd3..95d2f7d 100644 --- a/src/cmkrlib/cmake.cpp +++ b/src/cmkrlib/cmake.cpp @@ -196,27 +196,29 @@ CMake::CMake(const std::string &path, bool build) { #undef renamed - auto optional_array = [&t](const toml::key &k, std::vector &v) { + auto optional_array = [&t](const toml::key &k) { + std::vector v; if (t.contains(k)) { v = detail::to_string_vec(toml::find(t, k).as_array()); } + return v; }; - optional_array("compile-definitions", target.compile_definitions); - optional_array("compile-features", target.compile_features); - optional_array("compile-options", target.compile_options); - optional_array("include-directories", target.include_directories); - optional_array("link-directories", target.link_directories); - optional_array("link-libraries", target.link_libraries); - optional_array("link-options", target.link_options); - optional_array("precompile-headers", target.precompile_headers); + target.compile_definitions = optional_array("compile-definitions"); + target.compile_features = optional_array("compile-features"); + target.compile_options = optional_array("compile-options"); + target.include_directories = optional_array("include-directories"); + target.link_directories = optional_array("link-directories"); + target.link_libraries = optional_array("link-libraries"); + target.link_options = optional_array("link-options"); + target.precompile_headers = optional_array("precompile-headers"); if (t.contains("alias")) { target.alias = toml::find(t, "alias").as_string(); } if (t.contains("properties")) { - using prop_map = std::map; + using prop_map = tsl::ordered_map; target.properties = toml::find(t, "properties"); } diff --git a/src/cmkrlib/cmake.hpp b/src/cmkrlib/cmake.hpp index 5d3403b..a3f14a1 100644 --- a/src/cmkrlib/cmake.hpp +++ b/src/cmkrlib/cmake.hpp @@ -47,7 +47,7 @@ struct Target { std::vector sources; std::string alias; - std::map properties; + tsl::ordered_map properties; }; struct Test { diff --git a/src/cmkrlib/gen.cpp b/src/cmkrlib/gen.cpp index 528fed0..0cfdb56 100644 --- a/src/cmkrlib/gen.cpp +++ b/src/cmkrlib/gen.cpp @@ -158,7 +158,7 @@ struct Command { } template - bool print_arg(const std::map &map) { + bool print_arg(const tsl::ordered_map &map) { if (map.empty()) { return true; }