[CMake] unable to include a source file for all sub directories

Hendrik Sattler post at hendrik-sattler.de
Fri May 15 18:03:22 EDT 2009


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)
--------------------------------------------------------------

var.c:
--------------------------------------------------------------
#include "var.h"
char* var1 = "Hallo";
--------------------------------------------------------------

var.h:
--------------------------------------------------------------
extern char *var1;
--------------------------------------------------------------

sub/main.c
--------------------------------------------------------------
#include "../var.h"
#include <stdio.h>
int main (int argc, char **argv)
{
  printf(var1);
  return 0;
}
--------------------------------------------------------------

So the problem is _definitely_ with your code.

HS



More information about the CMake mailing list