From 07551f35de4e5d4aef40f1646f699785ab741128 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Wed, 19 Jul 2023 16:44:03 -0400 Subject: 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. --- Source/cmCoreTryCompile.cxx | 7 ++++--- 1 file 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 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)) { -- cgit v0.12