I have a problem with adding googletests to CMakeLists.txt.
The problem is "Error:include could not find load file: GoogleTest".
I have installed google tests using the commands:
- sudo apt-get install libgtest-dev
- sudo apt-get install cmake # install cmake
- cd /usr/src/gtest
- sudo cmake CMakeLists.txt
- sudo make
- sudo cp *.a /usr/lib
These commands I took from here. There is my CMakeLists.txt:
cmake_minimum_required(VERSION 3.6.2)
set(CMAKE_CXX_COMPILER clang++)
set(CMAKE_CXX_STANDARD 17)
project(compiler)
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
find_package(FLEX REQUIRED)
FLEX_TARGET(lexer src/lexer.fl ${CMAKE_CURRENT_BINARY_DIR}/lexer.cpp)
find_package(GTest REQUIRED)
include(GoogleTest) <- There is a problem!
add_executable(run_tests src/tests/test.cpp src/main.h ${FLEX_lexer_OUTPUTS})
target_include_directories(run_tests PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(run_tests ${GTEST_LIBRARIES} stdc++fs)
#gtest_add_tests(TARGET run_tests)
add_executable(compiler src/main.h src/main.cpp src/common.h ${FLEX_lexer_OUTPUTS})
I will be really appreciate if you give me an advice!
include(GoogleTest)
in the tutorial you refer to. Instead, the tutorial suggests to use another way for link with Google Test libraries. – Tsyvarev