mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-14 19:08:07 +08:00
PCH: add example/test
This commit is contained in:

committed by
Cristian Adam

parent
9b6797e71d
commit
375d01c680
17
Tests/PrecompileHeaders/CMakeLists.txt
Normal file
17
Tests/PrecompileHeaders/CMakeLists.txt
Normal file
@@ -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
Tests/PrecompileHeaders/foo.c
Normal file
6
Tests/PrecompileHeaders/foo.c
Normal file
@@ -0,0 +1,6 @@
|
||||
#include "foo.h"
|
||||
|
||||
int foo()
|
||||
{
|
||||
return 0;
|
||||
}
|
7
Tests/PrecompileHeaders/foobar.c
Normal file
7
Tests/PrecompileHeaders/foobar.c
Normal file
@@ -0,0 +1,7 @@
|
||||
#include "bar.h"
|
||||
#include "foo.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
return foo() + bar();
|
||||
}
|
9
Tests/PrecompileHeaders/include/bar.h
Normal file
9
Tests/PrecompileHeaders/include/bar.h
Normal file
@@ -0,0 +1,9 @@
|
||||
#ifndef bar_h
|
||||
#define bar_h
|
||||
|
||||
static int bar()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
6
Tests/PrecompileHeaders/include/foo.h
Normal file
6
Tests/PrecompileHeaders/include/foo.h
Normal file
@@ -0,0 +1,6 @@
|
||||
#ifndef foo_h
|
||||
#define foo_h
|
||||
|
||||
extern int foo();
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user