-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error in test\download_test_data.vcxproj custom build step when compiling with Visual Studio 2019 16.7.7 msbuild on Windows 10 #2593
Comments
This is strange, because this job works without problems: https://github.com/nlohmann/json/runs/1679595437?check_suite_focus=true (Windows Server 2019) |
I tested the commands that are executed in the job locally and you are correct, there is no error, because in the build step cmake --build build --parallel 10 the folder |
The problem is line 13 of
Here for Visual Studio Command Prompt on Windows it must be:
because there is no |
How would CMake be able to detect Windows Command Shell? |
It could be done same as with the find_program(TEST_COMMAND test)
if (TEST_COMMAND)
add_custom_target(download_test_data
COMMAND test -d json_test_data || ${GIT_EXECUTABLE} clone -c advice.detachedHead=false --branch v${JSON_TEST_DATA_VERSION} ${JSON_TEST_DATA_URL}.git --quiet --depth 1
COMMENT "Downloading test data from ${JSON_TEST_DATA_URL} (v${JSON_TEST_DATA_VERSION})"
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
else()
add_custom_target(download_test_data
COMMAND if exist json_test_data ${GIT_EXECUTABLE} clone -c advice.detachedHead=false --branch v${JSON_TEST_DATA_VERSION} ${JSON_TEST_DATA_URL}.git --quiet --depth 1
COMMENT "Downloading test data from ${JSON_TEST_DATA_URL} (v${JSON_TEST_DATA_VERSION})"
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
endif() |
I think I found a better way. @Andreas-Schniertshauer can you please try the fix of b2244a7 in branch https://github.com/nlohmann/json/tree/issue2593? |
It only works with the first CustomBuild:
...
Downloading test data from https://github.com/nlohmann/json_test_data (v3.0.0)
fatal: destination path 'json_test_data' already exists and is not an empty directory. Also when working in the Visual Studio GUI e.g. debugging
If you call this twice you also get the error because according to the |
This is strange, and I cannot reproduce this. I understand that once Can you please share the exact steps that lead to the problem (in particular, the CMake commands and in which paths you are executing what). |
I switched to the development branch #2593 and changed into the md build && cd build
cmake ..\ -D JSON_Install:BOOL=OFF -D JSON_ImplicitConversions:BOOL=OFF -D JSON_BuildTests:BOOL=ON
msbuild nlohmann_json.sln
msbuild nlohmann_json.sln I looked into the
|
Maybe you want to use cmake |
Hm. I have to check the code generated for Makefiles or Ninja - but it seems the generated code is wrong. |
#############################################
# Custom command for json_test_data
build json_test_data: CUSTOM_COMMAND
COMMAND = cmd.exe /C "cd /D json\build && "C:\Program Files\Git\bin\git.exe" clone -c advice.detachedHead=false --branch v3.0.0 https://github.com/nlohmann/json_test_data.git --quiet --depth 1"
DESC = Downloading test data from https://github.com/nlohmann/json_test_data (v3.0.0)
restat = 1 |
Yes, that's the download step. There should also be a target |
cmake -GNinja ..\ -D JSON_Install:BOOL=OFF -D JSON_ImplicitConversions:BOOL=OFF -D JSON_BuildTests:BOOL=ON
ninja
ninja json_test_data
[1/1] Downloading test data from https://github.com/nlohmann/json_test_data (v3.0.0)
ninja json_test_data
ninja: no work to do.
ninja test did work partially: 93% tests passed, 4 tests failed out of 60
Label Time Summary:
all = 1626.68 sec*proc (49 tests)
not_reproducible = 12.37 sec*proc (10 tests)
Total Test time (real) = 1639.47 sec
The following tests FAILED:
51 - cmake_import_configure (Failed)
52 - cmake_import_build (Not Run)
53 - cmake_import_minver_configure (Failed)
54 - cmake_import_minver_build (Not Run)
Errors while running CTest
FAILED: CMakeFiles/test.util |
51/60 Test #51: cmake_import_configure .......................***Failed 1.50 sec
Start 52: cmake_import_build
Failed test dependencies: cmake_import_configure
52/60 Test #52: cmake_import_build ...........................***Not Run 0.00 sec
Start 53: cmake_import_minver_configure
53/60 Test #53: cmake_import_minver_configure ................***Failed 1.09 sec
Start 54: cmake_import_minver_build
Failed test dependencies: cmake_import_minver_configure
54/60 Test #54: cmake_import_minver_build ....................***Not Run 0.00 sec |
Did you test this with branch Anyway, can you please share the output of the failed test? (Run |
Yes, cmake -GNinja ..\ -D JSON_Install:BOOL=OFF -D JSON_ImplicitConversions:BOOL=OFF -D JSON_BuildTests:BOOL=ON
ninja
ninja download_test_data
[1/1] Downloading test data from https://github.com/nlohmann/json_test_data (v3.0.0)
ninja download_test_data
ninja test Same result as with Here is the result of ...
51/60 Test #51: cmake_import_configure .......................***Failed 0.06 sec
CMake Error at json/build/nlohmann_jsonConfig.cmake:6 (include):
include could not find load file:
json/build/nlohmann_jsonTargets.cmake
Call Stack (most recent call first):
CMakeLists.txt:5 (find_package)
-- Configuring incomplete, errors occurred!
See also "json/build/test/cmake_import/CMakeFiles/CMakeOutput.log".
Start 52: cmake_import_build
Failed test dependencies: cmake_import_configure
52/60 Test #52: cmake_import_build ...........................***Not Run 0.00 sec
Start 53: cmake_import_minver_configure
53/60 Test #53: cmake_import_minver_configure ................***Failed 0.05 sec
CMake Error at json/build/nlohmann_jsonConfig.cmake:6 (include):
include could not find load file:
json/build/nlohmann_jsonTargets.cmake
Call Stack (most recent call first):
CMakeLists.txt:5 (find_package)
-- Configuring incomplete, errors occurred!
See also "json/build/test/cmake_import_minver/CMakeFiles/CMakeOutput.log".
Start 54: cmake_import_minver_build
Failed test dependencies: cmake_import_minver_configure
54/60 Test #54: cmake_import_minver_build ....................***Not Run 0.00 sec
Start 55: cmake_add_subdirectory_configure
55/60 Test #55: cmake_add_subdirectory_configure ............. Passed 0.09 sec
Start 56: cmake_add_subdirectory_build
56/60 Test #56: cmake_add_subdirectory_build ................. Passed 0.03 sec
Start 57: cmake_fetch_content_configure
57/60 Test #57: cmake_fetch_content_configure ................ Passed 1.39 sec
Start 58: cmake_fetch_content_build
58/60 Test #58: cmake_fetch_content_build .................... Passed 0.03 sec
Start 59: cmake_target_include_directories_configure
59/60 Test #59: cmake_target_include_directories_configure ... Passed 0.06 sec
Start 60: cmake_target_include_directories_build
60/60 Test #60: cmake_target_include_directories_build ....... Passed 0.03 sec
93% tests passed, 4 tests failed out of 60
Label Time Summary:
all = 1697.58 sec*proc (49 tests)
not_reproducible = 1.73 sec*proc (10 tests)
Total Test time (real) = 1699.82 sec
The following tests FAILED:
51 - cmake_import_configure (Failed)
52 - cmake_import_build (Not Run)
53 - cmake_import_minver_configure (Failed)
54 - cmake_import_minver_build (Not Run)
Errors while running CTest |
I currently see no way to fix this issue. The Windows builds run fine in the CI, and I have no way to reproduce the issue locally as I am not using MSVC. Happy to see PRs though. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
One could always rewrite this as a separate CMake script and run that via PR welcome, I'm sure. |
Yes, PR welcome. But it was time to clean up a bit. |
I get the following error in the CustomBuild step of test\download_test_data.vcxproj when compiling with Visual Studio 2019 16.7.7 Professional msbuild on Windows 10 2004 Professional:
CustomBuild:
Downloading test data from https://github.com/nlohmann/json_test_data (v3.0.0)
Der Befehl "test" ist entweder falsch geschrieben oder
konnte nicht gefunden werden.
Building Custom Rule ./test/CMakeLists.txt
The Command "test" is not found, because it does not exist on Windows.
"test -d json_test_data" is found in the CustomBuild step of the test\download_test_data.vcxproj project.
The problem is located in download_test_data.cmake "COMMAND test -d json_test_data || ...",
here "COMMAND if not exist json_test_data ..." should be used on Windows.
Please describe the steps to reproduce the issue.
What is the expected behavior?
No error.
And what is the actual behavior instead?
Step 6:
CustomBuild:
Downloading test data from https://github.com/nlohmann/json_test_data (v3.0.0)
Der Befehl "test" ist entweder falsch geschrieben oder
konnte nicht gefunden werden.
Building Custom Rule ./test/CMakeLists.txt
Step 7:
CustomBuild:
Downloading test data from https://github.com/nlohmann/json_test_data (v3.0.0)
Der Befehl "test" ist entweder falsch geschrieben oder
konnte nicht gefunden werden.
fatal: destination path 'json_test_data' already exists and is not an empty directory.
c:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(234,5): error MSB6006: "cmd.exe" wurde mit dem Code 128 beendet. [build\test\download_test_data.vcxproj]
Which compiler and operating system are you using?
Which version of the library did you use?
If you experience a compilation error: can you compile and run the unit tests?
did not work, there is mising a -C in the command
would do the job, but an error is reported about json_test_data.
After deleting the json_test_data folder and executing
it works.
Is also works without deleting the folder when "if exist" is used instead of "test" as reported on top of this post.
Total Test time (real) = 381.65 sec
The following tests FAILED:
51 - cmake_import_configure (Failed)
52 - cmake_import_build (Not Run)
53 - cmake_import_minver_configure (Failed)
54 - cmake_import_minver_build (Not Run)
57 - cmake_fetch_content_configure (Failed)
58 - cmake_fetch_content_build (Not Run)
Errors while running CTest
The text was updated successfully, but these errors were encountered: