How to I add files to CMakeLIsts.txt without being included in the target?

Answered

 

I want to add header files to CMakeLists, but I don't want to make it as executable entries.

Like attached screenshot, currently I can't add a header file to SET(HEADERS). How can I fix it?

0
2 comments

Hi Blackj0221

"Add to targets" feature detects calls like

add_executable
add_library

and all their entries (e.g SOURCES in your example). So automatically you can add header/source file only to real targets.

In you case you should update CMakeLists.txt manually.

0
Avatar
Permanently deleted user

I found another answer: Right click on folder -> Mark Directory As | Project Sources and Headers. In this simple project it seems to be more comfortable to add headers with this way. If I add it just manually, "This file does not belong to any project target, code insight features might not work properly" error comes out.

0

Please sign in to leave a comment.