Closed Moneyl closed 3 years ago
Sorry, supporting CMake is in my TODO list, at the moment the extension does an early exit when not finding the VS project information.
My plan was to add an entry in the extension options pointing to the file generated with '-DCMAKE_EXPORT_COMPILE_COMMANDS=1'. This way the extension can retrieve the full command line needed to parse a given unit. This still might make it tricky for header files, as I can't assume file are paired .h/.cpp at the same folder.
My CMake knowledge is not great so any ideas are welcome for the best way to extract for any given file:
Worst case scenario I can just let the user enter those fields directly in the extension options. But getting something more automatic would be better.
Sorry about the duplicate. I failed to notice it.
Recent CMake has that "thing" file-api used for IDE integration, which I think is used by VS by default now: https://cmake.org/cmake/help/git-stage/manual/cmake-file-api.7.html
Just submitted a first pass for CMake configuration in v0.3.4.
This should allow to detect some of the needed command arguments when using the CMAKE_EXPORT_COMPILE_COMMANDS macro with cmake and pointing to it from the Extension Options.
Alternatively, the automatic detection can be disabled and introduce the full configuration by hand if the project is not super complex.
For more detailed information you can check the configuration wiki page
I have been unable to heavily test it, as my CMake projects are quite simple and small. I am sure there are still issues and edge cases in there, feel free to add more issues on more detailed missing features. I added some pending stuff in the project page.
@Viladoman The extension fails to find "modern" C++ stuff like std::byte.
#include "CMakeProject1.h"
#define STRINGIFY(x) #x
#define TOSTRING(x) STRINGIFY(x)
int main()
{
std::byte b{8};
b <<= 2;
std::cout << "Hello CMake." << std::endl;
std::cout << TOSTRING(__cpp_lib_byte) << std::endl;
std::cout << std::to_integer<int>(b) << std::endl;
}
in CMakeLists.txt
cmake_minimum_required (VERSION 3.8)
# Add source to this project's executable.
add_executable (CMakeProject1 "CMakeProject1.cpp" "CMakeProject1.h")
set_target_properties (CMakeProject1
PROPERTIES
CXX_STANDARD 20
)
Thanks for reporting this. I had an issue in the CMake console command gathering!
I missed some c++ standard collection from the cmake commands. If you can try out v0.3.4.1 for validation: StructLayout.zip.
I tried it with your provided CMake setup and it worked for me.
Also remember to generate the CMake compile commands and set it up in the extension options: I only tried it with clang configurations so far.
Really appreciated, let me know if the new version improves your test cases.
EDIT: Also as a workaround for the current extension version you can add in the Extra Args section in the extension options -std=c++20
The extension doesn't work with MSVC.
[09:40:40] COMMAND LINE: C:....\Source\Repos\CMakeProject1\CMakeProject1\CMakeProject1.cpp -- -x c++ -m64 -w std=c++20
The following isn't related probably but just for the record:
To make cplusplus
report the correct version, /Zc:cplusplus is required.
https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-cplusplus/
Hi @Zingam! My last post got an unfortunate new line. The Extra Parser Arguments is missing a - in front: -std=c++20
Whenever I have some free time I will upgrade the cmake commands extractor to translate the basics from msvc commands too.
Thanx. I should have noticed that.
BTW. They (MS STL) broke the extension in the latest VS 16.8. https://github.com/microsoft/STL/issues/1300#issue-702950331
Hi. This is a really useful tool. Will save me a lot of time and it's convenient.
I tested it out with a few cmake projects opened with VS. Get this error in my output:
Regenerating the cmake cache and restarting VS don't fix this so I assume it relies on data from VS projects. Also tried creating a new cmake project, same error. It works on the normal VS projects I tested it on. I could paste my structs/classes into a normal VS project and check them there but that'd remove some of the convenience.