question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

CLion code insight don't work inside ./test folder

See original GitHub issue
  • [*] PlatformIO Core. If you’ve found a bug, please provide an information below.

Configuration

Operating system: Pop!_OS 20.04

PlatformIO Version (platformio --version): PlatformIO, version 4.4.0a4

Description of problem

CLion doesn’t think that .cpp files inside the ./test folder are part of the project, noting “This file does not belong to any project target, code insight features might not work properly”.

Steps to Reproduce

  1. git clone https://github.com/platformio/platformio-examples
  2. Open platformio-examples/unit-testing/wiring-blink in CLion and allow it to create CMakeLists.txt and wait for the automatically started pio init command to finish
  3. Open ./test/test_main.cpp and note the error highlighting on all #includes

Actual Results

Using #include leads to import errors (only in CLion, project compiles and tests fine with pio CLI tool).

Expected Results

Syntax highlighting works as expected without having red underscores on all #includes and most function calls.

Additional info

System information (uname -a): Linux pop-os 5.4.0-7634-generic #38~1592497129~20.04~9a1ea2e-Ubuntu SMP Fri Jun 19 22:43:37 UTC x86_64 x86_64 x86_64 GNU/Linux

CLion version: CLion 2020.2 EAP, Build #CL-202.6109.21

PlatformIO CLion plugin version: 202.6109.21

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
dumarjocommented, Jun 23, 2021

I created a new file CMakeListUser.txt with this content

# Add the test source files to CMake so that CLion recognises them properly.
# File won't be required once issue here is closed: https://youtrack.jetbrains.com/issue/CPP-21173
FILE(GLOB_RECURSE TEST_LIST
    ${CMAKE_CURRENT_LIST_DIR}/test/*.*
)

list(APPEND SRC_LIST ${TEST_LIST})

and now Clion is happy.

Read more comments on GitHub >

github_iconTop Results From Across the Web

CLion cannot detect classes from sources, and does not have ...
CLion won't find the source files I include, and therefore won't detect any classes that are declared inside other hps files and their...
Read more >
Clion code inspection not working
Clion static code analysis is highlight a lot of errors about missing definition and files, but its already included in the project.
Read more >
Unit testing tutorial | CLion Documentation - JetBrains
This tutorial gives an overview of the unit testing approach and discusses four frameworks supported by CLion: Google Test, Boost.
Read more >
Google Test | CLion Documentation - JetBrains
Create a CMakeLists.txt file inside the Google_tests folder: right-click it in the project tree and select New | CMakeLists.txt. Customize ...
Read more >
Manage CMake project files | CLion Documentation - JetBrains
Add new files. In the Project tree, right-click the folder you want to add a file into and select New from the context...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found