title: Correct way of changing possibly empty CMake lists
body: <p>An old question recently reoccurred: What is the correct way of setting <code>CMAKE_MODULE_PATH</code>? But this applies to pretty much any list. However there might be a difference for general text, but IMO only when that text might contain semicolons.</p>
  
  <p>Precondition: That variable might be unset, empty, or set</p>
  
  <p>Options: </p>
  
  <ol>
  <li><code>set (CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmakeModules ${CMAKE_MODULE_PATH})</code></li>
  <li><code>set (CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmakeModules" ${CMAKE_MODULE_PATH})</code></li>
  <li><code>list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmakeModules)</code></li>
  <li><code>list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmakeModules")</code></li>
  <li><code>if (NOT CMAKE_MODULE_PATH)
  set (CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmakeModules")
  else()
  set (CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmakeModules;${CMAKE_MODULE_PATH}")
  endif()</code></li>
  </ol>
  
  <p>To include some reasoning:</p>
  
  <p>a) 1. might fail, when there are spaces in the path so one has to use 2. to avoid this. Is this correct?<br>
  b) 3/4 looks like the better/more concise way. Again are the spaces required?<br>
  c) 5. Has (ugly) special case handling which 1-4 avoid. Is this required?</p>
  
  <p>Related: <a href="https://stackoverflow.com/questions/35847655/cmake-when-to-quote-variables">cmake: when to quote variables?</a></p>
  
  <p>But I'm still unsure, when to use quotes especially when dealing with paths and lists.</p>
  
  <p>Bonus: What exactly does happen during evaluation? If all <code>${...}</code> would get replaced by the value of the variable before it is passed to the function then e.g. the following would not work and requires spaces. But it does work as intended:</p>
  
  <pre><code>set(FOO_DIR "my space path")
  set(CMAKE_LIST /usr)
  set(CMAKE_LIST ${CMAKE_LIST} ${FOO_DIR}/foo)
  oder: list(APPEND CMAKE_LIST ${FOO_DIR}/foo)
  </code></pre>
  
  <p>This also applies to calls to other functions. E.g.:</p>
  
  <pre><code>set_target_properties(MYTARGET PROPERTIES
    IMPORTED_LOCATION ${FOO_DIR}/foo
  )
  </code></pre>
  
  <p>Question is: Why? Where in the standard is this specified?</p>