Browse Source

PCH: add example/test

Daniel Pfeifer 10 years ago
parent
commit
375d01c680

+ 17 - 0
Tests/PrecompileHeaders/CMakeLists.txt

@@ -0,0 +1,17 @@
+cmake_minimum_required(VERSION 3.15)
+project(PrecompileHeaders C)
+
+add_library(foo foo.c)
+target_include_directories(foo PUBLIC include)
+target_precompile_headers(foo PUBLIC
+  foo.h
+  <stdio.h>
+  \"string.h\"
+)
+
+add_library(bar INTERFACE)
+target_include_directories(bar INTERFACE include)
+target_precompile_headers(bar INTERFACE bar.h)
+
+add_executable(foobar foobar.c)
+target_link_libraries(foobar foo bar)

+ 6 - 0
Tests/PrecompileHeaders/foo.c

@@ -0,0 +1,6 @@
+#include "foo.h"
+
+int foo()
+{
+  return 0;
+}

+ 7 - 0
Tests/PrecompileHeaders/foobar.c

@@ -0,0 +1,7 @@
+#include "bar.h"
+#include "foo.h"
+
+int main()
+{
+  return foo() + bar();
+}

+ 9 - 0
Tests/PrecompileHeaders/include/bar.h

@@ -0,0 +1,9 @@
+#ifndef bar_h
+#define bar_h
+
+static int bar()
+{
+  return 0;
+}
+
+#endif

+ 6 - 0
Tests/PrecompileHeaders/include/foo.h

@@ -0,0 +1,6 @@
+#ifndef foo_h
+#define foo_h
+
+extern int foo();
+
+#endif