0

I'm using CLion 2018.2 to write C/C++ code for a custom compiler toolchain which are not supported natively by CLion. I currently compile with make on the Terminal instead of building from within the IDE.

I have a custom include directory with header files which are not resolved/found by CLion since they are not part of the project. However, I want to get code inspection features for them. The headers are e.g. located at C:\devkitPro\wups\include.

I decided to use the include_directories() CMake command to improve CLion's ability to resolved code:

include_directories("C:\\devkitPro\\wups\\include")

Then I also modified the CMake include path:

set(CMAKE_INCLUDE_PATH "C:\\devkitPro\\wups\\include")

And also decided to link against the lib directory:

link_directories("C:\\devkitPro\\wups\\lib")

After doing all that, the headers still aren't resolved in CLion (but it still compiles using make of course). How can the header resolution be done with CLion or is it not possible, yet?

BullyWiiPlaza
  • 17,329
  • 10
  • 113
  • 185
  • When you included via included_directories, did you check the CMake reload worked out correctly on the updated CMake scripts? Try to reload the project, if you haven't done that. Another option here is Mark Directory As from the project view and set Source files and Header to this directory. Or (from v2018.2) is you simply use a header/source via #include directive from the project file, then included file is treated as project one as well (should be under project root however). – nastasiak2512 Aug 09 '18 at 09:44

1 Answers1

0

Depending on the configured toolchain in CLion, CMake expects a Windows or a WSL-style path. Inspections will work with the include_directories directive, e.g.

# Add extra include directories
if (WIN32) # When using a Windows compilation toolchain
    set(WUT "/c/devkitPro/wut/include")
    set(WUPS "/c/devkitPro/wups/include")
else () # When using WSL as toolchain
    set(WUT "/mnt/c/devkitPro/wut/include")
    set(WUPS "/mnt/c/devkitPro/wups/include")
endif ()
include_directories(${WUT})
include_directories(${WUPS})

A more detailed written tutorial can be found in this pull request.

BullyWiiPlaza
  • 17,329
  • 10
  • 113
  • 185