Imported Upstream version 3.25.0
[platform/upstream/cmake.git] / Tests / RunCMake / PrecompileHeaders / PchReuseFrom-common.cmake
1 enable_language(C)
2
3 if(CMAKE_C_COMPILE_OPTIONS_USE_PCH)
4   add_definitions(-DHAVE_PCH_SUPPORT)
5 endif()
6
7 # Add this before the target from which we will reuse the PCH
8 # to test that generators can handle reversed ordering.
9 add_library(foo foo.c)
10 target_include_directories(foo PUBLIC include)
11
12 add_library(empty empty.c)
13 target_precompile_headers(empty PRIVATE
14   <stdio.h>
15   <string.h>
16 )
17 target_include_directories(empty PUBLIC include)
18
19 target_precompile_headers(foo REUSE_FROM empty)
20
21 # should not cause problems if configured multiple times
22 target_precompile_headers(foo REUSE_FROM empty)
23
24 add_executable(foobar foobar.c)
25 target_link_libraries(foobar foo )
26 set_target_properties(foobar PROPERTIES PRECOMPILE_HEADERS_REUSE_FROM foo)
27
28 enable_testing()
29 add_test(NAME foobar COMMAND foobar)