Show 7 more comments. The answer by Kleist certainly works, but there is an important caveat: When you write a Makefile manually, you might generate a SRCS variable using a function to select all. This isn't an answer, it's a comment about Kleist's answer.
Neowizard not in Stackoverflow terminology. This comment is nice, but it's "standard", right? The asker is using cmake already, so suggesting make can be "smarter" isn't that helpful. So is there way to add new source files and then build without re-running cmake?
Show 2 more comments. Extension for Kleist answer : Since CMake 3. Tsyvarev Tsyvarev 50k 16 16 gold badges 75 75 silver badges bronze badges. Using something else to collect the sources or to manually list every single source file? Thomas: They recommend to manually list every source file.
That answer gives a great explanation of the recommendation. Budnikov Sergey Budnikov Sergey 11 1 1 bronze badge.
So Why not use powershell to create the list of source files for you. Question is tagged cross-platform - powershell is not cross-platform. I know. But there's no tag for powershell and "CMake" is already crossplatform. SirDarius SirDarius I knew it must be something stupid. Indeed, I did not listed the headers Do I need to list the headers of just this library, or also all the headers that it might depend on on top of declaring the dependency on the library?
It's a growing project and I quite dread the idea of adding a header to all the dependencies when I add one in the root library. My question was more in the sense that I have several libraries which depend from each other: libroot, liba depends on libroot, libb depends on libroot.
The former sets it recursively for all targets in that directory; whereas the latter sets it for a target. Doing the former breaks the notion of a target graph in CMake, and instead relies on side effects to your file hierarchy. Feel free to invite me to a chat if you disagree with the changes. But, It does have the nice benefit of making the files show up in Visual Studio projects in the expected location.
There are known issues with this the scanner. Show 11 more comments. Angew is no longer proud of SO Angew is no longer proud of SO k 14 14 gold badges silver badges bronze badges.
I thought CMake figured out the include file dependencies automatically. ColinDBennett You don't have to list them for dependency reasons - CMake figures out build dependencies just fine if you don't.
But if you list them, they are considered part of the project, and will be listed as such in IDEs which was the topic of the question. At least for QtCreator it is not necessary to add class. Only lonely. See tutorial at www. I had the same problem. My project directory was like this: --project Classes Application Alex Reinking 9, 2 2 gold badges 31 31 silver badges 63 63 bronze badges.
Remembering that cmake is a 'build system generator' and not a 'build system' using file glob is not a good idea in modern cmake CMake with versions 3. Luckily for us, CMake wraps all this functionality into easy-to-understand commands. Without further ado, the following lines of CMake will add include directories to a particular CMake target.
Precisely, lines will set some required CMake project settings, which you can learn more about in my introduction to CMake post. Unsurprisingly, this CMake command adds include directories to CMake target, and the syntax is the following:.
In other words, using the PUBLIC scope specifier will cascade the include directories to the dependent targets of a target. For example in a build I'm doing with Visual Studio, it calls cmake. BugKiller 1, 1 1 gold badge 10 10 silver badges 19 19 bronze badges. FreshD FreshD 2, 2 2 gold badges 20 20 silver badges 32 32 bronze badges. Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown.
The Overflow Blog. Podcast Making Agile work for data science. Stack Gives Back Featured on Meta.
0コメント