Differentiate between root and subdirectory generation

vcpkg-wip
Duncan Ogilvie 4 years ago
parent 7828461a42
commit f9de5c67ef

@ -6,7 +6,7 @@ namespace gen {
int generate_project(const char *typ); int generate_project(const char *typ);
int generate_cmake(const char *path); int generate_cmake(const char *path, bool root = true);
} // namespace gen } // namespace gen
} // namespace cmkr } // namespace cmkr

@ -205,7 +205,7 @@ struct Command {
} }
}; };
int generate_cmake(const char *path) { int generate_cmake(const char *path, bool root) {
if (fs::exists(fs::path(path) / "cmake.toml")) { if (fs::exists(fs::path(path) / "cmake.toml")) {
cmake::CMake cmake(path, false); cmake::CMake cmake(path, false);
std::stringstream ss; std::stringstream ss;
@ -243,6 +243,7 @@ int generate_cmake(const char *path) {
} }
// TODO: make this a setting in the toml? // TODO: make this a setting in the toml?
if(root) {
comment("Regenerate CMakeLists.txt file when necessary"); comment("Regenerate CMakeLists.txt file when necessary");
cmd("include")("cmkr.cmake", "OPTIONAL", "RESULT_VARIABLE", "CMKR_INCLUDE_RESULT").endl(); cmd("include")("cmkr.cmake", "OPTIONAL", "RESULT_VARIABLE", "CMKR_INCLUDE_RESULT").endl();
@ -253,6 +254,7 @@ int generate_cmake(const char *path) {
cmd("cmake_minimum_required")("VERSION", cmake.cmake_version).endl(); cmd("cmake_minimum_required")("VERSION", cmake.cmake_version).endl();
cmd("set_property")("GLOBAL", "PROPERTY", "USE_FOLDERS", "ON").endl(); cmd("set_property")("GLOBAL", "PROPERTY", "USE_FOLDERS", "ON").endl();
}
// TODO: remove support and replace with global compile-features // TODO: remove support and replace with global compile-features
if (!cmake.cppflags.empty()) { if (!cmake.cppflags.empty()) {
@ -540,7 +542,7 @@ int generate_cmake(const char *path) {
for (const auto &sub : cmake.subdirs) { for (const auto &sub : cmake.subdirs) {
if (fs::exists(fs::path(sub) / "cmake.toml")) if (fs::exists(fs::path(sub) / "cmake.toml"))
generate_cmake(sub.c_str()); generate_cmake(sub.c_str(), false);
} }
} else { } else {
throw std::runtime_error("No cmake.toml found!"); throw std::runtime_error("No cmake.toml found!");

Loading…
Cancel
Save