I have
ExternalProjectAdd(googletest ......)
...
add_library(gtest_main UNKNOWN IMPORTED)
set_target_properties(gtest_main PROPERTIES
"IMPORTED_LOCATION" ${binary_dir}/googlemock/gtest/libgtest_main.a
)
...
add_executable(sometest somefile.cpp)
target_link_library(sometest gtest_main)
add_dependencies(sometest googletest)
But evidently stating the dependency of the executable sometest
on googletest
does not actually require the ExternalProject_Add
's build command to be invoked prior to the build command for sometest
.
If I run ninja
then it complains that it can't find libgtest_main.a
. But if you call ninja googletest && ninja sometest
it works just fine.
So, how do you tell cmake
that sometest
depends on googletest
's build command being invoked?