diff --git a/mob.ini b/mob.ini index bf21190..943895b 100644 --- a/mob.ini +++ b/mob.ini @@ -15,6 +15,7 @@ github_key = [cmake] install_message = never +host = [aliases] super = cmake_common modorganizer* githubpp diff --git a/src/core/conf.cpp b/src/core/conf.cpp index 4c7d4d2..be9bc4e 100644 --- a/src/core/conf.cpp +++ b/src/core/conf.cpp @@ -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 const& allowed) const { diff --git a/src/core/conf.h b/src/core/conf.h index 2090018..5c1fce7 100644 --- a/src/core/conf.h +++ b/src/core/conf.h @@ -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 const& allowed) const; diff --git a/src/tools/cmake.cpp b/src/tools/cmake.cpp index d7e0f2a..aa6faa5 100644 --- a/src/tools/cmake.cpp +++ b/src/tools/cmake.cpp @@ -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) diff --git a/src/tools/cmake.h b/src/tools/cmake.h index 021e8df..62f6811 100644 --- a/src/tools/cmake.h +++ b/src/tools/cmake.h @@ -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;