Skip to content

make add_test smart enough to run tests on DLL platforms

This is related to #24129 and #25684

To get my tests to run on Windows, I need the following boilerplate; CMake should take care of that for me.

    add_test(NAME ${test_target}
      COMMAND ${test_target})

    # When $ENV{PATH} is interpreted as a list on Windows, trailing backslashes in elements
    # (e.g. "C:\path\to\foo\;C:\another\path\...") will end up causing semicolons to be escaped.
    string(REPLACE "\\" "/" path "$ENV{PATH}")

    # Escape the semicolons when forming the environment setting.  As explained in
    # https://stackoverflow.com/a/59866840/125349, “this is not the last place the list will be used
    # (and interpreted by CMake). [It] is then used to populate CTestTestfile.cmake, which is later
    # read by CTest to setup your test environment.”
    set_tests_properties(${test_target}
      PROPERTIES ENVIRONMENT "PATH=$<JOIN:$<TARGET_RUNTIME_DLL_DIRS:${test_target}>;${path},\\;>")
Edited by Dave Abrahams
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information