`create`: Use make_cmake_cmd() and paths.get_cmake_exe()
MODIFY
src/commands_create.cpp
src/commands_create.cpp
#include "vcpkg_Environment.h"
#include "vcpkg_Files.h"
#include "vcpkg_Input.h"
+#include "vcpkglib.h"
namespace vcpkg::Commands::Create
{
void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths)
{
- static const std::string example = Commands::Help::create_example_string(R"###(create zlib2 http://zlib.net/zlib128.zip "zlib128-2.zip")###");
+ static const std::string example = Commands::Help::create_example_string(R"###(create zlib2 http://zlib.net/zlib1211.zip "zlib1211-2.zip")###");
args.check_max_arg_count(3, example);
args.check_min_arg_count(2, example);
args.check_and_get_optional_command_arguments({});
const std::string port_name = args.command_arguments.at(0);
+ const std::string url = args.command_arguments.at(1);
- Environment::ensure_utilities_on_path(paths);
+ const fs::path& cmake_exe = paths.get_cmake_exe();
+
+ std::vector<CMakeVariable> cmake_args
+ {
+ { L"CMD", L"CREATE" },
+ { L"PORT", port_name },
+ { L"URL", url }
+ };
- // Space OR define the FILENAME with proper spacing
- std::wstring custom_filename = L" ";
if (args.command_arguments.size() >= 3)
{
const std::string& zip_file_name = args.command_arguments.at(2);
Checks::check_exit(!Files::has_invalid_chars_for_filesystem(zip_file_name),
R"(Filename cannot contain invalid chars %s, but was %s)",
Files::FILESYSTEM_INVALID_CHARACTERS, zip_file_name);
- custom_filename = Strings::wformat(LR"( -DFILENAME="%s" )", Strings::utf8_to_utf16(zip_file_name));
+ cmake_args.push_back({ L"FILENAME", zip_file_name });
}
- const std::wstring cmdline = Strings::wformat(LR"(cmake -DCMD=CREATE -DPORT=%s -DURL=%s%s-P "%s")",
- Strings::utf8_to_utf16(port_name),
- Strings::utf8_to_utf16(args.command_arguments.at(1)),
- custom_filename,
- paths.ports_cmake.generic_wstring());
-
- exit(System::cmd_execute(cmdline));
+ const std::wstring cmd_launch_cmake = make_cmake_cmd(cmake_exe, paths.ports_cmake, cmake_args);
+ exit(System::cmd_execute(cmd_launch_cmake));
}
}

`create`: Use make_cmake_cmd() and paths.get_cmake_exe()