diff options
author | Brad King <brad.king@kitware.com> | 2019-03-25 15:50:06 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2019-03-25 15:50:06 (GMT) |
commit | c22a2b49afed255593d1cc8425a5fd1fd2e1a81c (patch) | |
tree | 510138a6f7b74082c6ecc9de74324a37b5b3097c | |
parent | b743058003e86b15c8d9a5043266c18744d5eae3 (diff) | |
parent | 588fa1bb9eed6e838f58d4f1fb1d01d83ecfd820 (diff) | |
download | CMake-c22a2b49afed255593d1cc8425a5fd1fd2e1a81c.zip CMake-c22a2b49afed255593d1cc8425a5fd1fd2e1a81c.tar.gz CMake-c22a2b49afed255593d1cc8425a5fd1fd2e1a81c.tar.bz2 |
Merge branch 'toolchain-include_directories' into release-3.14
Merge-request: !3140
-rw-r--r-- | Modules/CMakeDetermineCompilerABI.cmake | 1 | ||||
-rw-r--r-- | Source/cmCoreTryCompile.cxx | 17 | ||||
-rw-r--r-- | Tests/RunCMake/ToolchainFile/IncludeDirectories-toolchain.cmake | 1 | ||||
-rw-r--r-- | Tests/RunCMake/ToolchainFile/IncludeDirectories.c | 5 | ||||
-rw-r--r-- | Tests/RunCMake/ToolchainFile/IncludeDirectories.cmake | 2 | ||||
-rw-r--r-- | Tests/RunCMake/ToolchainFile/IncludeDirectories/IncDir.h | 1 | ||||
-rw-r--r-- | Tests/RunCMake/ToolchainFile/RunCMakeTest.cmake | 8 |
7 files changed, 34 insertions, 1 deletions
diff --git a/Modules/CMakeDetermineCompilerABI.cmake b/Modules/CMakeDetermineCompilerABI.cmake index e0d2449..06f3ba2 100644 --- a/Modules/CMakeDetermineCompilerABI.cmake +++ b/Modules/CMakeDetermineCompilerABI.cmake @@ -51,6 +51,7 @@ function(CMAKE_DETERMINE_COMPILER_ABI lang src) OUTPUT_VARIABLE OUTPUT COPY_FILE "${BIN}" COPY_FILE_ERROR _copy_error + __CMAKE_INTERNAL ABI ) # Restore original LC_ALL, LC_MESSAGES, and LANG diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index eb52895..3892011 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -123,6 +123,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv, std::string targetName; std::vector<std::string> cmakeFlags(1, "CMAKE_FLAGS"); // fake argv[0] std::vector<std::string> compileDefs; + std::string cmakeInternal; std::string outputVariable; std::string copyFile; std::string copyFileError; @@ -174,7 +175,8 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv, DoingCExtensions, DoingCxxExtensions, DoingCudaExtensions, - DoingSources + DoingSources, + DoingCMakeInternal }; Doing doing = useSources ? DoingSources : DoingNone; for (size_t i = 3; i < argv.size(); ++i) { @@ -223,6 +225,8 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv, } else if (argv[i] == "CUDA_EXTENSIONS") { doing = DoingCudaExtensions; didCudaExtensions = true; + } else if (argv[i] == "__CMAKE_INTERNAL") { + doing = DoingCMakeInternal; } else if (doing == DoingCMakeFlags) { cmakeFlags.push_back(argv[i]); } else if (doing == DoingCompileDefinitions) { @@ -296,6 +300,9 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv, doing = DoingNone; } else if (doing == DoingSources) { sources.push_back(argv[i]); + } else if (doing == DoingCMakeInternal) { + cmakeInternal = argv[i]; + doing = DoingNone; } else if (i == 3) { this->SrcFileSignature = false; projectName = argv[i].c_str(); @@ -508,6 +515,14 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv, } } fprintf(fout, "project(CMAKE_TRY_COMPILE%s)\n", projectLangs.c_str()); + if (cmakeInternal == "ABI") { + // This is the ABI detection step, also used for implicit includes. + // Erase any include_directories() calls from the toolchain file so + // that we do not see them as implicit. Our ABI detection source + // does not include any system headers anyway. + fprintf(fout, + "set_property(DIRECTORY PROPERTY INCLUDE_DIRECTORIES \"\")\n"); + } fprintf(fout, "set(CMAKE_VERBOSE_MAKEFILE 1)\n"); for (std::string const& li : testLangs) { std::string langFlags = "CMAKE_" + li + "_FLAGS"; diff --git a/Tests/RunCMake/ToolchainFile/IncludeDirectories-toolchain.cmake b/Tests/RunCMake/ToolchainFile/IncludeDirectories-toolchain.cmake new file mode 100644 index 0000000..e77e9fe --- /dev/null +++ b/Tests/RunCMake/ToolchainFile/IncludeDirectories-toolchain.cmake @@ -0,0 +1 @@ +include_directories(${CMAKE_CURRENT_LIST_DIR}/IncludeDirectories) diff --git a/Tests/RunCMake/ToolchainFile/IncludeDirectories.c b/Tests/RunCMake/ToolchainFile/IncludeDirectories.c new file mode 100644 index 0000000..81b2465 --- /dev/null +++ b/Tests/RunCMake/ToolchainFile/IncludeDirectories.c @@ -0,0 +1,5 @@ +#include <IncDir.h> + +void IncDir(void) +{ +} diff --git a/Tests/RunCMake/ToolchainFile/IncludeDirectories.cmake b/Tests/RunCMake/ToolchainFile/IncludeDirectories.cmake new file mode 100644 index 0000000..616cff4 --- /dev/null +++ b/Tests/RunCMake/ToolchainFile/IncludeDirectories.cmake @@ -0,0 +1,2 @@ +enable_language(C) +add_library(IncDir STATIC IncludeDirectories.c) diff --git a/Tests/RunCMake/ToolchainFile/IncludeDirectories/IncDir.h b/Tests/RunCMake/ToolchainFile/IncludeDirectories/IncDir.h new file mode 100644 index 0000000..bca9c2c --- /dev/null +++ b/Tests/RunCMake/ToolchainFile/IncludeDirectories/IncDir.h @@ -0,0 +1 @@ +/* IncDir.h */ diff --git a/Tests/RunCMake/ToolchainFile/RunCMakeTest.cmake b/Tests/RunCMake/ToolchainFile/RunCMakeTest.cmake index 8a20200..7eb4485 100644 --- a/Tests/RunCMake/ToolchainFile/RunCMakeTest.cmake +++ b/Tests/RunCMake/ToolchainFile/RunCMakeTest.cmake @@ -9,3 +9,11 @@ run_cmake_toolchain(CallEnableLanguage) run_cmake_toolchain(CallProject) run_cmake_toolchain(FlagsInit) run_cmake_toolchain(LinkFlagsInit) + +function(run_IncludeDirectories) + run_cmake_toolchain(IncludeDirectories) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/IncludeDirectories-build) + set(RunCMake_TEST_NO_CLEAN 1) + run_cmake_command(IncludeDirectories-build ${CMAKE_COMMAND} --build . --config Debug) +endfunction() +run_IncludeDirectories() |