I'm building a cmake based build system for our product. The problem is that Visual Studio project, generated by cmake, doesn't display header files in solution browser.
What I need to add in CMakeList.txt to list header files? The preferred solution is where no need to list each particular header file.
Solution Here is a solution I came with:
file(GLOB_RECURSE INCS "*.h")
add_library(myLib ${SRCS} ${INCS})
Thanks
I had the same problem while working at a build system for a Qt project and I came out with this solution, thanks to the other posts on this page. I included a complete example adapted from my makefiles. Hope this helps!
The basic trick to this is to add the header files to one of the targets (either executable or library). This is particularly irritating because cmake already knows all the header file dependencies and should take care of this for us. You can organize it further using the source_group command:
Note that you have to do the same thing in Xcode too.
Just add the header files along with the source files:
Or using variables: