cmake/Tests/RunCMake/PrecompileHeaders/PchReuseFrom-common.cmake

30 lines
788 B
CMake
Raw Normal View History

2022-11-16 20:14:03 +01:00
enable_language(C)
2020-02-01 23:06:01 +01:00
if(CMAKE_C_COMPILE_OPTIONS_USE_PCH)
add_definitions(-DHAVE_PCH_SUPPORT)
endif()
2020-08-30 11:54:41 +02:00
# Add this before the target from which we will reuse the PCH
# to test that generators can handle reversed ordering.
add_library(foo foo.c)
target_include_directories(foo PUBLIC include)
2020-02-01 23:06:01 +01:00
add_library(empty empty.c)
target_precompile_headers(empty PRIVATE
<stdio.h>
<string.h>
)
target_include_directories(empty PUBLIC include)
target_precompile_headers(foo REUSE_FROM empty)
# should not cause problems if configured multiple times
target_precompile_headers(foo REUSE_FROM empty)
add_executable(foobar foobar.c)
target_link_libraries(foobar foo )
set_target_properties(foobar PROPERTIES PRECOMPILE_HEADERS_REUSE_FROM foo)
enable_testing()
add_test(NAME foobar COMMAND foobar)