Include files not context highlighting

Answered

I am very new to CLion. I just decided to switch over from Microsoft Visual studios, and project setup has been rocky to put it lightly. I cant get context highlighting working and adding SDL2 was beyond difficult. I've been searching the internet for days now, and while i finally got my code compiling after roughly 3 days of wrestling with CMakeLists.txt, the header files still lack context highlighting. I've tried plenty of solutions with Include_Directories, marking my file as source (Seems to have no effect) and mucking with the add_executables.

Here's my CMakeLists.txt:

cmake_minimum_required(VERSION 3.16)
project(NightLight)

set(CMAKE_CXX_STANDARD 14)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/SDL2/sdl2-cmake-scripts")
set(SDL2_PATH "${CMAKE_CURRENT_SOURCE_DIR}/SDL2")
set(SDL2_IMAGE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/SDL2_image")
set(SDL2_TTF_PATH "${CMAKE_CURRENT_SOURCE_DIR}/SDL2_ttf")

find_package(SDL2 REQUIRED)
find_package(SDL2_image REQUIRED)
find_package(SDL2_ttf REQUIRED)

include_directories(${SDL2_INCLUDE_DIR}
${SDL2_IMAGE_INCLUDE_DIR}
${SDL2_TTF_INCLUDE_DIR}
json-3.6.1
src/main/headers/constants
src/main/headers/core
src/main/headers/customdata
src/main/headers/metaheader
src/main/headers/utilities)

add_executable(NightLight
src/main/headers/customdata/action.h
src/main/headers/core/actionprocessor.h
src/main/headers/customdata/baseobject.h
src/main/headers/customdata/color.h
src/main/headers/constants/constants.h
src/main/headers/metaheader/core.h
src/main/headers/metaheader/customdatatypes.h
src/main/headers/metaheader/customutilities.h
src/main/headers/customdata/dimension.h
src/main/headers/core/directoryloader.h
src/main/headers/utilities/filereader.h
src/main/headers/core/imageloader.h
src/main/headers/customdata/interactable.h
src/main/headers/core/interactableloader.h
src/main/headers/customdata/itemplacement.h
src/main/headers/utilities/jsonutlities.h
src/main/headers/constants/keyconstants.h
src/main/headers/customdata/Layer.h
src/main/headers/core/level.h
src/main/headers/core/levelloader.h
src/main/main.cpp
src/main/headers/metaheader/mainheader.h
src/main/headers/core/mainwindow.h
src/main/headers/utilities/miscutilities.h
src/main/headers/metaheader/noncustomincludes.h
src/main/headers/core/queueprocessor.h
src/main/headers/core/renderable.h
src/main/headers/customdata/RenderRequest.h
src/main/headers/core/resourcemanager.h
src/main/headers/customdata/scrolldata.h
src/main/headers/customdata/settings.h
src/main/headers/customdata/Sprite.h
src/main/headers/metaheader/testinghooks.h
src/main/headers/customdata/windowsettings.h)

target_link_libraries(NightLight ${SDL2_LIBRARY}
${SDL2_IMAGE_LIBRARIES}
${SDL2_TTF_LIBRARIES})

I'm using CLion 2020.1, Microsoft Visual Studio toolchain, and a amd64 target platform. Any ideas on how to make my project work in this new IDE? I'd like to try to break from visual studio to make linux releases easier later.

0
8 comments

Hello!

You can try following https://intellij-support.jetbrains.com/hc/en-us/community/posts/115000770164/comments/360000002010.

Please note that you need to download SDL2-devel-2.0.12-VC.zip (Visual C++ 32/64-bit) instead of SDL2 distribution for MinGW.

 

0

Thank you for your post Anna.

I read through the suggestion, I feel like that's already what i've done above. SDL2 is working fine and the project builds. The problem is the context highlighting for files like Constants.h and QueueProcessor.h.

I looked at the CMakeLists.txt you provided, vs the one i have and the only major difference i could see was I'm using C++ 14 and you were using C++ 11. I tried switching to C++ 11 and no luck.

What happens is when i open up CLion for the first time, the code context highlights for a brief moment. The files are clearly seen as project files. However if i start typing/editing the source files context highlighting and auto complete both break till i restart CLion. The project still compiles through.

I got my FindSDL2.cmake from here if you'd like a reference: https://github.com/tcbrindle/sdl2-cmake-scripts

0

Please check the idea.log file (Help | Show Log in ...). Do you see any mentions about clangd crashes?

0

I checked the logs for today, while i dont see any clangd crashes, i see this line that looks pretty ominous.

2020-05-18 08:05:12,169 [1090216] INFO - j.ide.actions.RevealFileAction - Exit code 1

 

An exit code other than zero is never good.

0

Please restart CLion, go to Help | Find Action, type "Registry...", select it, in the opened list find the clion.clang.clangd.debug option and set it to 1. Then please reproduce the issue (type code, pressing ctrl + space etc.) and send the idea.log file. to clion-support at jetbrains.com. Note that logs might contain private user's information (like file paths and names). 

1

Thank you, i got the log files. Guess i have to wait on support. I'm seeing some weird errors about it not being able to construct a preamble for my files or something. Thank you for your help.

0

I see only one support request from you which was submitted on Saturday. But I don't see any logs there. Did you provide the logs in this request? Or did you send them to clion-support at jetbrains.com?

0

Log added to the support ticket. Sorry bout that, i was waiting for them to respond since the ticket was already open. I didnt know you had access to it and wanted the info now.

Ticket is updated with appropriate log file. Thanks.

0

Please sign in to leave a comment.