diff options
author | Ben Boeckel <ben.boeckel@kitware.com> | 2023-07-19 20:44:03 (GMT) |
---|---|---|
committer | Ben Boeckel <ben.boeckel@kitware.com> | 2023-07-31 15:37:47 (GMT) |
commit | 07551f35de4e5d4aef40f1646f699785ab741128 (patch) | |
tree | 567acc7cdf452d8a73ded6f4a0693330c3ad5505 /Source/cmCoreTryCompile.cxx | |
parent | aad9033b5640b62ab47c0be926b8e05d66b735c0 (diff) | |
download | CMake-07551f35de4e5d4aef40f1646f699785ab741128.zip CMake-07551f35de4e5d4aef40f1646f699785ab741128.tar.gz CMake-07551f35de4e5d4aef40f1646f699785ab741128.tar.bz2 |
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.
Diffstat (limited to 'Source/cmCoreTryCompile.cxx')
-rw-r--r-- | Source/cmCoreTryCompile.cxx | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index 7773569..32f2e3b 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -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)) { |