Add possibility to specify host for VS generator.

This commit is contained in:
Mikaël Capelle
2022-05-15 11:30:13 +02:00
parent 3e8f5b83e2
commit 3f4eed9e2a
5 changed files with 34 additions and 1 deletions
+1
View File
@@ -15,6 +15,7 @@ github_key =
[cmake]
install_message = never
host =
[aliases]
super = cmake_common modorganizer* githubpp
+5
View File
@@ -756,6 +756,11 @@ conf_cmake::cmake_constant conf_cmake::install_message() const
return read_cmake_constant("install_message", { ALWAYS, LAZY, NEVER });
}
std::string conf_cmake::host() const
{
return details::get_string(name(), "host");
}
conf_cmake::cmake_constant conf_cmake::read_cmake_constant(
std::string_view key, std::vector<cmake_constant> const& allowed) const
{
+9
View File
@@ -192,8 +192,17 @@ public:
public:
conf_cmake();
// specify the value for CMAKE_INSTALL_MESSAGE
//
cmake_constant install_message() const;
// specify the toolset host configuration, if any, this is equivalent
// to -T host=XXX on the command line
//
// an empty string means no host configured
//
std::string host() const;
private:
cmake_constant read_cmake_constant(
std::string_view key, std::vector<cmake_constant> const& allowed) const;
+11 -1
View File
@@ -145,7 +145,8 @@ void cmake::do_generate()
// string
p
.arg("-G", "\"" + g.name + "\"")
.arg(g.get_arch(arch_));
.arg(g.get_arch(arch_))
.arg(g.get_host(conf().cmake().host()));
}
else
{
@@ -240,6 +241,15 @@ std::string cmake::gen_info::get_arch(arch a) const
}
}
std::string cmake::gen_info::get_host(std::string_view conf_host) const
{
if (conf_host.empty()) {
return {};
}
return "-T host=" + std::string{ conf_host };
}
std::string cmake::gen_info::output_dir(arch a) const
{
switch (a)
+8
View File
@@ -135,6 +135,14 @@ private:
//
std::string get_arch(arch a) const;
// for generator that supports it, returns a toolset configuration to set
// the host as specified in the configuration
//
// for VS generator, this returns "-T host=XXX" if conf_host is not empty,
// otherwise returns an empty string
//
std::string get_host(std::string_view conf_host) const;
// return either `dir` for 64-bit or `dir` + "_32" for 32-bit
//
std::string output_dir(arch a) const;