Hi,
Given the following simple CMakeLists.txt
with an added check that aborts if BUILD_TESTING
is set:
$ cat CMakeLists.txt
cmake_minimum_required(VERSION 3.12)
project(SimpleTest)
set(CMAKE_CXX_STANDARD 14)
if(BUILD_TESTING)
message(FATAL_ERROR "BUILD_TESTING is set. Aborting.")
endif()
add_executable(SimpleTest main.cpp)
When building manually it works successfully:
$ mkdir build
$ cd build
$ cmake ..
-- The C compiler identification is GNU 7.3.0
-- The CXX compiler identification is GNU 7.3.0
-- Check for working C compiler: /usr/bin/gcc-7
-- Check for working C compiler: /usr/bin/gcc-7 -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/g++-7
-- Check for working CXX compiler: /usr/bin/g++-7 -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /SimpleTest/build
$
$ make
Scanning dependencies of target SimpleTest
[ 50%] Building CXX object CMakeFiles/SimpleTest.dir/main.cpp.o
[100%] Linking CXX executable SimpleTest
[100%] Built target SimpleTest
However, if building using cget build
(or cget install
), the BUILD_TESTING
flag seems to somehow have been set, causing the command to abort:
$ cd ..
$ rm build -r
$ cget build
-- The C compiler identification is GNU 7.3.0
-- The CXX compiler identification is GNU 7.3.0
-- Check for working C compiler: /usr/bin/gcc-7
-- Check for working C compiler: /usr/bin/gcc-7 -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/g++-7
-- Check for working CXX compiler: /usr/bin/g++-7 -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at CMakeLists.txt:7 (message):
BUILD_TESTING is set. Aborting.
-- Configuring incomplete, errors occurred!
See also "/SimpleTest/cget/cget/build/_url_L2hvbWUvdGhvdWdodG9uL0RvY3VtZW50cy9Db2RpbmcvQ2dldFByb2plY3RzL1NpbXBsZVRlc3Q_/build/CMakeFiles/CMakeOutput.log".
Command failed: ['/home/linuxbrew/.linuxbrew/bin/cmake', '-DCMAKE_TOOLCHAIN_FILE=/SimpleTest/cget/cget/cget.cmake', u'/SimpleTest', '-DCGET_CMAKE_DIR=/.local/lib/python2.7/site-packages/cget/cmake', '-DCGET_CMAKE_ORIGINAL_SOURCE_FILE=/SimpleTest/__cget_original_cmake_file__.cmake', '-DBUILD_TESTING=On', '-DCMAKE_BUILD_TYPE=Release']
Failed to build package .
$
(It can also be clearly seen in the echo of the failed command above that -DBUILD_TESTING
is explicitly being set in the command arguments being executed.)
Is there a way to configure this default? Or is it simply a bug?
(For the record, it currently makes it quite tricky to setup a project with optional tests.)
Thanks!