I am trying to build a simple test project using gTest as a dependency. My conanfile.txt looks like:
[requires]
gtest/1.13.0
[generators]
CMakeToolchain
CMakeDeps
[layout]
cmake_layout
Installing the gTest dependency works fine with:
conan install . mytests/1.0.0@
The folder with the conanfile.txt also contains a simple CMakeLists.txt:
project(my_test)
find_package(GTest REQUIRED)
add_executable(my_test main.cpp)
target_link_libraries(my_test GTest::gtest_main)
include(GoogleTest)
gtest_discover_tests(my_test)
At the build step it fails with:
$ conan build .
ERROR: Conanfile not found at /home/user/myTest/conanfile.py
Is it really necessary to create a full blown conanfile.py or am I missing something?
Edit: The goal would be to just build and run the project. No need to package my_test in the end as a conan package.
When I try to use cmake to build after installing the dependencies, cmake has issues finding the conan generated GTestConfig.cmake files. Are there any suggestions how to let CMake know where to find the cmake config files?
- Extending the CMAKE_PREFIX_PATH? I don't really want to make my CMakeLists.txt file dependent on locations to my local conan cache
- Any conan virtualrunenv generator
- Some other way?
I would be interested to know which way you suggest to build after running conan install
.
cmake --build --preset release
seems to work pretty well without further modifications.