1 cmake_minimum_required(VERSION 3.15)
2 project(PchReuseFrom C)
4 if(CMAKE_C_COMPILE_OPTIONS_USE_PCH)
5 add_definitions(-DHAVE_PCH_SUPPORT)
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)
13 add_library(empty empty.c)
14 target_precompile_headers(empty PRIVATE
18 target_include_directories(empty PUBLIC include)
20 target_precompile_headers(foo REUSE_FROM empty)
22 # should not cause problems if configured multiple times
23 target_precompile_headers(foo REUSE_FROM empty)
25 add_executable(foobar foobar.c)
26 target_link_libraries(foobar foo )
27 set_target_properties(foobar PROPERTIES PRECOMPILE_HEADERS_REUSE_FROM foo)
30 add_test(NAME foobar COMMAND foobar)