Add an explicit CMake error message on missing googletest submodule

- build.bat now exit on error instead of trying to build or run tests
This commit is contained in:
Sébastien Rombauts 2016-07-18 18:13:30 +02:00
parent 223c14139b
commit 2b36f52b6e
3 changed files with 17 additions and 0 deletions

View File

@ -252,6 +252,9 @@ if (SQLITECPP_BUILD_TESTS)
# add the subdirectory containing the CMakeLists.txt for the gtest library # add the subdirectory containing the CMakeLists.txt for the gtest library
# TODO: under Linux, uses libgtest-dev if found # TODO: under Linux, uses libgtest-dev if found
# TODO: move to the new googletest Github repository # 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) add_subdirectory(googletest)
include_directories("${PROJECT_SOURCE_DIR}/googletest/include") include_directories("${PROJECT_SOURCE_DIR}/googletest/include")

View File

@ -7,11 +7,19 @@ cd build
@REM Generate a Visual Studio solution for latest version found @REM Generate a Visual Studio solution for latest version found
cmake -DSQLITECPP_BUILD_EXAMPLES=ON -DSQLITECPP_BUILD_TESTS=ON .. cmake -DSQLITECPP_BUILD_EXAMPLES=ON -DSQLITECPP_BUILD_TESTS=ON ..
if ERRORLEVEL 1 goto onError
@REM Build default configuration (ie 'Debug') @REM Build default configuration (ie 'Debug')
cmake --build . cmake --build .
if ERRORLEVEL 1 goto onError
@REM Build and run tests @REM Build and run tests
ctest --output-on-failure ctest --output-on-failure
if ERRORLEVEL 1 goto onError
cd .. cd ..
exit
:onError
@echo An error occured!
cd ..

View File

@ -1,12 +1,18 @@
#!/bin/sh
# Copyright (c) 2012-2016 Sébastien Rombauts (sebastien.rombauts@gmail.com) # Copyright (c) 2012-2016 Sébastien Rombauts (sebastien.rombauts@gmail.com)
# #
# Distributed under the MIT License (MIT) (See accompanying file LICENSE.txt # Distributed under the MIT License (MIT) (See accompanying file LICENSE.txt
# or copy at http://opensource.org/licenses/MIT) # or copy at http://opensource.org/licenses/MIT)
# exit on firts error
set -e
mkdir -p build mkdir -p build
cd build cd build
# Generate a Makefile for GCC (or Clang, depanding on CC/CXX envvar) # 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 .. cmake -DCMAKE_BUILD_TYPE=Debug -DSQLITECPP_USE_GCOV=OFF -DSQLITECPP_BUILD_EXAMPLES=ON -DSQLITECPP_BUILD_TESTS=ON ..
if [ $? != 0 ] ; then exit
# Build (ie 'make') # Build (ie 'make')
cmake --build . cmake --build .