Skip to content

Commit 634908c

Browse files
authored
Merge pull request #97 from build-cpp/cmkr-init-regression
Fix a regression where cmkr init wouldn't create any source files
2 parents e650073 + 33911f3 commit 634908c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/cmake_generator.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,9 @@ void generate_project(const std::string &type) {
209209
throw std::runtime_error("Cannot initialize a project when cmake.toml already exists!");
210210
}
211211

212+
// Check if the folder is empty before creating any files
213+
auto is_empty = fs::is_empty(fs::current_path());
214+
212215
// Automatically generate .gitattributes to not skew the statistics of the repo
213216
generate_gitfile(".gitattributes", {"/**/CMakeLists.txt linguist-generated", "/**/cmkr.cmake linguist-vendored"});
214217

@@ -220,7 +223,7 @@ void generate_project(const std::string &type) {
220223
{"@type", type},
221224
};
222225

223-
if (!fs::is_empty(fs::current_path())) {
226+
if (!is_empty) {
224227
// Make a backup of an existing CMakeLists.txt if it exists
225228
std::error_code ec;
226229
fs::rename("CMakeLists.txt", "CMakeLists.txt.bak", ec);

0 commit comments

Comments
 (0)