From 6cd9ff808342c761cfdd709a1307ff01d820fc16 Mon Sep 17 00:00:00 2001 From: tastytea Date: Tue, 1 Jan 2019 09:29:16 +0100 Subject: [PATCH] Abort on compilation error. --- CMakeLists.txt | 2 +- src/main.cpp | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index eb983df..ef753cd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required (VERSION 3.2) project(compilescript - VERSION 0.3.1 + VERSION 0.3.2 LANGUAGES CXX ) diff --git a/src/main.cpp b/src/main.cpp index 5c2be6b..d3a58d9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -200,8 +200,13 @@ int main(int argc, char *argv[]) return 1; } - std::system((compiler + " " + source.string() + " " + compiler_arguments - + " -o " + binary.string()).c_str()); + int ret = std::system((compiler + " " + source.string() + " " + + compiler_arguments + " -o " + binary.string()).c_str()); + if (ret != 0) + { + cerr << "ERROR: Compilation failed.\n"; + return 1; + } } execv(binary.c_str(), &argv[1]);