CMake with environment Variables and WSL
I'm trying to cross compile for my raspberry using cmake and wsl. I'm roughly following this guide: https://stackoverflow.com/questions/19162072/how-to-install-the-raspberry-pi-cross-compiler-on-my-linux-host-machine/58559140#58559140
I have a couple of issues:
1. When i set a program argument (i.e. the -DCMAKE_TOOLCHAIN_FILE=..) in the "run configuration" for my Cmake application, it get's copied over to the settings-> cmake page and from then on any changes to the run configuration don't make any difference. I have to go into the settings make changes or remove the setting. Why is that?
2. I have to set some environment variables for the location of the toolchain file, adding the compiler to the PATH etc. Two issues here: 1. The $HOME variable doesn't get resolved (i.e. $HOME/x doesnt turn into /home/myuser/x) and secondly adding something to the PATH doesnt work with PATH=/something/x:PATH. How does CLion handle the ssh login to my WSL? How can I set the env variables correctly?
3. Clion puts all the cmake files in a folder called "cmake-build-debug", where as a normal cmake invocation just puts it in the root. How is that set? Can I change the name of that?
Executing the command that clion excutes for Cmake directly from the WSL Shell works fine, I get a cmake build and can compile with make.
Please sign in to leave a comment.
Hello!
>When i set a program argument (i.e. the -DCMAKE_TOOLCHAIN_FILE=..) in the "run configuration"
CMake options should be specified in CMake profile (in the CMake options field), not in the Run/Debug configuration.
>adding something to the PATH doesnt work with PATH=/something/x:PATH
Unfortunately, it doesn't work currently: https://youtrack.jetbrains.com/issue/CPP-11809. Feel free to comment or upvote the issue in order to get updates. See https://intellij-support.jetbrains.com/hc/en-us/articles/207241135-How-to-follow-YouTrack-issues-and-receive-notifications if you are not familiar with YouTrack.
You can try using the full paths in the toolchain file.
>Clion puts all the cmake files in a folder called "cmake-build-debug", where as a normal cmake invocation just puts it in the root. How is that set? Can I change the name of that?
In the Generation path field in CMake profile: https://www.jetbrains.com/help/clion/quick-cmake-tutorial.html#profiles.
Just FYI while it doesn't work by changing the PATH variable in the "system variables" window, you can add your own PATH variable (LINUX-formatted) to the top window and add it will work.
This makes it possible to work even with ESP-IDF inside CLion through WSL.