Bug in CLion for CMakeListsPrivate.txt generation when using lib_extra_dirs in Windows

Hey everyone, hopefully you can help me resolve this or at least I can bring this to your attention.

I’m on Windows 10 using the PlatformIO plugin (version 212.5080.54).

It seems that if I use an absolute path in lib_extra_dirs, it attempts to be smart in its generation of CMakeListsPrivate.txt by replacing the drive and user directory with $ENV{HOMEDRIVE}$ENV{HOMEPATH}, which then evaluates to include backslashes and breaks cmake. This occurs even if you explicitly use forward slashes in the absolute path.

In platform.ini:

lib_extra_dirs=C:/Users/john_contactci/AppData/Local/Maestro/libs

In the resulting generated CMakeListsPrivate.txt:

    FILE(GLOB_RECURSE EXTRA_LIB_SOURCES
        ${CMAKE_CURRENT_LIST_DIR}/.pio/libdeps/teensy40/*.*
        $ENV{HOMEDRIVE}$ENV{HOMEPATH}/AppData/Local/Maestro/libs/*.*
    )

Later on EXTRA_LIB_SOURCES is appended to SRC_LIST:

list(APPEND SRC_LIST ${EXTRA_LIB_SOURCES})

And this results in the following error from CMakeLists.txt:

CMake Error at CMakeLists.txt:33 (add_executable):
  Syntax error in cmake code when parsing string

    C:\Users\john_contactci/AppData/Local/Maestro/libs/maestro-embedded-config/include/MaestroEmbeddedConfiguration.h

  Invalid character escape '\U'.

Due to the backslash in the path.

For reference, line 33 of CMakeLists.txt:

add_executable(Z_DUMMY_TARGET ${SRC_LIST})

Which is why I mention the bit about EXTRA_LIB_SOURCES being appended to SRC_LIST above.

Things I have tried to no avail:

  • Defining a PLATFORMIO_LIB_EXTRA_DIRS env var, which results in the same problem.
  • Throwing quotes around the path, which just results in it being treated as a relative path rather than absolute.
  • Using backslashes but escaping them (i.e. \\) in the absolute path.

Any assistance or work around would be greatly appreciated!

Thanks!

– EDIT –
Opened an issue in github here: Bug in CLion for CMakeListsPrivate.txt generation when using lib_extra_dirs in Windows · Issue #4071 · platformio/platformio-core · GitHub

Open a bug report in Issues · platformio/platformio-core · GitHub, that’s where the generator lives.

Thanks for the direction. I’ve opened an issue Bug in CLion for CMakeListsPrivate.txt generation when using lib_extra_dirs in Windows · Issue #4071 · platformio/platformio-core · GitHub