I’d like to tightly integrate my test suite with Visual Studio 2019. If I understand correctly, the correct way is to reference one project to another:
So how would one do equivalent using cmake ? For the example let’s consider the simple setup:
> cat .\src\CMakeLists.txt
add_library(foo SHARED foo.c foo.h)
target_include_directories(
foo PUBLIC $<BUILD_INTERFACE:${p_SOURCE_DIR}/src>
)
and tests directory is:
> cat .\tests\CMakeLists.txt
add_executable(footest footest.c)
target_link_libraries(footest PRIVATE foo)
add_test(NAME footest COMMAND footest)
By default footest.exe
will fail to execute since foo.dll
will be located in a different directory.
Please no suggestion about tweaking the PATH
in a set_tests_properties
call or putting all *.dll inside a single CMAKE_RUNTIME_OUTPUT_DIRECTORY
. I’d really like to reference projects so that Visual Studio copies the Debug/Release/… dll for me (I’d prefer a solution without an explicit copy in a POST_BUILD custom command).
Currently:
with:
Thanks