Skip to content
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

cmake --build build/test --target format not working #119

Open
mscofield0 opened this issue Mar 31, 2021 · 9 comments
Open

cmake --build build/test --target format not working #119

mscofield0 opened this issue Mar 31, 2021 · 9 comments
Labels
help wanted Extra attention is needed

Comments

@mscofield0
Copy link
Contributor

I've installed all that the documentation said is required:

$ pip list
Package      Version
------------ -------
cmake-format 0.6.13
cmakelang    0.6.13
pip          21.0.1
PyYAML       5.4.1
setuptools   49.2.1
six          1.15.0
$ clang-format.exe --version
clang-format version 11.0.1

However, cmake --build build/standalone --target format works.

@TheLartians
Copy link
Owner

TheLartians commented Apr 1, 2021

@mscofield0 the format target should error if your code is not properly formatted. fix-format should auto format it. Also the target should only be defined for the tests and not the standalone. Could you post the error message you are receiving to better understand the problem?

@mscofield0
Copy link
Contributor Author

Yeah, here it is:

$ cmake --build build/test --target format
Microsoft (R) Build Engine version 16.9.0+5e4b48a27 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

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

Also, I forgot to mention that I added the Format.cmake package to the standalone target.

@TheLartians
Copy link
Owner

That's strange, unfortunately I don't have much knowledge in MSVC, so it's hard to say why the project file doesn't exist. Does the error also occur if you create a fresh build of the all project? E.g.

# delete build_all if it exists
cmake -S all -B build_all
cmake --build build_all --target format

May I ask why you added Format.cmake it to the standalone project?

@mscofield0
Copy link
Contributor Author

That's strange, unfortunately I don't have much knowledge in MSVC, so it's hard to say why the project file doesn't exist. Does the error also occur if you create a fresh build of the all project? E.g.

# delete build_all if it exists
cmake -S all -B build_all
cmake --build build_all --target format

Huh, that works. May I ask why it doesn't work on build/test though?

May I ask why you added Format.cmake it to the standalone project?

No specific reason, I was new to the template so I wanted to play around with it.

@TheLartians
Copy link
Owner

Huh, that works. May I ask why it doesn't work on build/test though?

Yeah, that is strange indeed. It should still work assuming that you didn't remove the Format.cmake target from the source there. What happens if you build the format target on the tests after a fresh clone of the template?

No specific reason, I was new to the template so I wanted to play around with it.

Gotcha. Just FYI the idea of the Format target is to be run alongside the test suite and it will check the whole codebase committed to Git. As it isn't needed to build the standalone target, it makes most sense to be left alongside the tests.

@mscofield0
Copy link
Contributor Author

mscofield0 commented Apr 5, 2021

What happens if you build the format target on the tests after a fresh clone of the template?
These are the exact commands I entered:

$ git clone https://github.com/TheLartians/ModernCppStarter.git
...
$ cd ModernCppStarter
$ cmake -S test -B build/test
...
$ cmake --build build/test
...
$ cmake --build build/test --target format
Microsoft (R) Build Engine version 16.9.0+5e4b48a27 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

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

Really can't tell what the issue might be...

Gotcha. Just FYI the idea of the Format target is to be run alongside the test suite and it will check the whole codebase committed to Git. As it isn't needed to build the standalone target, it makes most sense to be left alongside the tests.

Oh, that makes sense. Thanks for the clarification.

@TheLartians
Copy link
Owner

Yeah, that's indeed very strange, the same command sequence works on my Mac without issues. I think this might be an issue with CMake, which version are you on? Unfortunately, I don't have access to a windows machine to explore this myself.

@mscofield0
Copy link
Contributor Author

I think this might be an issue with CMake, which version are you on?

I'm on CMake 3.20.0, which is the latest one.

@mscofield0
Copy link
Contributor Author

This might be an important information, but the executable is in build/test/Debug instead of build/test

@TheLartians TheLartians added the help wanted Extra attention is needed label Apr 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants