Merge topic 'export-interface-source-files'

f7e33820 Add release notes for export-interface-source-files.
6da65b39 Allow export of targets with INTERFACE_SOURCES.
736bcb96 Tests: Move IfacePaths test stderr files.
d9f8390d Tests: Run IfacePaths tests with a parameter.
cc152094 Tests: Split part of include_directories test to a generic location.
This commit is contained in:
Brad King 2015-02-11 09:59:30 -05:00 committed by CMake Topic Stage
commit 108e94ecf1
72 changed files with 488 additions and 291 deletions

View File

@ -22,10 +22,6 @@ items will populate the :prop_tgt:`SOURCES` property of
following arguments specify sources. Repeated calls for the same
``<target>`` append items in the order called.
Targets with :prop_tgt:`INTERFACE_SOURCES` may not be exported with the
:command:`export` or :command:`install(EXPORT)` commands. This limitation may be
lifted in a future version of CMake.
Arguments to ``target_sources`` may use "generator expressions"
with the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)`
manual for available expressions. See the :manual:`cmake-buildsystem(7)`

View File

@ -12,10 +12,6 @@ When target dependencies are specified using :command:`target_link_libraries`,
CMake will read this property from all target dependencies to determine the
sources of the consumer.
Targets with ``INTERFACE_SOURCES`` may not be exported with the
:command:`export` or :command:`install(EXPORT)` commands. This limitation may be
lifted in a future version of CMake.
Contents of ``INTERFACE_SOURCES`` may use "generator expressions"
with the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)`
manual for available expressions. See the :manual:`cmake-buildsystem(7)`

View File

@ -0,0 +1,6 @@
export-interface-source-files
-----------------------------
* It is now possible to export targets which populate the
:prop_tgt:`INTERFACE_SOURCES` target property using the
:command:`install(EXPORT)` and :command:`export()` commands.

View File

@ -68,16 +68,6 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os)
tei != this->Exports.end(); ++tei)
{
cmTarget* te = *tei;
if (te->GetProperty("INTERFACE_SOURCES"))
{
std::ostringstream e;
e << "Target \""
<< te->GetName()
<< "\" has a populated INTERFACE_SOURCES property. This is not "
"currently supported.";
cmSystemTools::Error(e.str().c_str());
return false;
}
this->GenerateImportTargetCode(os, te);
te->AppendBuildInterfaceIncludes();
@ -87,6 +77,9 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os)
this->PopulateInterfaceProperty("INTERFACE_INCLUDE_DIRECTORIES", te,
cmGeneratorExpression::BuildInterface,
properties, missingTargets);
this->PopulateInterfaceProperty("INTERFACE_SOURCES", te,
cmGeneratorExpression::BuildInterface,
properties, missingTargets);
this->PopulateInterfaceProperty("INTERFACE_COMPILE_DEFINITIONS", te,
cmGeneratorExpression::BuildInterface,
properties, missingTargets);

View File

@ -224,7 +224,7 @@ static bool isSubDirectory(const char* a, const char* b)
//----------------------------------------------------------------------------
static bool checkInterfaceDirs(const std::string &prepro,
cmTarget *target)
cmTarget *target, const std::string& prop)
{
const char* installDir =
target->GetMakefile()->GetSafeDefinition("CMAKE_INSTALL_PREFIX");
@ -250,20 +250,27 @@ static bool checkInterfaceDirs(const std::string &prepro,
std::ostringstream e;
if (genexPos != std::string::npos)
{
switch (target->GetPolicyStatusCMP0041())
if (prop == "INTERFACE_INCLUDE_DIRECTORIES")
{
case cmPolicies::WARN:
messageType = cmake::WARNING;
e << target->GetMakefile()->GetPolicies()
->GetPolicyWarning(cmPolicies::CMP0041) << "\n";
break;
case cmPolicies::OLD:
continue;
case cmPolicies::REQUIRED_IF_USED:
case cmPolicies::REQUIRED_ALWAYS:
case cmPolicies::NEW:
hadFatalError = true;
break; // Issue fatal message.
switch (target->GetPolicyStatusCMP0041())
{
case cmPolicies::WARN:
messageType = cmake::WARNING;
e << target->GetMakefile()->GetPolicies()
->GetPolicyWarning(cmPolicies::CMP0041) << "\n";
break;
case cmPolicies::OLD:
continue;
case cmPolicies::REQUIRED_IF_USED:
case cmPolicies::REQUIRED_ALWAYS:
case cmPolicies::NEW:
hadFatalError = true;
break; // Issue fatal message.
}
}
else
{
hadFatalError = true;
}
}
if (cmHasLiteralPrefix(li->c_str(), "${_IMPORT_PREFIX}"))
@ -272,8 +279,8 @@ static bool checkInterfaceDirs(const std::string &prepro,
}
if (!cmSystemTools::FileIsFullPath(li->c_str()))
{
e << "Target \"" << target->GetName() << "\" "
"INTERFACE_INCLUDE_DIRECTORIES property contains relative path:\n"
e << "Target \"" << target->GetName() << "\" " << prop <<
" property contains relative path:\n"
" \"" << *li << "\"";
target->GetMakefile()->IssueMessage(messageType, e.str());
}
@ -289,32 +296,35 @@ static bool checkInterfaceDirs(const std::string &prepro,
(!inBinary || isSubDirectory(installDir, topBinaryDir)) &&
(!inSource || isSubDirectory(installDir, topSourceDir));
if (!shouldContinue)
if (prop == "INTERFACE_INCLUDE_DIRECTORIES")
{
switch(target->GetPolicyStatusCMP0052())
if (!shouldContinue)
{
case cmPolicies::WARN:
switch(target->GetPolicyStatusCMP0052())
{
std::ostringstream s;
s << target->GetMakefile()->GetPolicies()
->GetPolicyWarning(cmPolicies::CMP0052) << "\n";
s << "Directory:\n \"" << *li << "\"\nin "
"INTERFACE_INCLUDE_DIRECTORIES of target \""
<< target->GetName() << "\" is a subdirectory of the install "
"directory:\n \"" << installDir << "\"\nhowever it is also "
"a subdirectory of the " << (inBinary ? "build" : "source")
<< " tree:\n \"" << (inBinary ? topBinaryDir : topSourceDir)
<< "\"" << std::endl;
target->GetMakefile()->IssueMessage(cmake::AUTHOR_WARNING,
s.str());
case cmPolicies::WARN:
{
std::ostringstream s;
s << target->GetMakefile()->GetPolicies()
->GetPolicyWarning(cmPolicies::CMP0052) << "\n";
s << "Directory:\n \"" << *li << "\"\nin "
"INTERFACE_INCLUDE_DIRECTORIES of target \""
<< target->GetName() << "\" is a subdirectory of the install "
"directory:\n \"" << installDir << "\"\nhowever it is also "
"a subdirectory of the " << (inBinary ? "build" : "source")
<< " tree:\n \"" << (inBinary ? topBinaryDir : topSourceDir)
<< "\"" << std::endl;
target->GetMakefile()->IssueMessage(cmake::AUTHOR_WARNING,
s.str());
}
case cmPolicies::OLD:
shouldContinue = true;
break;
case cmPolicies::REQUIRED_ALWAYS:
case cmPolicies::REQUIRED_IF_USED:
case cmPolicies::NEW:
break;
}
case cmPolicies::OLD:
shouldContinue = true;
break;
case cmPolicies::REQUIRED_ALWAYS:
case cmPolicies::REQUIRED_IF_USED:
case cmPolicies::NEW:
break;
}
}
if (shouldContinue)
@ -324,8 +334,8 @@ static bool checkInterfaceDirs(const std::string &prepro,
}
if (inBinary)
{
e << "Target \"" << target->GetName() << "\" "
"INTERFACE_INCLUDE_DIRECTORIES property contains path:\n"
e << "Target \"" << target->GetName() << "\" " << prop <<
" property contains path:\n"
" \"" << *li << "\"\nwhich is prefixed in the build directory.";
target->GetMakefile()->IssueMessage(messageType, e.str());
}
@ -333,8 +343,8 @@ static bool checkInterfaceDirs(const std::string &prepro,
{
if (inSource)
{
e << "Target \"" << target->GetName() << "\" "
"INTERFACE_INCLUDE_DIRECTORIES property contains path:\n"
e << "Target \"" << target->GetName() << "\" " << prop <<
" property contains path:\n"
" \"" << *li << "\"\nwhich is prefixed in the source directory.";
target->GetMakefile()->IssueMessage(messageType, e.str());
}
@ -364,6 +374,46 @@ static void prefixItems(std::string &exportDirs)
}
}
//----------------------------------------------------------------------------
void cmExportFileGenerator::PopulateSourcesInterface(
cmTargetExport *tei,
cmGeneratorExpression::PreprocessContext preprocessRule,
ImportPropertyMap &properties,
std::vector<std::string> &missingTargets)
{
cmTarget *target = tei->Target;
assert(preprocessRule == cmGeneratorExpression::InstallInterface);
const char *propName = "INTERFACE_SOURCES";
const char *input = target->GetProperty(propName);
if (!input)
{
return;
}
if (!*input)
{
properties[propName] = "";
return;
}
std::string prepro = cmGeneratorExpression::Preprocess(input,
preprocessRule,
true);
if (!prepro.empty())
{
this->ResolveTargetsInGeneratorExpressions(prepro, target,
missingTargets);
if (!checkInterfaceDirs(prepro, target, propName))
{
return;
}
properties[propName] = prepro;
}
}
//----------------------------------------------------------------------------
void cmExportFileGenerator::PopulateIncludeDirectoriesInterface(
cmTargetExport *tei,
@ -424,7 +474,7 @@ void cmExportFileGenerator::PopulateIncludeDirectoriesInterface(
this->ResolveTargetsInGeneratorExpressions(prepro, target,
missingTargets);
if (!checkInterfaceDirs(prepro, target))
if (!checkInterfaceDirs(prepro, target, propName))
{
return;
}

View File

@ -139,6 +139,11 @@ protected:
cmGeneratorExpression::PreprocessContext preprocessRule,
ImportPropertyMap &properties,
std::vector<std::string> &missingTargets);
void PopulateSourcesInterface(
cmTargetExport *target,
cmGeneratorExpression::PreprocessContext preprocessRule,
ImportPropertyMap &properties,
std::vector<std::string> &missingTargets);
void SetImportLinkInterface(const std::string& config,
std::string const& suffix,

View File

@ -123,6 +123,7 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
bool require2_8_12 = false;
bool require3_0_0 = false;
bool require3_1_0 = false;
bool requiresConfigFiles = false;
// Create all the imported targets.
for(std::vector<cmTargetExport*>::const_iterator
@ -131,17 +132,6 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
{
cmTarget* te = (*tei)->Target;
if (te->GetProperty("INTERFACE_SOURCES"))
{
std::ostringstream e;
e << "Target \""
<< te->GetName()
<< "\" has a populated INTERFACE_SOURCES property. This is not "
"currently supported.";
cmSystemTools::Error(e.str().c_str());
return false;
}
requiresConfigFiles = requiresConfigFiles
|| te->GetType() != cmTarget::INTERFACE_LIBRARY;
@ -152,6 +142,9 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
this->PopulateIncludeDirectoriesInterface(*tei,
cmGeneratorExpression::InstallInterface,
properties, missingTargets);
this->PopulateSourcesInterface(*tei,
cmGeneratorExpression::InstallInterface,
properties, missingTargets);
this->PopulateInterfaceProperty("INTERFACE_SYSTEM_INCLUDE_DIRECTORIES",
te,
cmGeneratorExpression::InstallInterface,
@ -190,6 +183,13 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
{
require3_0_0 = true;
}
if(te->GetProperty("INTERFACE_SOURCES"))
{
// We can only generate INTERFACE_SOURCES in CMake 3.3, but CMake 3.1
// can consume them.
require3_1_0 = true;
}
this->PopulateInterfaceProperty("INTERFACE_POSITION_INDEPENDENT_CODE",
te, properties);
this->PopulateCompatibleInterfaceProperties(te, properties);
@ -197,7 +197,11 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
this->GenerateInterfaceProperties(te, os, properties);
}
if (require3_0_0)
if (require3_1_0)
{
this->GenerateRequiredCMakeVersion(os, "3.1.0");
}
else if (require3_0_0)
{
this->GenerateRequiredCMakeVersion(os, "3.0.0");
}

View File

@ -29,7 +29,17 @@ target_compile_features(use_auto_type INTERFACE cxx_auto_type)
add_library(use_c_restrict INTERFACE)
target_compile_features(use_c_restrict INTERFACE c_restrict)
install(TARGETS headeronly sharediface use_auto_type use_c_restrict
add_library(source_target INTERFACE)
target_sources(source_target INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/source_target.cpp>
$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/src/source_target_for_install.cpp>
)
install(FILES
source_target_for_install.cpp
DESTINATION src
)
install(TARGETS headeronly sharediface use_auto_type use_c_restrict source_target
EXPORT expInterface
)
install(TARGETS sharedlib

View File

@ -0,0 +1,13 @@
#ifndef USE_FROM_BUILD_DIR
#error Expected define USE_FROM_BUILD_DIR
#endif
#ifdef USE_FROM_INSTALL_DIR
#error Unexpected define USE_FROM_INSTALL_DIR
#endif
int source_symbol()
{
return 42;
}

View File

@ -0,0 +1,13 @@
#ifdef USE_FROM_BUILD_DIR
#error Unexpected define USE_FROM_BUILD_DIR
#endif
#ifndef USE_FROM_INSTALL_DIR
#error Expected define USE_FROM_INSTALL_DIR
#endif
int source_symbol()
{
return 42;
}

View File

@ -82,6 +82,14 @@ endmacro()
do_try_compile(bld)
add_executable(source_target_test_bld source_target_test.cpp)
target_link_libraries(source_target_test_bld bld::source_target)
target_compile_definitions(source_target_test_bld PRIVATE USE_FROM_BUILD_DIR)
add_executable(source_target_test_exp source_target_test.cpp)
target_link_libraries(source_target_test_exp exp::source_target)
target_compile_definitions(source_target_test_exp PRIVATE USE_FROM_INSTALL_DIR)
add_executable(headeronlytest_exp headeronlytest.cpp)
target_link_libraries(headeronlytest_exp exp::headeronly)

View File

@ -0,0 +1,7 @@
extern int source_symbol();
int main()
{
return source_symbol() - 42;
}

View File

@ -189,6 +189,12 @@ add_RunCMake_test(install)
add_RunCMake_test(CPackInstallProperties)
add_RunCMake_test(ExternalProject)
set(IfacePaths_INCLUDE_DIRECTORIES_ARGS -DTEST_PROP=INCLUDE_DIRECTORIES)
add_RunCMake_test(IfacePaths_INCLUDE_DIRECTORIES TEST_DIR IfacePaths)
set(IfacePaths_SOURCES_ARGS -DTEST_PROP=SOURCES)
add_RunCMake_test(IfacePaths_SOURCES TEST_DIR IfacePaths)
if(RPMBUILD)
add_RunCMake_test(CPackRPM)
endif()

View File

@ -1,6 +1,6 @@
CMake Error in CMakeLists.txt:
Target "testTarget" INTERFACE_INCLUDE_DIRECTORIES property contains path:
".*Tests/RunCMake/include_directories/prefix/BinInInstallPrefix-CMP0052-NEW-build/foo"
".*Tests/RunCMake/IfacePaths_INCLUDE_DIRECTORIES/prefix/BinInInstallPrefix-CMP0052-NEW-build/foo"
which is prefixed in the build directory.

View File

@ -6,15 +6,15 @@ CMake Warning \(dev\) in CMakeLists.txt:
Directory:
".*Tests/RunCMake/include_directories/prefix/BinInInstallPrefix-CMP0052-WARN-build/foo"
".*Tests/RunCMake/IfacePaths_INCLUDE_DIRECTORIES/prefix/BinInInstallPrefix-CMP0052-WARN-build/foo"
in INTERFACE_INCLUDE_DIRECTORIES of target "testTarget" is a subdirectory
of the install directory:
".*Tests/RunCMake/include_directories/prefix"
".*Tests/RunCMake/IfacePaths_INCLUDE_DIRECTORIES/prefix"
however it is also a subdirectory of the build tree:
".*Tests/RunCMake/include_directories/prefix/BinInInstallPrefix-CMP0052-WARN-build"
".*Tests/RunCMake/IfacePaths_INCLUDE_DIRECTORIES/prefix/BinInInstallPrefix-CMP0052-WARN-build"
This warning is for project developers. Use -Wno-dev to suppress it.

View File

@ -0,0 +1,6 @@
CMake Error in CMakeLists.txt:
Target "testTarget" INTERFACE_SOURCES property contains path:
".*Tests/RunCMake/IfacePaths_SOURCES/prefix/BinInInstallPrefix-build/empty.cpp"
which is prefixed in the build directory.

View File

@ -1,6 +1,6 @@
CMake Error in CMakeLists.txt:
Target "testTarget" INTERFACE_INCLUDE_DIRECTORIES property contains path:
".*Tests/RunCMake/include_directories/InstallInBinDir-build/foo"
".*RunCMake/IfacePaths_INCLUDE_DIRECTORIES/BinaryDirectoryInInterface-build/foo"
which is prefixed in the build directory.

View File

@ -0,0 +1,6 @@
CMake Error in CMakeLists.txt:
Target "testTarget" INTERFACE_SOURCES property contains path:
".*Tests/RunCMake/IfacePaths_SOURCES/BinaryDirectoryInInterface-build/empty.cpp"
which is prefixed in the build directory.

View File

@ -0,0 +1,15 @@
enable_language(CXX)
add_library(testTarget "${CMAKE_CURRENT_SOURCE_DIR}/empty.cpp")
if (TEST_PROP STREQUAL INCLUDE_DIRECTORIES)
set_property(TARGET testTarget PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}/foo")
else()
set_property(TARGET testTarget PROPERTY INTERFACE_SOURCES "${CMAKE_CURRENT_BINARY_DIR}/empty.cpp")
endif()
install(TARGETS testTarget EXPORT testTargets
DESTINATION lib
)
install(EXPORT testTargets DESTINATION lib/cmake)

View File

@ -0,0 +1,6 @@
cmake_minimum_required(VERSION 3.0)
project(${RunCMake_TEST} NONE)
if(NOT TEST_FILE)
set(TEST_FILE ${RunCMake_TEST}.cmake)
endif()
include(${TEST_FILE})

View File

@ -0,0 +1,14 @@
enable_language(CXX)
add_library(testTarget empty.cpp)
if (TEST_PROP STREQUAL INCLUDE_DIRECTORIES)
set_property(TARGET testTarget PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/dir")
else()
set_property(TARGET testTarget PROPERTY INTERFACE_SOURCES "${CMAKE_INSTALL_PREFIX}/empty.cpp")
endif()
install(TARGETS testTarget EXPORT testTargets
DESTINATION lib
)
install(EXPORT testTargets DESTINATION lib/cmake)

View File

@ -1,6 +1,6 @@
CMake Error in CMakeLists.txt:
Target "testTarget" INTERFACE_INCLUDE_DIRECTORIES property contains path:
".*RunCMake/include_directories/BinaryDirectoryInInterface-build/foo"
".*Tests/RunCMake/IfacePaths_INCLUDE_DIRECTORIES/InstallInBinDir-build/foo"
which is prefixed in the build directory.

View File

@ -0,0 +1,6 @@
CMake Error in CMakeLists.txt:
Target "testTarget" INTERFACE_SOURCES property contains path:
".*Tests/RunCMake/IfacePaths_SOURCES/InstallInBinDir-build/empty.cpp"
which is prefixed in the build directory.

View File

@ -1,6 +1,6 @@
CMake Error in CMakeLists.txt:
Target "testTarget" INTERFACE_INCLUDE_DIRECTORIES property contains path:
".*Tests/RunCMake/include_directories/prefix/src/foo"
".*Tests/RunCMake/IfacePaths_INCLUDE_DIRECTORIES/copy/foo"
which is prefixed in the source directory.

View File

@ -0,0 +1,6 @@
CMake Error in CMakeLists.txt:
Target "testTarget" INTERFACE_SOURCES property contains path:
".*Tests/RunCMake/IfacePaths_SOURCES/copy/empty.cpp"
which is prefixed in the source directory.

View File

@ -0,0 +1,4 @@
CMake Error in CMakeLists.txt:
Target "testTarget" contains relative path in its INTERFACE_SOURCES:
"empty.cpp"

View File

@ -0,0 +1,13 @@
enable_language(CXX)
add_library(testTarget "${CMAKE_CURRENT_SOURCE_DIR}/empty.cpp")
if (TEST_PROP STREQUAL INCLUDE_DIRECTORIES)
set_property(TARGET testTarget PROPERTY INTERFACE_INCLUDE_DIRECTORIES "$<1:foo>")
else()
set_property(TARGET testTarget PROPERTY INTERFACE_SOURCES "$<1:empty.cpp>")
endif()
add_library(userTarget "${CMAKE_CURRENT_SOURCE_DIR}/empty.cpp")
target_link_libraries(userTarget testTarget)

View File

@ -0,0 +1,4 @@
CMake Error in CMakeLists.txt:
Target "testTarget" INTERFACE_SOURCES property contains relative path:
"empty.cpp"

View File

@ -0,0 +1,14 @@
enable_language(CXX)
add_library(testTarget "${CMAKE_CURRENT_SOURCE_DIR}/empty.cpp")
if (TEST_PROP STREQUAL INCLUDE_DIRECTORIES)
set_property(TARGET testTarget PROPERTY INTERFACE_INCLUDE_DIRECTORIES "foo")
else()
set_property(TARGET testTarget PROPERTY INTERFACE_SOURCES "empty.cpp")
endif()
install(TARGETS testTarget EXPORT testTargets
DESTINATION lib
)
install(EXPORT testTargets DESTINATION lib/cmake)

View File

@ -0,0 +1,156 @@
include(RunCMake)
macro(run_cmake test)
list(APPEND RunCMake_TEST_OPTIONS -DTEST_PROP=${TEST_PROP})
set(RunCMake-stderr-file ${test}-stderr_${TEST_PROP}.txt)
_run_cmake(${test})
endmacro()
run_cmake(RelativePathInInterface)
run_cmake(RelativePathInGenex)
run_cmake(export-NOWARN)
run_cmake(SourceDirectoryInInterface)
run_cmake(BinaryDirectoryInInterface)
set(RunCMake_TEST_OPTIONS "-DCMAKE_INSTALL_PREFIX=${RunCMake_BINARY_DIR}/DirInInstallPrefix/prefix")
run_cmake(DirInInstallPrefix)
configure_file(
"${RunCMake_SOURCE_DIR}/CMakeLists.txt"
"${RunCMake_BINARY_DIR}/copy/CMakeLists.txt"
COPYONLY
)
configure_file(
"${RunCMake_SOURCE_DIR}/empty.cpp"
"${RunCMake_BINARY_DIR}/copy/empty.cpp"
COPYONLY
)
configure_file(
"${RunCMake_SOURCE_DIR}/SourceDirectoryInInterface.cmake"
"${RunCMake_BINARY_DIR}/copy/SourceDirectoryInInterface.cmake"
COPYONLY
)
set(RunCMake_TEST_OPTIONS
"-DCMAKE_INSTALL_PREFIX=${RunCMake_BINARY_DIR}/copy/SourceDirectoryInInterface/prefix"
"-DTEST_FILE=${RunCMake_BINARY_DIR}/copy/SourceDirectoryInInterface.cmake"
)
set(RunCMake_TEST_SOURCE_DIR "${RunCMake_BINARY_DIR}/copy")
run_cmake(InstallInSrcDir)
unset(RunCMake_TEST_SOURCE_DIR)
set(RunCMake_TEST_OPTIONS "-DCMAKE_INSTALL_PREFIX=${RunCMake_BINARY_DIR}/InstallInBinDir-build/prefix")
set(RunCMake_TEST_OPTIONS
"-DCMAKE_INSTALL_PREFIX=${RunCMake_BINARY_DIR}/InstallInBinDir-build/prefix"
"-DTEST_FILE=${RunCMake_SOURCE_DIR}/BinaryDirectoryInInterface.cmake"
)
set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/InstallInBinDir-build")
run_cmake(InstallInBinDir)
unset(RunCMake_TEST_BINARY_DIR)
configure_file(
"${RunCMake_SOURCE_DIR}/CMakeLists.txt"
"${RunCMake_BINARY_DIR}/prefix/src/CMakeLists.txt"
COPYONLY
)
configure_file(
"${RunCMake_SOURCE_DIR}/empty.cpp"
"${RunCMake_BINARY_DIR}/prefix/src/empty.cpp"
COPYONLY
)
configure_file(
"${RunCMake_SOURCE_DIR}/SourceDirectoryInInterface.cmake"
"${RunCMake_BINARY_DIR}/prefix/src/SourceDirectoryInInterface.cmake"
COPYONLY
)
foreach(policyStatus NEW OLD "")
if (TEST_PROP STREQUAL INCLUDE_DIRECTORIES)
if (NOT "${policyStatus}" STREQUAL "")
set(policyOption -DCMAKE_POLICY_DEFAULT_CMP0052=${policyStatus})
else()
unset(policyOption)
set(policyStatus WARN)
endif()
set(policySuffix -CMP0052-${policyStatus})
endif()
set(RunCMake_TEST_OPTIONS
"-DCMAKE_INSTALL_PREFIX=${RunCMake_BINARY_DIR}/prefix" ${policyOption}
"-DTEST_FILE=${RunCMake_SOURCE_DIR}/BinaryDirectoryInInterface.cmake"
)
# Set the RunCMake_TEST_SOURCE_DIR here to the copy too. This is needed to run
# the test suite in-source properly. Otherwise the install directory would be
# a subdirectory or the source directory, which is allowed and tested separately
# below.
set(RunCMake_TEST_SOURCE_DIR "${RunCMake_BINARY_DIR}/prefix/src")
set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/prefix/BinInInstallPrefix${policySuffix}-build")
run_cmake(BinInInstallPrefix${policySuffix})
unset(RunCMake_TEST_BINARY_DIR)
set(RunCMake_TEST_OPTIONS
"-DCMAKE_INSTALL_PREFIX=${RunCMake_BINARY_DIR}/prefix" ${policyOption}
"-DTEST_FILE=${RunCMake_BINARY_DIR}/prefix/src/SourceDirectoryInInterface.cmake"
)
run_cmake(SrcInInstallPrefix${policySuffix})
unset(RunCMake_TEST_SOURCE_DIR)
if (NOT TEST_PROP STREQUAL INCLUDE_DIRECTORIES)
break()
endif()
endforeach()
set(RunCMake_TEST_OPTIONS "-DCMAKE_INSTALL_PREFIX=${RunCMake_BINARY_DIR}/InstallPrefixInInterface-build/prefix")
run_cmake(InstallPrefixInInterface)
configure_file(
"${RunCMake_SOURCE_DIR}/CMakeLists.txt"
"${RunCMake_BINARY_DIR}/installToSrc/CMakeLists.txt"
COPYONLY
)
configure_file(
"${RunCMake_SOURCE_DIR}/empty.cpp"
"${RunCMake_BINARY_DIR}/installToSrc/empty.cpp"
COPYONLY
)
configure_file(
"${RunCMake_SOURCE_DIR}/InstallPrefixInInterface.cmake"
"${RunCMake_BINARY_DIR}/installToSrc/InstallPrefixInInterface.cmake"
COPYONLY
)
set(RunCMake_TEST_OPTIONS
"-DCMAKE_INSTALL_PREFIX=${RunCMake_BINARY_DIR}/installToSrc/InstallPrefixInInterface/prefix"
"-DTEST_FILE=${RunCMake_BINARY_DIR}/installToSrc/InstallPrefixInInterface.cmake"
)
set(RunCMake_TEST_SOURCE_DIR "${RunCMake_BINARY_DIR}/installToSrc")
run_cmake(InstallToPrefixInSrcDirOutOfSource)
unset(RunCMake_TEST_SOURCE_DIR)
file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}/installToSrcInSrc")
set(RunCMake_TEST_NO_CLEAN ON)
configure_file(
"${RunCMake_SOURCE_DIR}/CMakeLists.txt"
"${RunCMake_BINARY_DIR}/installToSrcInSrc/CMakeLists.txt"
COPYONLY
)
configure_file(
"${RunCMake_SOURCE_DIR}/empty.cpp"
"${RunCMake_BINARY_DIR}/installToSrcInSrc/empty.cpp"
COPYONLY
)
configure_file(
"${RunCMake_SOURCE_DIR}/InstallPrefixInInterface.cmake"
"${RunCMake_BINARY_DIR}/installToSrcInSrc/InstallPrefixInInterface.cmake"
COPYONLY
)
set(RunCMake_TEST_OPTIONS
"-DCMAKE_INSTALL_PREFIX=${RunCMake_BINARY_DIR}/installToSrcInSrc/InstallPrefixInInterface/prefix"
"-DTEST_FILE=${RunCMake_BINARY_DIR}/installToSrcInSrc/InstallPrefixInInterface.cmake"
)
set(RunCMake_TEST_SOURCE_DIR "${RunCMake_BINARY_DIR}/installToSrcInSrc")
set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/installToSrcInSrc")
run_cmake(InstallToPrefixInSrcDirInSource)
unset(RunCMake_TEST_SOURCE_DIR)
unset(RunCMake_TEST_BINARY_DIR)
unset(RunCMake_TEST_NO_CLEAN)

View File

@ -1,6 +1,6 @@
CMake Error in CMakeLists.txt:
Target "testTarget" INTERFACE_INCLUDE_DIRECTORIES property contains path:
".*RunCMake/include_directories/foo"
".*RunCMake/IfacePaths/foo"
which is prefixed in the source directory.

View File

@ -0,0 +1,6 @@
CMake Error in CMakeLists.txt:
Target "testTarget" INTERFACE_SOURCES property contains path:
".*Tests/RunCMake/IfacePaths/empty.cpp"
which is prefixed in the source directory.

View File

@ -0,0 +1,15 @@
enable_language(CXX)
add_library(testTarget "${CMAKE_CURRENT_SOURCE_DIR}/empty.cpp")
if (TEST_PROP STREQUAL INCLUDE_DIRECTORIES)
set_property(TARGET testTarget PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/foo")
else()
set_property(TARGET testTarget PROPERTY INTERFACE_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/empty.cpp")
endif()
install(TARGETS testTarget EXPORT testTargets
DESTINATION lib
)
install(EXPORT testTargets DESTINATION lib/cmake)

View File

@ -1,6 +1,6 @@
CMake Error in CMakeLists.txt:
Target "testTarget" INTERFACE_INCLUDE_DIRECTORIES property contains path:
".*Tests/RunCMake/include_directories/copy/foo"
".*Tests/RunCMake/IfacePaths_INCLUDE_DIRECTORIES/prefix/src/foo"
which is prefixed in the source directory.

View File

@ -6,15 +6,15 @@ CMake Warning \(dev\) in CMakeLists.txt:
Directory:
".*Tests/RunCMake/include_directories/prefix/src/foo"
".*Tests/RunCMake/IfacePaths_INCLUDE_DIRECTORIES/prefix/src/foo"
in INTERFACE_INCLUDE_DIRECTORIES of target "testTarget" is a subdirectory
of the install directory:
".*Tests/RunCMake/include_directories/prefix"
".*Tests/RunCMake/IfacePaths_INCLUDE_DIRECTORIES/prefix"
however it is also a subdirectory of the source tree:
".*Tests/RunCMake/include_directories/prefix/src"
".*Tests/RunCMake/IfacePaths_INCLUDE_DIRECTORIES/prefix/src"
This warning is for project developers. Use -Wno-dev to suppress it.

View File

@ -0,0 +1 @@
1

View File

@ -0,0 +1,6 @@
CMake Error in CMakeLists.txt:
Target "testTarget" INTERFACE_SOURCES property contains path:
".*Tests/RunCMake/IfacePaths_SOURCES/prefix/src/empty.cpp"
which is prefixed in the source directory.

View File

View File

@ -1,19 +1,34 @@
enable_language(CXX)
add_library(foo empty.cpp)
set_property(TARGET foo APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES $<0:>/include/subdir)
set_property(TARGET foo APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES $<INSTALL_PREFIX>/include/subdir)
set_property(TARGET foo APPEND PROPERTY INTERFACE_SOURCES $<0:>/include/subdir/empty.cpp)
set_property(TARGET foo APPEND PROPERTY INTERFACE_SOURCES $<INSTALL_PREFIX>/include/subdir/empty.cpp)
set_property(TARGET foo APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES $<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include/subdir>)
set_property(TARGET foo APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES $<INSTALL_INTERFACE:include/subdir>)
set_property(TARGET foo APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES $<INSTALL_INTERFACE:include/$<0:>>)
set_property(TARGET foo APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES $<INSTALL_INTERFACE:$<0:>/include>)
set_property(TARGET foo APPEND PROPERTY INTERFACE_SOURCES $<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include/subdir/empty.cpp>)
set_property(TARGET foo APPEND PROPERTY INTERFACE_SOURCES $<INSTALL_INTERFACE:include/subdir/empty.cpp>)
set_property(TARGET foo APPEND PROPERTY INTERFACE_SOURCES $<INSTALL_INTERFACE:include/subdir/empty.cpp$<0:>>)
set_property(TARGET foo APPEND PROPERTY INTERFACE_SOURCES $<INSTALL_INTERFACE:$<0:>/include/subdir/empty.cpp>)
# target_include_directories(foo INTERFACE include/subdir) # Does and should warn. INSTALL_INTERFACE must not list src dir paths.
target_include_directories(foo INTERFACE $<0:>/include/subdir) # Does not and should not should warn, because it starts with a genex.
target_include_directories(foo INTERFACE $<INSTALL_PREFIX>/include/subdir)
target_sources(foo INTERFACE $<0:>/include/subdir/empty.cpp)
target_sources(foo INTERFACE $<INSTALL_PREFIX>/include/subdir/empty.cpp)
target_include_directories(foo INTERFACE $<INSTALL_INTERFACE:include/subdir>)
target_include_directories(foo INTERFACE $<INSTALL_INTERFACE:include/$<0:>>)
target_sources(foo INTERFACE $<INSTALL_INTERFACE:include/subdir/empty.cpp>)
target_sources(foo INTERFACE $<INSTALL_INTERFACE:include/subdir/empty.cpp$<0:>>)
install(FILES include/subdir/empty.cpp
DESTINATION include/subdir
)
install(TARGETS foo EXPORT FooTargets DESTINATION lib)
install(EXPORT FooTargets DESTINATION lib/cmake)

View File

@ -1 +0,0 @@
CMake Error: Target "iface" has a populated INTERFACE_SOURCES property. This is not currently supported.

View File

@ -1 +0,0 @@
CMake Error: Target "iface" has a populated INTERFACE_SOURCES property. This is not currently supported.

View File

@ -1,6 +0,0 @@
add_library(iface INTERFACE)
target_sources(iface INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/empty_1.cpp")
install(TARGETS iface EXPORT exp)
install(EXPORT exp DESTINATION cmake)

View File

@ -10,4 +10,3 @@ endif()
run_cmake(CMP0026-LOCATION)
run_cmake(RelativePathInInterface)
run_cmake(ExportBuild)
run_cmake(ExportInstall)

View File

@ -1,11 +0,0 @@
enable_language(CXX)
add_library(testTarget "${CMAKE_CURRENT_SOURCE_DIR}/empty.cpp")
target_include_directories(testTarget INTERFACE "${CMAKE_CURRENT_BINARY_DIR}/foo")
install(TARGETS testTarget EXPORT testTargets
DESTINATION lib
)
install(EXPORT testTargets DESTINATION lib/cmake)

View File

@ -1,6 +1,3 @@
cmake_minimum_required(VERSION 3.0)
project(${RunCMake_TEST} NONE)
if(NOT TEST_FILE)
set(TEST_FILE ${RunCMake_TEST}.cmake)
endif()
include(${TEST_FILE})
include(${RunCMake_TEST}.cmake)

View File

@ -1,9 +0,0 @@
enable_language(CXX)
add_library(testTarget empty.cpp)
target_include_directories(testTarget INTERFACE "${CMAKE_INSTALL_PREFIX}/dir")
install(TARGETS testTarget EXPORT testTargets
DESTINATION lib
)
install(EXPORT testTargets DESTINATION lib/cmake)

View File

@ -1,8 +0,0 @@
enable_language(CXX)
add_library(testTarget "${CMAKE_CURRENT_SOURCE_DIR}/empty.cpp")
set_property(TARGET testTarget PROPERTY INTERFACE_INCLUDE_DIRECTORIES "$<1:foo>")
add_library(userTarget "${CMAKE_CURRENT_SOURCE_DIR}/empty.cpp")
target_link_libraries(userTarget testTarget)

View File

@ -1,11 +0,0 @@
enable_language(CXX)
add_library(testTarget "${CMAKE_CURRENT_SOURCE_DIR}/empty.cpp")
set_property(TARGET testTarget PROPERTY INTERFACE_INCLUDE_DIRECTORIES "foo")
install(TARGETS testTarget EXPORT testTargets
DESTINATION lib
)
install(EXPORT testTargets DESTINATION lib/cmake)

View File

@ -3,148 +3,7 @@ include(RunCMake)
run_cmake(NotFoundContent)
run_cmake(DebugIncludes)
run_cmake(TID-bad-target)
run_cmake(SourceDirectoryInInterface)
run_cmake(BinaryDirectoryInInterface)
run_cmake(RelativePathInInterface)
run_cmake(ImportedTarget)
run_cmake(RelativePathInGenex)
run_cmake(CMP0021)
run_cmake(install_config)
run_cmake(incomplete-genex)
run_cmake(export-NOWARN)
set(RunCMake_TEST_OPTIONS "-DCMAKE_INSTALL_PREFIX=${RunCMake_BINARY_DIR}/DirInInstallPrefix/prefix")
run_cmake(DirInInstallPrefix)
configure_file(
"${RunCMake_SOURCE_DIR}/CMakeLists.txt"
"${RunCMake_BINARY_DIR}/copy/CMakeLists.txt"
COPYONLY
)
configure_file(
"${RunCMake_SOURCE_DIR}/empty.cpp"
"${RunCMake_BINARY_DIR}/copy/empty.cpp"
COPYONLY
)
configure_file(
"${RunCMake_SOURCE_DIR}/SourceDirectoryInInterface.cmake"
"${RunCMake_BINARY_DIR}/copy/SourceDirectoryInInterface.cmake"
COPYONLY
)
set(RunCMake_TEST_OPTIONS
"-DCMAKE_INSTALL_PREFIX=${RunCMake_BINARY_DIR}/copy/SourceDirectoryInInterface/prefix"
"-DTEST_FILE=${RunCMake_BINARY_DIR}/copy/SourceDirectoryInInterface.cmake"
)
set(RunCMake_TEST_SOURCE_DIR "${RunCMake_BINARY_DIR}/copy")
run_cmake(InstallInSrcDir)
unset(RunCMake_TEST_SOURCE_DIR)
set(RunCMake_TEST_OPTIONS "-DCMAKE_INSTALL_PREFIX=${RunCMake_BINARY_DIR}/InstallInBinDir-build/prefix")
set(RunCMake_TEST_OPTIONS
"-DCMAKE_INSTALL_PREFIX=${RunCMake_BINARY_DIR}/InstallInBinDir-build/prefix"
"-DTEST_FILE=${RunCMake_SOURCE_DIR}/BinaryDirectoryInInterface.cmake"
)
set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/InstallInBinDir-build")
run_cmake(InstallInBinDir)
unset(RunCMake_TEST_BINARY_DIR)
configure_file(
"${RunCMake_SOURCE_DIR}/CMakeLists.txt"
"${RunCMake_BINARY_DIR}/prefix/src/CMakeLists.txt"
COPYONLY
)
configure_file(
"${RunCMake_SOURCE_DIR}/empty.cpp"
"${RunCMake_BINARY_DIR}/prefix/src/empty.cpp"
COPYONLY
)
configure_file(
"${RunCMake_SOURCE_DIR}/SourceDirectoryInInterface.cmake"
"${RunCMake_BINARY_DIR}/prefix/src/SourceDirectoryInInterface.cmake"
COPYONLY
)
foreach(policyStatus "" NEW OLD)
if (NOT "${policyStatus}" STREQUAL "")
set(policyOption -DCMAKE_POLICY_DEFAULT_CMP0052=${policyStatus})
else()
unset(policyOption)
set(policyStatus WARN)
endif()
set(RunCMake_TEST_OPTIONS
"-DCMAKE_INSTALL_PREFIX=${RunCMake_BINARY_DIR}/prefix" ${policyOption}
"-DTEST_FILE=${RunCMake_SOURCE_DIR}/BinaryDirectoryInInterface.cmake"
)
# Set the RunCMake_TEST_SOURCE_DIR here to the copy too. This is needed to run
# the test suite in-source properly. Otherwise the install directory would be
# a subdirectory or the source directory, which is allowed and tested separately
# below.
set(RunCMake_TEST_SOURCE_DIR "${RunCMake_BINARY_DIR}/prefix/src")
set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/prefix/BinInInstallPrefix-CMP0052-${policyStatus}-build")
run_cmake(BinInInstallPrefix-CMP0052-${policyStatus})
unset(RunCMake_TEST_BINARY_DIR)
set(RunCMake_TEST_OPTIONS
"-DCMAKE_INSTALL_PREFIX=${RunCMake_BINARY_DIR}/prefix" ${policyOption}
"-DTEST_FILE=${RunCMake_BINARY_DIR}/prefix/src/SourceDirectoryInInterface.cmake"
)
run_cmake(SrcInInstallPrefix-CMP0052-${policyStatus})
unset(RunCMake_TEST_SOURCE_DIR)
endforeach()
set(RunCMake_TEST_OPTIONS "-DCMAKE_INSTALL_PREFIX=${RunCMake_BINARY_DIR}/InstallPrefixInInterface-build/prefix")
run_cmake(InstallPrefixInInterface)
configure_file(
"${RunCMake_SOURCE_DIR}/CMakeLists.txt"
"${RunCMake_BINARY_DIR}/installToSrc/CMakeLists.txt"
COPYONLY
)
configure_file(
"${RunCMake_SOURCE_DIR}/empty.cpp"
"${RunCMake_BINARY_DIR}/installToSrc/empty.cpp"
COPYONLY
)
configure_file(
"${RunCMake_SOURCE_DIR}/InstallPrefixInInterface.cmake"
"${RunCMake_BINARY_DIR}/installToSrc/InstallPrefixInInterface.cmake"
COPYONLY
)
set(RunCMake_TEST_OPTIONS
"-DCMAKE_INSTALL_PREFIX=${RunCMake_BINARY_DIR}/installToSrc/InstallPrefixInInterface/prefix"
"-DTEST_FILE=${RunCMake_BINARY_DIR}/installToSrc/InstallPrefixInInterface.cmake"
)
set(RunCMake_TEST_SOURCE_DIR "${RunCMake_BINARY_DIR}/installToSrc")
run_cmake(InstallToPrefixInSrcDirOutOfSource)
unset(RunCMake_TEST_SOURCE_DIR)
file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}/installToSrcInSrc")
set(RunCMake_TEST_NO_CLEAN ON)
configure_file(
"${RunCMake_SOURCE_DIR}/CMakeLists.txt"
"${RunCMake_BINARY_DIR}/installToSrcInSrc/CMakeLists.txt"
COPYONLY
)
configure_file(
"${RunCMake_SOURCE_DIR}/empty.cpp"
"${RunCMake_BINARY_DIR}/installToSrcInSrc/empty.cpp"
COPYONLY
)
configure_file(
"${RunCMake_SOURCE_DIR}/InstallPrefixInInterface.cmake"
"${RunCMake_BINARY_DIR}/installToSrcInSrc/InstallPrefixInInterface.cmake"
COPYONLY
)
set(RunCMake_TEST_OPTIONS
"-DCMAKE_INSTALL_PREFIX=${RunCMake_BINARY_DIR}/installToSrcInSrc/InstallPrefixInInterface/prefix"
"-DTEST_FILE=${RunCMake_BINARY_DIR}/installToSrcInSrc/InstallPrefixInInterface.cmake"
)
set(RunCMake_TEST_SOURCE_DIR "${RunCMake_BINARY_DIR}/installToSrcInSrc")
set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/installToSrcInSrc")
run_cmake(InstallToPrefixInSrcDirInSource)
unset(RunCMake_TEST_SOURCE_DIR)
unset(RunCMake_TEST_BINARY_DIR)
unset(RunCMake_TEST_NO_CLEAN)

View File

@ -1,11 +0,0 @@
enable_language(CXX)
add_library(testTarget "${CMAKE_CURRENT_SOURCE_DIR}/empty.cpp")
target_include_directories(testTarget INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/foo")
install(TARGETS testTarget EXPORT testTargets
DESTINATION lib
)
install(EXPORT testTargets DESTINATION lib/cmake)