mirror of
https://github.com/Kitware/CMake.git
synced 2026-03-09 01:09:30 -05:00
Merge topic 'pch-export'
c54448e185 PCH: Propagate INTERFACE_PRECOMPILE_HEADERS in install(EXPORT)
Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Cristian Adam <cristian.adam@gmail.com>
Merge-request: !3862
This commit is contained in:
@@ -94,6 +94,9 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
|
||||
this->PopulateInterfaceProperty("INTERFACE_COMPILE_OPTIONS", gt,
|
||||
cmGeneratorExpression::InstallInterface,
|
||||
properties, missingTargets);
|
||||
this->PopulateInterfaceProperty("INTERFACE_PRECOMPILE_HEADERS", gt,
|
||||
cmGeneratorExpression::InstallInterface,
|
||||
properties, missingTargets);
|
||||
this->PopulateInterfaceProperty("INTERFACE_AUTOUIC_OPTIONS", gt,
|
||||
cmGeneratorExpression::InstallInterface,
|
||||
properties, missingTargets);
|
||||
|
||||
@@ -6,6 +6,12 @@ set_property(TARGET headeronly PROPERTY INTERFACE_INCLUDE_DIRECTORIES
|
||||
)
|
||||
set_property(TARGET headeronly PROPERTY INTERFACE_COMPILE_DEFINITIONS "HEADERONLY_DEFINE")
|
||||
|
||||
add_library(pch_iface INTERFACE)
|
||||
target_precompile_headers(pch_iface INTERFACE
|
||||
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/pch/pch.h>"
|
||||
"$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include/pch/pch.h>"
|
||||
)
|
||||
|
||||
include(GenerateExportHeader)
|
||||
add_library(sharedlib SHARED sharedlib.cpp)
|
||||
generate_export_header(sharedlib)
|
||||
@@ -45,7 +51,7 @@ set_property(TARGET cmakeonly PROPERTY custom_property CustomPropertyValue)
|
||||
set_property(TARGET cmakeonly PROPERTY EXPORT_PROPERTIES custom_property)
|
||||
|
||||
install(TARGETS headeronly sharediface use_auto_type use_c_restrict source_target
|
||||
cmakeonly
|
||||
pch_iface cmakeonly
|
||||
EXPORT expInterface
|
||||
)
|
||||
install(TARGETS sharedlib
|
||||
@@ -60,6 +66,10 @@ install(FILES
|
||||
headeronly/headeronly.h
|
||||
DESTINATION include/headeronly
|
||||
)
|
||||
install(FILES
|
||||
pch/pch.h
|
||||
DESTINATION include/pch
|
||||
)
|
||||
install(FILES
|
||||
sharedlib/sharedlib.h
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/sharedlib_export.h"
|
||||
|
||||
1
Tests/ExportImport/Export/Interface/pch/pch.h
Normal file
1
Tests/ExportImport/Export/Interface/pch/pch.h
Normal file
@@ -0,0 +1 @@
|
||||
#define PCH_PCH_H_INCLUDED
|
||||
@@ -98,6 +98,17 @@ set_property(TARGET exp::sharediface APPEND PROPERTY INTERFACE_LINK_LIBRARIES de
|
||||
add_executable(interfacetest_exp interfacetest.cpp)
|
||||
target_link_libraries(interfacetest_exp exp::sharediface)
|
||||
|
||||
if(NOT CMAKE_OSX_ARCHITECTURES MATCHES "[;$]" OR CMAKE_GENERATOR STREQUAL "Xcode")
|
||||
add_executable(pch_iface_test_bld pch_iface_test.cpp)
|
||||
target_link_libraries(pch_iface_test_bld bld::pch_iface)
|
||||
add_executable(pch_iface_test_exp pch_iface_test.cpp)
|
||||
target_link_libraries(pch_iface_test_exp exp::pch_iface)
|
||||
if(CMAKE_CXX_COMPILE_OPTIONS_USE_PCH)
|
||||
target_compile_definitions(pch_iface_test_bld PRIVATE EXPECT_PCH)
|
||||
target_compile_definitions(pch_iface_test_exp PRIVATE EXPECT_PCH)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
do_try_compile(exp)
|
||||
|
||||
foreach(ns exp bld)
|
||||
|
||||
16
Tests/ExportImport/Import/Interface/pch_iface_test.cpp
Normal file
16
Tests/ExportImport/Import/Interface/pch_iface_test.cpp
Normal file
@@ -0,0 +1,16 @@
|
||||
#ifdef EXPECT_PCH
|
||||
// Verify that pch/pch.h was included via '-include ...' or equivalent.
|
||||
# ifndef PCH_PCH_H_INCLUDED
|
||||
# error "Expected PCH_PCH_H_INCLUDED."
|
||||
# endif
|
||||
#elif defined(__PGIC__) || defined(__ibmxl__)
|
||||
// No PCH expected but these compilers define macros below.
|
||||
#elif defined(__GNUC__) || defined(__clang__) || defined(_INTEL_COMPILER) || \
|
||||
defined(_MSC_VER)
|
||||
# error "Expected EXPECT_PCH for this compiler."
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user