recognize header files from other directories

I have a project structured as below:

project/src/util.h
project/src/util.cc
project/test/test.cc
project/test/Makefile.am

the Makefile.am includes: AM_CPPFLAGS = -I${top_srcdir}/src
in test.cc, I need to import util.h and use some API frm this file, but Clion can not resolve these symbols. Is there any solution?

0
6 comments
Avatar
Permanently deleted user

Wi Zhung, what's in your CMakeLists.txt file?

0
Avatar
Permanently deleted user

It looks like :
cmake_minimum_required(VERSION 2.8.4)
project(linux)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

set(SOURCE_FILES
   src/util.h
   src/util.cc
   test/test.cc
   test/Makefile.am
    CMakeLists.txt
    configure.ac
    Makefile.am)

add_executable(linux ${SOURCE_FILES})

and I've already tried reload CMake Project

0
Avatar
Permanently deleted user

It looks correct. One more question, is "#include "util.h"" resolved?
If you can send us your project, we'll find out the problem.

0
Avatar
Permanently deleted user

No, it can not resolve the header file.
project is in the  attachment.



Attachment(s):
Cliontest.zip
0
Avatar
Permanently deleted user

Thank you for the project.
CLion can't find util.h, because it's not in the current directory. You should include it as "#include "../src/util.h"".
By the way, auto-import popup is trying to include it correcty, is auto-import working for you?



Attachment(s):
Screen Shot 2014-11-05 at 14.09.49.png
0
Avatar
Permanently deleted user

Selecting the "user directory" manually when importing the project can solve this problem.



Attachment(s):
20141106095702.png
0

Please sign in to leave a comment.