Export the INTERFACE_PIC property.
This commit is contained in:
parent
4ee872cb99
commit
522bdac149
@ -72,6 +72,8 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os)
|
|||||||
this->PopulateInterfaceProperty("INTERFACE_COMPILE_DEFINITIONS", te,
|
this->PopulateInterfaceProperty("INTERFACE_COMPILE_DEFINITIONS", te,
|
||||||
cmGeneratorExpression::BuildInterface,
|
cmGeneratorExpression::BuildInterface,
|
||||||
properties, missingTargets);
|
properties, missingTargets);
|
||||||
|
this->PopulateInterfaceProperty("INTERFACE_POSITION_INDEPENDENT_CODE",
|
||||||
|
te, properties);
|
||||||
|
|
||||||
this->GenerateInterfaceProperties(te, os, properties);
|
this->GenerateInterfaceProperties(te, os, properties);
|
||||||
}
|
}
|
||||||
|
@ -125,6 +125,18 @@ void cmExportFileGenerator::GenerateImportConfig(std::ostream& os,
|
|||||||
this->GenerateImportTargetsConfig(os, config, suffix, missingTargets);
|
this->GenerateImportTargetsConfig(os, config, suffix, missingTargets);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
void cmExportFileGenerator::PopulateInterfaceProperty(const char *propName,
|
||||||
|
cmTarget *target,
|
||||||
|
ImportPropertyMap &properties)
|
||||||
|
{
|
||||||
|
const char *input = target->GetProperty(propName);
|
||||||
|
if (input)
|
||||||
|
{
|
||||||
|
properties[propName] = input;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void cmExportFileGenerator::PopulateInterfaceProperty(const char *propName,
|
void cmExportFileGenerator::PopulateInterfaceProperty(const char *propName,
|
||||||
const char *outputName,
|
const char *outputName,
|
||||||
|
@ -101,6 +101,8 @@ protected:
|
|||||||
cmGeneratorExpression::PreprocessContext,
|
cmGeneratorExpression::PreprocessContext,
|
||||||
ImportPropertyMap &properties,
|
ImportPropertyMap &properties,
|
||||||
std::vector<std::string> &missingTargets);
|
std::vector<std::string> &missingTargets);
|
||||||
|
void PopulateInterfaceProperty(const char *propName, cmTarget *target,
|
||||||
|
ImportPropertyMap &properties);
|
||||||
void GenerateInterfaceProperties(cmTarget *target, std::ostream& os,
|
void GenerateInterfaceProperties(cmTarget *target, std::ostream& os,
|
||||||
const ImportPropertyMap &properties);
|
const ImportPropertyMap &properties);
|
||||||
|
|
||||||
|
@ -89,6 +89,8 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
|
|||||||
te,
|
te,
|
||||||
cmGeneratorExpression::InstallInterface,
|
cmGeneratorExpression::InstallInterface,
|
||||||
properties, missingTargets);
|
properties, missingTargets);
|
||||||
|
this->PopulateInterfaceProperty("INTERFACE_POSITION_INDEPENDENT_CODE",
|
||||||
|
te, properties);
|
||||||
|
|
||||||
this->GenerateInterfaceProperties(te, os, properties);
|
this->GenerateInterfaceProperties(te, os, properties);
|
||||||
}
|
}
|
||||||
|
@ -162,6 +162,10 @@ include(GenerateExportHeader)
|
|||||||
|
|
||||||
add_library(testSharedLibRequired SHARED testSharedLibRequired.cpp)
|
add_library(testSharedLibRequired SHARED testSharedLibRequired.cpp)
|
||||||
generate_export_header(testSharedLibRequired)
|
generate_export_header(testSharedLibRequired)
|
||||||
|
set_property(TARGET testSharedLibRequired
|
||||||
|
PROPERTY
|
||||||
|
INTERFACE_POSITION_INDEPENDENT_CODE ON
|
||||||
|
)
|
||||||
set_property(TARGET testSharedLibRequired APPEND PROPERTY
|
set_property(TARGET testSharedLibRequired APPEND PROPERTY
|
||||||
INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}"
|
INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}"
|
||||||
)
|
)
|
||||||
|
@ -167,6 +167,24 @@ target_link_libraries(deps_shared_iface testSharedLibDepends)
|
|||||||
target_include_directories(deps_shared_iface PRIVATE testSharedLibDepends)
|
target_include_directories(deps_shared_iface PRIVATE testSharedLibDepends)
|
||||||
target_compile_definitions(deps_shared_iface PRIVATE testSharedLibDepends)
|
target_compile_definitions(deps_shared_iface PRIVATE testSharedLibDepends)
|
||||||
|
|
||||||
|
if (APPLE OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
||||||
|
include(CheckCXXCompilerFlag)
|
||||||
|
check_cxx_compiler_flag(-fPIE run_pic_test)
|
||||||
|
else()
|
||||||
|
if (CMAKE_CXX_COMPILER_ID MATCHES "PGI"
|
||||||
|
OR CMAKE_CXX_COMPILER_ID MATCHES "PathScale"
|
||||||
|
OR CMAKE_SYSTEM_NAME MATCHES "IRIX64"
|
||||||
|
OR CMAKE_CXX_COMPILER_ID MATCHES "Intel")
|
||||||
|
set(run_pic_test 0)
|
||||||
|
else()
|
||||||
|
set(run_pic_test 1)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (run_pic_test)
|
||||||
|
target_compile_definitions(deps_shared_iface PRIVATE CHECK_PIC_WORKS)
|
||||||
|
endif()
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
# Test that targets imported from the build tree have their dependencies
|
# Test that targets imported from the build tree have their dependencies
|
||||||
# evaluated correctly. The above already tests the same for the install tree.
|
# evaluated correctly. The above already tests the same for the install tree.
|
||||||
|
@ -2,6 +2,12 @@
|
|||||||
|
|
||||||
#include "testSharedLibDepends.h"
|
#include "testSharedLibDepends.h"
|
||||||
|
|
||||||
|
#ifdef CHECK_PIC_WORKS
|
||||||
|
#if defined(__ELF__) && !defined(__PIC__) && !defined(__PIE__)
|
||||||
|
#error Expected by INTERFACE_POSITION_INDEPENDENT_CODE property of dependency
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef TEST_SUBDIR_LIB
|
#ifdef TEST_SUBDIR_LIB
|
||||||
#include "subdir.h"
|
#include "subdir.h"
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user