// -*- c++ -*- #include #include #include namespace { std::vector eval_mocs(const std::string& path, const std::vector>& moc_list) { std::vector sources; for(const auto& moc : moc_list) { std::filesystem::path input(moc.first); std::filesystem::path output(moc.second); std::filesystem::path fspath(path); if(!std::filesystem::exists(fspath / input)) { std::cerr << "Missing moc input file: " << input.string() << '\n'; exit(1); } if(!std::filesystem::exists(path / output) || std::filesystem::last_write_time(path / input) > std::filesystem::last_write_time(path / output)) { std::string cmd = "cd \"" + path + "\"; moc "; cmd += "-o \"" + output.string() + "\" \"" + input.string() + "\""; std::cerr << cmd << "\n"; auto ret = system(cmd.data()); if(ret != 0) { std::cerr << "moc generation failed: " << cmd << '\n'; exit(ret); } } sources.push_back((path / output).string()); } return sources; } BuildConfigurations myConfigs() { // // Qookie-cast client // BuildConfiguration qookie = { .target = "qookie", // output filename .sources = { "src/qookie.cc", "src/database.cc", "src/database_gourmet.cc", "src/database_krecipes.cc", "src/mainwindow.cc", "src/viewer.cc", "src/client.cc", }, .flags = { .cxxflags = { "-fPIC", "-Wall", "-Werror", "-Wextra",// "-Wconversion", "-g", }, }, .externals = { "qt", "sqlite" }, }; std::vector qookie_mocs = eval_mocs("src", { { "mainwindow.h", "moc_mainwindow.cc"}, { "viewer.h", "moc_viewer.cc"}, { "client.h", "moc_client.cc"}, }); for(const auto& moc : qookie_mocs) { qookie.sources.push_back(moc); } // // Qookie-cast client // BuildConfiguration qookie_cast_client = { .target = "qookie-cast-client", // output filename .sources = { "src/qookie-cast-client.cc", }, .flags = { .cxxflags = { "-fPIC", "-Wall", "-Werror", "-Wextra",// "-Wconversion", "-g", }, }, .externals = {"qt"}, }; std::vector qookie_cast_client_mocs = eval_mocs("src", { { "qookie-cast-client.h", "moc_qookie-cast-client.cc"}, }); for(const auto& moc : qookie_cast_client_mocs) { qookie_cast_client.sources.push_back(moc); } return {qookie, qookie_cast_client}; } ExternalConfigurations ctorExtConfigs() { return { { .name = "qt", .external = ExternalManual{ .flags = { .cxxflags = { "-I/usr/include/qt5", }, .ldflags = { "-lQt5Core", "-lQt5Network", "-lQt5Gui", "-lQt5Widgets", }, }, }, }, { .name = "sqlite", .external = ExternalManual{ .flags = { .ldflags = { "-lsqlite3", }, }, }, }, }; } } // Register callbacks REG(myConfigs); REG(ctorExtConfigs);