Skip to content

Commit 2b36f52

Browse files
committed
Add an explicit CMake error message on missing googletest submodule
- build.bat now exit on error instead of trying to build or run tests
1 parent 223c141 commit 2b36f52

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,9 @@ if (SQLITECPP_BUILD_TESTS)
252252
# add the subdirectory containing the CMakeLists.txt for the gtest library
253253
# TODO: under Linux, uses libgtest-dev if found
254254
# TODO: move to the new googletest Github repository
255+
if (NOT EXISTS "${PROJECT_SOURCE_DIR}/googletest/CMakeLists.txt")
256+
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")
257+
endif ()
255258
add_subdirectory(googletest)
256259
include_directories("${PROJECT_SOURCE_DIR}/googletest/include")
257260

build.bat

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,19 @@ cd build
77

88
@REM Generate a Visual Studio solution for latest version found
99
cmake -DSQLITECPP_BUILD_EXAMPLES=ON -DSQLITECPP_BUILD_TESTS=ON ..
10+
if ERRORLEVEL 1 goto onError
1011

1112
@REM Build default configuration (ie 'Debug')
1213
cmake --build .
14+
if ERRORLEVEL 1 goto onError
1315

1416
@REM Build and run tests
1517
ctest --output-on-failure
18+
if ERRORLEVEL 1 goto onError
1619

1720
cd ..
21+
exit
22+
23+
:onError
24+
@echo An error occured!
25+
cd ..

build.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
1+
#!/bin/sh
12
# Copyright (c) 2012-2016 Sébastien Rombauts ([email protected])
23
#
34
# Distributed under the MIT License (MIT) (See accompanying file LICENSE.txt
45
# or copy at http://opensource.org/licenses/MIT)
6+
7+
# exit on firts error
8+
set -e
9+
510
mkdir -p build
611
cd build
712

813
# Generate a Makefile for GCC (or Clang, depanding on CC/CXX envvar)
914
cmake -DCMAKE_BUILD_TYPE=Debug -DSQLITECPP_USE_GCOV=OFF -DSQLITECPP_BUILD_EXAMPLES=ON -DSQLITECPP_BUILD_TESTS=ON ..
15+
if [ $? != 0 ] ; then exit
1016

1117
# Build (ie 'make')
1218
cmake --build .

0 commit comments

Comments
 (0)