mirror of
https://github.com/Kitware/CMake.git
synced 2025-12-31 10:50:16 -06:00
cmCoreTryCompile: use target_sources for try_compile targets
In order to support using C++ module sources in `try_compile`, `target_sources` will be required. To prepare, always use the command.
This commit is contained in:
@@ -837,17 +837,18 @@ cm::optional<cmTryCompileResult> cmCoreTryCompile::TryCompileCode(
|
||||
fprintf(fout, "set(CMAKE_RUNTIME_OUTPUT_DIRECTORY \"%s\")\n",
|
||||
this->BinaryDirectory.c_str());
|
||||
/* Create the actual executable. */
|
||||
fprintf(fout, "add_executable(%s", targetName.c_str());
|
||||
fprintf(fout, "add_executable(%s)\n", targetName.c_str());
|
||||
} else // if (targetType == cmStateEnums::STATIC_LIBRARY)
|
||||
{
|
||||
/* Put the static library at a known location (for COPY_FILE). */
|
||||
fprintf(fout, "set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY \"%s\")\n",
|
||||
this->BinaryDirectory.c_str());
|
||||
/* Create the actual static library. */
|
||||
fprintf(fout, "add_library(%s STATIC", targetName.c_str());
|
||||
fprintf(fout, "add_library(%s STATIC)\n", targetName.c_str());
|
||||
}
|
||||
fprintf(fout, "target_sources(%s PRIVATE\n", targetName.c_str());
|
||||
for (std::string const& si : sources) {
|
||||
fprintf(fout, " \"%s\"", si.c_str());
|
||||
fprintf(fout, " \"%s\"\n", si.c_str());
|
||||
|
||||
// Add dependencies on any non-temporary sources.
|
||||
if (!IsTemporary(si)) {
|
||||
|
||||
Reference in New Issue
Block a user