diff --git a/CMakeLists.txt b/CMakeLists.txt index 18cb1c5..5fa79d5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -252,6 +252,9 @@ if (SQLITECPP_BUILD_TESTS) # add the subdirectory containing the CMakeLists.txt for the gtest library # TODO: under Linux, uses libgtest-dev if found # TODO: move to the new googletest Github repository + if (NOT EXISTS "${PROJECT_SOURCE_DIR}/googletest/CMakeLists.txt") + message(FATAL_ERROR "Missing 'googletest' submodule! Either use 'git init submodule' and 'git update submodule' to get googletest according to the README, or deactivate unit tests with -DSQLITECPP_BUILD_TESTS=OFF") + endif () add_subdirectory(googletest) include_directories("${PROJECT_SOURCE_DIR}/googletest/include") diff --git a/build.bat b/build.bat index 02d476f..895096b 100644 --- a/build.bat +++ b/build.bat @@ -7,11 +7,19 @@ cd build @REM Generate a Visual Studio solution for latest version found cmake -DSQLITECPP_BUILD_EXAMPLES=ON -DSQLITECPP_BUILD_TESTS=ON .. +if ERRORLEVEL 1 goto onError @REM Build default configuration (ie 'Debug') cmake --build . +if ERRORLEVEL 1 goto onError @REM Build and run tests ctest --output-on-failure +if ERRORLEVEL 1 goto onError cd .. +exit + +:onError +@echo An error occured! +cd .. \ No newline at end of file diff --git a/build.sh b/build.sh index 92b46c7..4388be9 100755 --- a/build.sh +++ b/build.sh @@ -1,12 +1,18 @@ +#!/bin/sh # Copyright (c) 2012-2016 Sébastien Rombauts (sebastien.rombauts@gmail.com) # # Distributed under the MIT License (MIT) (See accompanying file LICENSE.txt # or copy at http://opensource.org/licenses/MIT) + +# exit on firts error +set -e + mkdir -p build cd build # Generate a Makefile for GCC (or Clang, depanding on CC/CXX envvar) cmake -DCMAKE_BUILD_TYPE=Debug -DSQLITECPP_USE_GCOV=OFF -DSQLITECPP_BUILD_EXAMPLES=ON -DSQLITECPP_BUILD_TESTS=ON .. +if [ $? != 0 ] ; then exit # Build (ie 'make') cmake --build .