Reputation: 523
I'm trying the following CMake cmakelist.txt file for executing tests for my school project:
cmake_minimum_required(VERSION 3.3)
project(ex2)
set(CMAKE_CXX_COMPILER "/usr/local/Cellar/gcc/5.2.0/bin/g++-5")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra -Wall -std=c++11")
find_package(CxxTest)
if(CXXTEST_FOUND)
include_directories(${CXXTEST_INCLUDE_DIR})
enable_testing()
CXXTEST_ADD_TEST(bag_of_words_runner tests/bag_of_words_runner.cpp tests/BagOfWordsTests.h)
CXXTEST_ADD_TEST(parsing_runner tests/parsing_runner.cpp tests/ParsingTests.h)
target_link_libraries(bag_of_words_runner ex2)
target_link_libraries(parsing_runner ex2)
endif()
set(SOURCE_FILES MIR.cpp SongEntry.cpp BagOfWords.cpp Parameters.cpp parsing)
add_executable(ex2 ${SOURCE_FILES})
But I get following error:
luftzug$ cmake --build /Users/luftzug/Library/Caches/clion11/cmake/generated/c7799756/c7799756/Debug --target bag_of_words_runner -- -j 4[ 33%] Generating tests/bag_of_words_runner.cpp
File "/usr/local/bin/cxxtestgen", line 2
PYTHONPATH="/usr/local/Cellar/cxxtest/4.4/lib/python2.7/site-packages:/usr/local/Cellar/cxxtest/4.4/lib/python2.7/site-packages" exec "/usr/local/Cellar/cxxtest/4.4/libexec/bin/cxxtestgen" "$@"
^
SyntaxError: invalid syntax
make[3]: *** [tests/bag_of_words_runner.cpp] Error 1
make[2]: *** [CMakeFiles/bag_of_words_runner.dir/all] Error 2
make[1]: *** [CMakeFiles/bag_of_words_runner.dir/rule] Error 2
make: *** [bag_of_words_runner] Error 2
I had tried running it outside of CLion just to rule that out. I can run cxxtestgen from the command line with no trouble at all.
Any idea or a workaround? I need to be able to run these unit tests, preferably from using CMake (to enjoy the benefits of it's integration with CLion).
Upvotes: 0
Views: 711
Reputation: 179
It happens that FindCxxTest thought /usr/local/bin/cxxtestgen
is a python script. However it is not; maybe previously it was. The cmake module is not yet up to date. Here's a temporary fix:
find_package(CxxTest)
set(CXXTEST_TESTGEN_INTERPRETER bash) # FindCxxTest module bug
CXXTEST_ADD_TEST(...)
Upvotes: 0