Running test from cmake on windows

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Running test from cmake on windows

Federico Kircheis
Hello, I'm having some trouble understanding how I can execute my test
suite uniformly on all platforms.

On GNU/Linux (with `make`), I can execute

----
cmake -S "$PROJDIR" -B "$BUILDDIR" -DCMAKE_BUILD_TYPE="$build_type"
-DBUILD_TESTING=ON
cmake --build "$BUILDDIR"
cmake --build "$BUILDDIR" --config "$build_type" --target test --
ARGS="--progress"
----

(PROJDIR points to the project directory, BUILDDIR the build directory
and build_type to Release, Debug and so on)

If I try to execute on Windows (with msvc and msbuild) the same
commands, I get following error:

--
MSBUILD : error MSB1008: Only one project can be specified.
Switch: ARGS=--progress
--

Which is very misleading.
Removing `-- ARGS="--progress"` from the invocation yields

--
MSBUILD : error MSB1009: Project file does not exist.
Switch: test.vcxproj
--

Looking at the generated projects, I realized there is a "RUN_TESTS" target:

----
cmake -S "$PROJDIR" -B "$BUILDDIR" -DBUILD_TESTING=ON
cmake --build "$BUILDDIR"
cmake --build "$BUILDDIR" --config "$build_type" --target RUN_TESTS --
ARGS="--progress"
----

still yields

--
MSBUILD : error MSB1008: Only one project can be specified.
Switch: ARGS=--progress
--

This time removing `-- ARGS="--progress"` finally runs the tests:

----
cmake -S "$PROJDIR" -B "$BUILDDIR"  -DBUILD_TESTING=ON
cmake --build "$BUILDDIR"
cmake --build "$BUILDDIR" --config "$build_type" --target RUN_TESTS
----

So there are 2 questions, I'm unsure if those are bugs.

1)
Is there a target that I can use on any platform for running the tests,
or do I need to handle every platform/build-system differently?
RUN_TESTS is not a valid target with `make`.

2)
How can I pass `ARGS="--progress"` on windows.
This parameter is accepted by `ctest` on windows too, so it should be valid.

Regards,

Federico
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake