[CMake] unable to include a source file for all sub directories
ankit jain
ankitguddu at gmail.com
Tue May 19 00:58:18 EDT 2009
2009/5/16 Hendrik Sattler <post at hendrik-sattler.de>
> Am Freitag 15 Mai 2009 17:05:58 schrieb ankit jain:
> [...]
>
> The following works with VS2008 without any problem as expected:
> CMakeLists.txt:
> --------------------------------------------------------------
> project(var C)
> add_executable(var sub/main.c var.c var.h)
> --------------------------------------------------------------
>
Just try this:
add_library(var sub/main.c var.c)
>
> var.c:
> --------------------------------------------------------------
> // #include "var.h"(dont include this line since no var.h is there)
>
#include<stdio.h>
> char* var1 = "Hallo";
> --------------------------------------------------------------
>
> //var.h:
> --------------------------------------------------------------
> //extern char *var1;
> --------------------------------------------------------------
>
> sub/main.c
> --------------------------------------------------------------
> // #include "../var.h"
> #include <stdio.h>
extern char *var1;
>
> int main (int argc, char **argv)
> {
> printf(var1);
> return 0;
> }
> --------------------------------------------------------------
>
> So the problem is _definitely_ with your code.
>
I made the changes above can u run this code for me and let me know whether
it is working or not.
i commented the line which are not there in my code. Also here var.h is not
exits since code of var.h is directly there in main.c..
Ankit
>
> HS
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20090519/81dea4e4/attachment.htm>
More information about the CMake
mailing list