Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions src/cmake_generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1378,10 +1378,19 @@ void generate_cmake(const char *path, const parser::Project *parent_project) {
}
}

// Fetch the generated CMakeLists.txt output from the stringstream buffer
auto generated_cmake = ss.str();

// Make sure the file ends in a single newline
while (!generated_cmake.empty() && std::isspace(generated_cmake.back())) {
generated_cmake.pop_back();
}
generated_cmake += '\n';

// Generate CMakeLists.txt
auto list_path = fs::path(path) / "CMakeLists.txt";

auto should_regenerate = [&list_path, &ss]() {
auto should_regenerate = [&list_path, &generated_cmake]() {
if (!fs::exists(list_path))
return true;

Expand All @@ -1391,11 +1400,11 @@ void generate_cmake(const char *path, const parser::Project *parent_project) {
}

std::string data((std::istreambuf_iterator<char>(ifs)), std::istreambuf_iterator<char>());
return data != ss.str();
return data != generated_cmake;
}();

if (should_regenerate) {
create_file(list_path, ss.str());
create_file(list_path, generated_cmake);
}

auto generate_subdir = [path, &project](const fs::path &sub) {
Expand Down
1 change: 0 additions & 1 deletion tests/CMakeLists.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.