title: How to share variables between different CMake files
body: <p>How do I share variables between different CMake files, and I show the following examples to illustrate my question:</p>
  
  <h3>Main</h3>
  
  <pre><code>cmake_minimum_required(VERSION 2.6)
  project(test)
  set(Var3 "Global variable")
  
  add_subdirectory(${test_SOURCE_DIR}/exe)
  add_subdirectory(${test_SOURCE_DIR}/dll)
  </code></pre>
  
  <h3>EXE file</h3>
  
  <pre><code>set(Var1 "this is variable 1")
  set(Var1 ${Var1} " added to varible 1")
  message(STATUS ${Var1})
  </code></pre>
  
  <h3>DLL file</h3>
  
  <pre><code>set(Var2 "this is variable 2")
  message(STATUS ${Var2})
  message(STATUS ${Var1})
  message(STATUS ${Var3})
  </code></pre>
  
  <p>In this example, Var3 can be seen in the CMake files of <code>exe</code> and <code>dll</code> as it is defined in <code>Main</code>. However, Var1, which is defined in <code>exe</code>, will not be observed in <code>dll</code>. I was just curious: is there a way to make Var1 defined in <code>exe</code> observable in <code>dll</code>?</p>