Upon generating a Vistual Studio project from a CMake build file, CMake generates a solution with a sub-project called RUN_TESTS.vcproj that runs all unit tests a开发者_运维知识库s a post build action.
How can you invoke the RUN_TESTS from the command prompt using msbuild.exe?
Running msbuild RUN_TESTS.vcproj
from the build directory does not work.
Under UNIX you would do a simple make test
for Makefiles generated by CMake.
There seems to be no way to run the tests through MSBuild.exe. You can invoke the tests with the executable ctest.exe which is part of the CMake installation:
ctest -C "Debug"
This will run the tests associated with the project's "Debug" configuration.
You need open an "Administrator: Visual Studio Command Pormpt" that you can find under the Visual Studio tool. Then, running "msbuild RUN_TESTS.vcproj" should work.
You could also use CMake to build:
cd <path_to_build_dir>
cmake.exe --build . --target RUN_TESTS --config release
The --build
functionality of CMake wraps around the build-system you're using, so in your case it would use MsBuild, on Linux it would use g++ or similar. It's a good solution if you want to provide portable build-scripts for your project.
Admittedly you would rather use the above for building the INSTALL target. CTest is the tool of choice in your case.
精彩评论