title: CMake macro across CMakeLists
body: <p>I have a c++ project which directory structure like below:</p>
  
  <pre><code>server/
     code/
        BASE/
           Thread/
           Log/
           Memory/
        Net/
     cmake/
        CMakeList.txt
        BASE/
           CMakeList.txt
        Net/
           CMakeList.txt
  </code></pre>
  
  <p>here is part of /cmake/CMakeList.txt: </p>
  
  <pre><code>MACRO(SUBDIRLIST result curdir)
    FILE(GLOB children RELATIVE ${curdir} ${curdir}/*)
    SET(dirlist "")
    FOREACH(child ${children})
      IF(IS_DIRECTORY ${curdir}/${child})
          SET(dirlist ${dirlist} ${child})
      ENDIF()
    ENDFOREACH()
    SET(${result} ${dirlist})
  ENDMACRO()
  
  add_subdirectory(Base)
  </code></pre>
  
  <p>then use macro in /cmake/Base/CMakeList.txt: </p>
  
  <pre><code>SET(SUBDIR, "")
  SUBDIRLIST(SUBDIRS, ${BASE_SRC_DIR})
  message("SUBDIRS : " ${SUBDIRS})
  </code></pre>
  
  <p>output:
  SUBDIRS : </p>
  
  <p>I check ${dirlist} by output it's value in macro, I get directory list expected,but when message("result " ${result}) after SET(${result} ${dirlist}),I can not get output expected , what's wrong with my CMakeLists.txt?</p>