Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Technical Support
 Does VAX Add Include work with CMake projects?

You must be registered to post a reply.
Click here to register.

Screensize:
UserName:
Password:
Format: BoldItalicizeUnderlineStrikethrough Align leftCenterAlign right Insert horizontal ruleUpload and insert imageInsert hyperlinkInsert email addressInsert codeInsert quoted textInsert listInsert Emoji
   
Message:

Forum code is on.
Html is off.

 
Check to subscribe to this topic.
   

T O P I C    R E V I E W
tony.riviere Posted - Feb 15 2024 : 04:00:07 AM
Hello,
I was wondering if this feature was compatible with CMake project. Here I have a simple solution with 2 projects: CMakeProject2 depending on CMakeProject1. When I hit "Add Include" on Class1 (defined in CMakeProject1) from CMakeProject2, VAX includes the corresponding header relatively from the current project instead of relatively to the include directory '.' of the CMakeProject1. While IntelliSense resolve the correct path.

// CMakeProject2.cpp

// #include "../CMakeProject1/CMakeProject1.h" // Generated by VAX
// #include <CMakeProject1.h>                  // Generated by Intellisense

int main()
{
    Class1 c;
    return 0;
}






I'm not using the last VAX version because the AddInclude in broken (as mentioned in another issue). Here is my info:

License: Named Network User / Standard (3DAL-VRDTCF-5U79FL-32PD) Support ends 2024.07.21
VA_X64.dll file version 10.9.2508.0 built 2023.11.24
DevEnv.exe version 17.10.34607.79 Professional
msenv.dll version 17.0.34606.254
Comctl32.dll version 6.10.22621.2506
Windows 11 11.0 23H2 Build 22631
16 processors (x86-64)
Language info: 1252, 0x40c

Platform: Win32
Stable Includes:

Other Includes:

Stable Source Directories:

10   L A T E S T    R E P L I E S    (Newest First)
feline Posted - Feb 26 2024 : 09:57:21 AM
There is a project variable you can find in CMakeLists.txt:

https://cmake.org/cmake/help/latest/variable/CMAKE_PROJECT_NAME.html

which opens up a separate conversation.

A reserved string for the directory name makes sense, I have put in a feature request for this:

case=164231
tony.riviere Posted - Feb 21 2024 : 07:08:33 AM
Well, in my case, the folder containing the CMakeLists.txt has the name of the project. But it's probably not the same for everyone.
feline Posted - Feb 20 2024 : 07:34:45 AM
That makes sense, so taking the directory holding the CMakeLists.txt file is considered reliable for the name of the project? I just expected you to be after something inside the CMakeLists.txt file is all
tony.riviere Posted - Feb 19 2024 : 3:34:58 PM
The main example I have in mind is this one:

#include "$PROJECT_NAME$/$PROJECT_NAME$Defines.h"

// Expanded to: #include "ProjectA/ProjectADefines.h"

We use it at the beginning of every header of a project, as the xxxDefines.h header contains macros for this particular project (like the declspec import/export ones). And we have several projects per solution.
In case of CMake project, $PROJECT_NAME$ is expanded either to empty string in the configure has not yet been executed, or to "CMakeList" if there was a configure.

$PROJECT_PATH$ is probably the closest as it gives the full path to the folder containing the CMakeLists.txt.
// Suppose the CMake project: D:\Solution\ProjectA\CMakeLists.txt
// Then $PROJECT_PATH$ is expanded to:
D:\Solution\ProjectA

Where a macro $PROJECT_FOLDER_NAME$ could be resolved to "ProjectA" and it could work for either .vcxproj or CMakeLists.txt
feline Posted - Feb 19 2024 : 11:14:23 AM
For excluding things, here is the content of my test file. Starting in the base directory, that you open when going open directory, it is the file:

.vscode\settings.json

and it excludes directories and files. Anything that isn't a file name is a directory being excluded.

{
    "files.exclude": {
        "*/cpp_dll_cpp17": true,
        "cpp_dll_cpp20" : true,
        "**/bugs" : true,
        "**/code_formatting_tests/clangFormatBase" : true,
        "**/test_plain_text.txt" : true,
        "**/*.xaml" : true
    }
}

this should get you up and running without to many problems with this. Please do note that you need to Enable the setting:

VA Options -> Performance -> Do not parse files excluded by .vscode\settings.json (requires restart)

before the file is going to start taking effect.


As for snippets, unfortunately no, but that is a good point. Trying the current reserved strings, $SOLUTION_NAME$ is giving me the full path of the directory I open when I open the CMake project. How close is this to what you are looking for?

Or is the target possibly different to the directory name? I still only know a tiny, and random, bit about CMake projects, so this might be a silly question.
tony.riviere Posted - Feb 19 2024 : 05:06:02 AM
Thanks for the hint. I was not aware of this option, and it could definitely help me the last time VSCode burnt my RAM up to 20 Go parsing the compilation directory with preprocessed sources...

Edit: In your snippet engine, we used to have snippets using the PROJECT_NAME which no longer work for the CMake project. Do you have plan to support it (or something like TARGET_NAME)?
feline Posted - Feb 16 2024 : 11:25:08 AM
But surely no one really needs a project bigger than Hello World, do they?

Since you are working with larger projects, do you know about the ".vscode\settings.json" file? VA will detect and respect this file, easily letting you exclude directories and files, especially useful for excluding build files, or some auto generated files you don't want VA to parse.
tony.riviere Posted - Feb 16 2024 : 09:49:08 AM
Thank you for your quick answer.
We are moving our code base from vcxproj based to CMake based and AddInclude is definitely one of the most used feature after code navigation (since IntelliSense is completely lost on projects bigger than hello world ).
feline Posted - Feb 16 2024 : 09:09:25 AM
I have the test project, many thanks for this. As you already know, this is a pure CMake project, so no Visual Studio project for us to read, to get the include directories from.

VA doesn't currently pick up the include directories from "CMakeLists.txt" files, which is the problem here. This is something we are looking to do:

case=140829

Not quite as simple as picking up visual studio project settings, since as I understand it, we have to search the directory tree for multiple "CMakeLists.txt" files and correctly combine them together. So having a clear start point example is helpful, thank you for that.
feline Posted - Feb 15 2024 : 09:10:34 AM
Would it be possible to get a copy of these two cmake projects so I can test this here, and run some experiments?

It sounds like VA is picking up a different understanding of the include directories than the IDE has, and I am not sure why that would happen. There is a known problem that VA doesn't currently understand external include directories, which can be generated by cmake when cmake is used to generate a Visual Studio solution. So it is possible this is the cause of the problem. Or something else could be going on here.

If it is possible to get the files please send me them via the email:

[email protected]

including this thread ID or URL in the description, so we can match it up.

© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000