How do I add an existing C++ sSource file to a CLion Project

I created a simple cmake project in Clion. I need to add existing source files from another directory. How do I do that ???

The project table only allows we to add a new source ( and it updates CMakeFile.txt ). Also why does it add the header files to the source list ??

3
8 comments
Avatar
Permanently deleted user

This'll work for that.

 

add_subdirectory(/path to directory/ ${CMAKE_CURRENT_BINARY_DIR}/tinyxml2-3.0.0)
1
Avatar
Permanently deleted user

could you describe how you add it to SOURCE_FILES...

1
Avatar
Permanently deleted user

Are you trying to do an out of source build for some dependency?

0
Avatar
Permanently deleted user

Please see the attached image, I am trying to add an existing file to this project called "intro"

0
Avatar
Permanently deleted user

In that case just drop it in the folder and add it to SOURCE_FILES.

0
Avatar
Permanently deleted user

once i added mingw path, i got it working

0

Hi everybody. I am new to CLion. I have C files and folders in place however the IDE compiles only 'main.c' and ignores the other source files.

The English verb "add" seems to be missing in the CLion documentation - so can't add files to project...

That sounds like trivial question but: how to build a C project from more than one C file?

0

Hello CLion NewB!

>I have C files and folders in place however the IDE compiles only 'main.c' and ignores the other source files.

Do you need to compile those source files as separate executables? Or should all the files be included into one executable?

0

Please sign in to leave a comment.