[pio-core 4.0.0b2] CLion and CMakeUserLists.txt

Hi !
I have been using platformio for around two years now and it has been a wonderful tool !
I am currently testing some of the new features of platformio 4.0 but I ran into an issue while testing the possibility to use a custom “CMakeListsUser.txt” file to add new targets for CLion :
After creating and adding a custom target to the CMakeListsUser.txt file, nothing happened. I used the message() CMake function to try to know what’s the issue and it appears that it is not included at all.

After some investigation, it looks like the if(EXISTS CMakeListsUser.txt) looks for the file in the cmake-build-debug directory, where cmake works, but the include(CMakeListsUser.txt) looks for the file in the root of the project. In the current state, it renders the use of this new functionality a tad annoying as you have to create (or symlink) a CMakeListsUser.txt file in the cmake-build-debug directory, which should not be needed.

From what I gathered the fix would be simple, test if(EXISTS ../CmakeListsUser.txt) in CMakeLists.txt , but I am not sure the current test works for other people. Should I open an issue on the github page ?

Steps to reproduce:

  1. Init a new paltoformio project with --ide clion
  2. Create the CMakeListsUser.txt file containing message(${CMAKE_VERSION}) at the root of the project
  3. Open in CLion. Check the “CMake” tab, no message :
-- Configuring done
-- Generating done
  1. Move CMakeListsUser.txt to the generated cmake-build-debug folder. Reload CMake project, an error appears :
CMake Error at CMakeLists.txt:14 (include):
  include could not find load file:

    CMakeListsUser.txt
  1. Copy the CMakeListsUser.txt to the root of the project. Reload CMake project, the CMake version is displayed:
3.14.3
-- Configuring done
-- Generating done

Details :
CLion 2019.1.4
Bundled CMake 3.14.3
platformio-core 4.0.0b2
Python 3.7.3
Debian 9, kernel 4.9.168-1+deb9u3 x86_64

Fixed in [CLion] CMakeListsUser.txt is not included in CMakeLists.txt · Issue #2712 · platformio/platformio-core · GitHub

Please re-test with $ pio upgrade --dev.