浏览代码

try_compile: Propogate CMP0065 to the generated project.

Set policy CMP0065 to the value used in the calling project.

Set the the value of CMAKE_ENABLE_EXPORTS if set in the calling
project to initialize the target property appropriately.
Chuck Atkins 10 年之前
父节点
当前提交
b15f4e9b86
共有 2 个文件被更改,包括 13 次插入0 次删除
  1. 3 0
      Help/command/try_compile.rst
  2. 10 0
      Source/cmCoreTryCompile.cxx

+ 3 - 0
Help/command/try_compile.rst

@@ -100,6 +100,7 @@ If set, the following variables are passed in to the generated
 try_compile CMakeLists.txt to initialize compile target properties with
 try_compile CMakeLists.txt to initialize compile target properties with
 default values:
 default values:
 
 
+* :variable:`CMAKE_ENABLE_EXPORTS`
 * :variable:`CMAKE_LINK_SEARCH_START_STATIC`
 * :variable:`CMAKE_LINK_SEARCH_START_STATIC`
 * :variable:`CMAKE_LINK_SEARCH_END_STATIC`
 * :variable:`CMAKE_LINK_SEARCH_END_STATIC`
 * :variable:`CMAKE_POSITION_INDEPENDENT_CODE`
 * :variable:`CMAKE_POSITION_INDEPENDENT_CODE`
@@ -107,5 +108,7 @@ default values:
 If :policy:`CMP0056` is set to ``NEW``, then
 If :policy:`CMP0056` is set to ``NEW``, then
 :variable:`CMAKE_EXE_LINKER_FLAGS` is passed in as well.
 :variable:`CMAKE_EXE_LINKER_FLAGS` is passed in as well.
 
 
+The current setting of :policy:`CMP0065` is set in the generated project.
+
 Set the :variable:`CMAKE_TRY_COMPILE_CONFIGURATION` variable to choose
 Set the :variable:`CMAKE_TRY_COMPILE_CONFIGURATION` variable to choose
 a build configuration.
 a build configuration.

+ 10 - 0
Source/cmCoreTryCompile.cxx

@@ -481,6 +481,16 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
       fprintf(fout, "set(CMAKE_LINK_SEARCH_END_STATIC \"%s\")\n", lssDef);
       fprintf(fout, "set(CMAKE_LINK_SEARCH_END_STATIC \"%s\")\n", lssDef);
       }
       }
 
 
+    /* Set the appropriate policy information for ENABLE_EXPORTS */
+    fprintf(fout, "cmake_policy(SET CMP0065 %s)\n",
+       this->Makefile->GetPolicyStatus(cmPolicies::CMP0065) ==
+         cmPolicies::NEW ? "NEW" : "OLD");
+    if(const char *ee = this->Makefile->GetDefinition(
+        "CMAKE_ENABLE_EXPORTS"))
+      {
+      fprintf(fout, "set(CMAKE_ENABLE_EXPORTS %s)\n", ee);
+      }
+
     /* Put the executable at a known location (for COPY_FILE).  */
     /* Put the executable at a known location (for COPY_FILE).  */
     fprintf(fout, "set(CMAKE_RUNTIME_OUTPUT_DIRECTORY \"%s\")\n",
     fprintf(fout, "set(CMAKE_RUNTIME_OUTPUT_DIRECTORY \"%s\")\n",
             this->BinaryDirectory.c_str());
             this->BinaryDirectory.c_str());