Using conan for unit tests #25
-
Whats the preferred way to us conan libraries for unit tests. For example, my only dependencies for my library tests are the library itself and boost::ut. My previous naive approach for this was just to have a
And my cmake_minimum_required(VERSION 3.1...3.21)
project(test VERSION 0.0.1 LANGUAGES CXX)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR})
list(APPEND CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR})
find_package(libarmcortex CONFIG REQUIRED)
find_package(ut CONFIG REQUIRED)
add_executable(${PROJECT_NAME}
system_timer.test.cpp
dwt_counter.test.cpp
interrupt.test.cpp
main.test.cpp)
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_20)
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_EXTENSIONS OFF)
target_compile_definitions(${PROJECT_NAME} PRIVATE -DPLATFORM=test)
target_link_libraries(${PROJECT_NAME} PRIVATE
libarmcortex::libarmcortex
boost::ut) I ran |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
The Conan example from the README shows you how to integrate with Conan. It also shows you how to use a dev dependency, such as doctest. To costumize how Conan installs your dependencies, you can edit the conan.cmake file. If you follow the example, then you have an experience similar to vcpkg: cmake --preset=dev-unix # the preset also has the Conan code
cmake --build build/dev-unix
ctest --test-dir build/dev-unix |
Beta Was this translation helpful? Give feedback.
The Conan example from the README shows you how to integrate with Conan. It also shows you how to use a dev dependency, such as doctest. To costumize how Conan installs your dependencies, you can edit the conan.cmake file.
If you follow the example, then you have an experience similar to vcpkg:
cmake --preset=dev-unix # the preset also has the Conan code cmake --build build/dev-unix ctest --test-dir build/dev-unix