|
@@ -121,6 +121,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
|
|
|
std::string cxxExtensions;
|
|
std::string cxxExtensions;
|
|
|
std::string cudaExtensions;
|
|
std::string cudaExtensions;
|
|
|
std::vector<std::string> targets;
|
|
std::vector<std::string> targets;
|
|
|
|
|
+ std::vector<std::string> linkOptions;
|
|
|
std::string libsToLink = " ";
|
|
std::string libsToLink = " ";
|
|
|
bool useOldLinkLibs = true;
|
|
bool useOldLinkLibs = true;
|
|
|
char targetNameBuf[64];
|
|
char targetNameBuf[64];
|
|
@@ -144,6 +145,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
|
|
|
DoingNone,
|
|
DoingNone,
|
|
|
DoingCMakeFlags,
|
|
DoingCMakeFlags,
|
|
|
DoingCompileDefinitions,
|
|
DoingCompileDefinitions,
|
|
|
|
|
+ DoingLinkOptions,
|
|
|
DoingLinkLibraries,
|
|
DoingLinkLibraries,
|
|
|
DoingOutputVariable,
|
|
DoingOutputVariable,
|
|
|
DoingCopyFile,
|
|
DoingCopyFile,
|
|
@@ -165,6 +167,8 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
|
|
|
doing = DoingCMakeFlags;
|
|
doing = DoingCMakeFlags;
|
|
|
} else if (argv[i] == "COMPILE_DEFINITIONS") {
|
|
} else if (argv[i] == "COMPILE_DEFINITIONS") {
|
|
|
doing = DoingCompileDefinitions;
|
|
doing = DoingCompileDefinitions;
|
|
|
|
|
+ } else if (argv[i] == "LINK_OPTIONS") {
|
|
|
|
|
+ doing = DoingLinkOptions;
|
|
|
} else if (argv[i] == "LINK_LIBRARIES") {
|
|
} else if (argv[i] == "LINK_LIBRARIES") {
|
|
|
doing = DoingLinkLibraries;
|
|
doing = DoingLinkLibraries;
|
|
|
useOldLinkLibs = false;
|
|
useOldLinkLibs = false;
|
|
@@ -208,6 +212,8 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
|
|
|
cmakeFlags.push_back(argv[i]);
|
|
cmakeFlags.push_back(argv[i]);
|
|
|
} else if (doing == DoingCompileDefinitions) {
|
|
} else if (doing == DoingCompileDefinitions) {
|
|
|
compileDefs.push_back(argv[i]);
|
|
compileDefs.push_back(argv[i]);
|
|
|
|
|
+ } else if (doing == DoingLinkOptions) {
|
|
|
|
|
+ linkOptions.push_back(argv[i]);
|
|
|
} else if (doing == DoingLinkLibraries) {
|
|
} else if (doing == DoingLinkLibraries) {
|
|
|
libsToLink += "\"" + cmSystemTools::TrimWhitespace(argv[i]) + "\" ";
|
|
libsToLink += "\"" + cmSystemTools::TrimWhitespace(argv[i]) + "\" ";
|
|
|
if (cmTarget* tgt = this->Makefile->FindTargetToUse(argv[i])) {
|
|
if (cmTarget* tgt = this->Makefile->FindTargetToUse(argv[i])) {
|
|
@@ -814,6 +820,23 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ if (!linkOptions.empty()) {
|
|
|
|
|
+ std::vector<std::string> options;
|
|
|
|
|
+ options.reserve(linkOptions.size());
|
|
|
|
|
+ for (const auto& option : linkOptions) {
|
|
|
|
|
+ options.emplace_back(cmOutputConverter::EscapeForCMake(option));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (targetType == cmStateEnums::STATIC_LIBRARY) {
|
|
|
|
|
+ fprintf(fout,
|
|
|
|
|
+ "set_property(TARGET %s PROPERTY STATIC_LIBRARY_OPTIONS %s)\n",
|
|
|
|
|
+ targetName.c_str(), cmJoin(options, " ").c_str());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ fprintf(fout, "target_link_options(%s PRIVATE %s)\n",
|
|
|
|
|
+ targetName.c_str(), cmJoin(options, " ").c_str());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
if (useOldLinkLibs) {
|
|
if (useOldLinkLibs) {
|
|
|
fprintf(fout, "target_link_libraries(%s ${LINK_LIBRARIES})\n",
|
|
fprintf(fout, "target_link_libraries(%s ${LINK_LIBRARIES})\n",
|
|
|
targetName.c_str());
|
|
targetName.c_str());
|