File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -199,6 +199,7 @@ struct Project {
199199
200200 Project (const Project *parent, const std::string &path, bool build);
201201 const Project *root () const ;
202+ bool cmake_minimum_version (int major, int minor) const ;
202203};
203204
204205bool is_root_path (const std::string &path);
Original file line number Diff line number Diff line change @@ -741,6 +741,26 @@ const Project *Project::root() const {
741741 return root;
742742}
743743
744+ bool Project::cmake_minimum_version (int major, int minor) const {
745+ // NOTE: this code is like pulling teeth, sorry
746+ auto root_version = root ()->cmake_version ;
747+ puts (root_version.c_str ());
748+ auto range_index = root_version.find (" ..." );
749+ if (range_index != std::string::npos) {
750+ root_version.resize (range_index);
751+ }
752+
753+ auto period_index = root_version.find (' .' );
754+ auto root_major = atoi (root_version.substr (0 , period_index).c_str ());
755+ int root_minor = 0 ;
756+ if (period_index != std::string::npos) {
757+ auto end_index = root_version.find (' .' , period_index + 1 );
758+ root_minor = atoi (root_version.substr (period_index + 1 , end_index).c_str ());
759+ }
760+
761+ return std::tie (root_major, root_minor) >= std::tie (major, minor);
762+ }
763+
744764bool is_root_path (const std::string &path) {
745765 const auto toml_path = fs::path (path) / " cmake.toml" ;
746766 if (!fs::exists (toml_path)) {
You can’t perform that action at this time.
0 commit comments