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