vcpkg-wip
Duncan Ogilvie 4 years ago
parent 1e8b756276
commit 461f26d0c6

@ -17,21 +17,21 @@ project(cmkr VERSION ${cmkr_PROJECT_VERSION})
add_subdirectory(third_party) add_subdirectory(third_party)
set(cmkrlib_SOURCES set(cmkrlib_SOURCES
src/cmkrlib/args.cpp "src/cmkrlib/args.cpp"
src/cmkrlib/build.cpp "src/cmkrlib/build.cpp"
src/cmkrlib/cmake.cpp "src/cmkrlib/cmake.cpp"
src/cmkrlib/error.cpp "src/cmkrlib/error.cpp"
src/cmkrlib/gen.cpp "src/cmkrlib/gen.cpp"
src/cmkrlib/help.cpp "src/cmkrlib/help.cpp"
src/cmkrlib/cmake.hpp "src/cmkrlib/cmake.hpp"
src/cmkrlib/enum_helper.hpp "src/cmkrlib/enum_helper.hpp"
src/cmkrlib/fs.hpp "src/cmkrlib/fs.hpp"
include/args.h "include/args.h"
include/build.h "include/build.h"
include/error.h "include/error.h"
include/gen.h "include/gen.h"
include/help.h "include/help.h"
include/literals.h "include/literals.h"
cmake.toml cmake.toml
) )
@ -55,7 +55,7 @@ target_link_libraries(cmkrlib PUBLIC
) )
set(cmkr_SOURCES set(cmkr_SOURCES
src/main.cpp "src/main.cpp"
cmake.toml cmake.toml
) )

@ -139,7 +139,7 @@ struct Command {
std::string quote(const std::string &str) { std::string quote(const std::string &str) {
// Don't quote arguments that don't need quoting // Don't quote arguments that don't need quoting
if (str.find(' ') == std::string::npos && str.find('\"') == std::string::npos && str.find("${") == std::string::npos) { if (str.find(' ') == std::string::npos && str.find('\"') == std::string::npos && str.find('/') == std::string::npos) {
return str; return str;
} }
std::string result; std::string result;
@ -201,7 +201,7 @@ struct Command {
} else { } else {
ss << ' '; ss << ' ';
} }
ss << value; ss << quote(value);
return true; return true;
} }
@ -212,7 +212,9 @@ struct Command {
} else { } else {
ss << ' '; ss << ' ';
} }
ss << value; std::stringstream tmp;
tmp << value;
ss << quote(tmp.str());
return true; return true;
} }
@ -245,7 +247,7 @@ int generate_cmake(const char *path, bool root) {
} }
return Command(ss, indent, command); return Command(ss, indent, command);
}; };
auto comment = [&ss](const char *comment) { auto comment = [&ss](const std::string &comment) {
ss << "# " << comment << '\n'; ss << "# " << comment << '\n';
return CommandEndl(ss); return CommandEndl(ss);
}; };
@ -427,13 +429,14 @@ int generate_cmake(const char *path, bool root) {
cmd("endif")(); cmd("endif")();
// clang-format on // clang-format on
cmd("add_subdirectory")(dir); cmd("add_subdirectory")(dir);
cmd("set")("CMAKE_FOLDER", "CMKR_CMAKE_FOLDER"); cmd("set")("CMAKE_FOLDER", "${CMKR_CMAKE_FOLDER}").endl();
} }
endl(); endl();
} }
if (!cmake.targets.empty()) { if (!cmake.targets.empty()) {
for (const auto &target : cmake.targets) { for (const auto &target : cmake.targets) {
comment("Target " + target.name);
if (!target.cmake_before.empty()) { if (!target.cmake_before.empty()) {
ss << tolf(target.cmake_before) << "\n\n"; ss << tolf(target.cmake_before) << "\n\n";
} }

Loading…
Cancel
Save