title: How can I have CMAKE_BUILD_TYPE being propagated to sublibraries included via add_subdirectory?
body: <p>My build consists of several sub-libraries being first build and then linked together.</p>
  <p>In the main cmakelists.txt they're added with</p>
  <pre><code>add_subdirectory (src/submodules/CanTp/CanTp CanTp)
  </code></pre>
  <p>and a linker dependency is added with</p>
  <pre><code>target_link_libraries(my_app_name PRIVATE CanTp/${CMAKE_BUILD_TYPE}/CanTp
  </code></pre>
  <p>The cmakelists.txt for CanTp is</p>
  <pre><code>add_library (CanTp CanTp.cpp)
  
  target_include_directories (CanTp PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
  </code></pre>
  <p>The issue is that CanTp is always built with build type Debug regardless of CMAKE_BUILD_TYPE. CMAKE_BUILD_TYPE does have an effect on the build type for the sources files in the top cmakelists.txt so I know it's set correctly.</p>
  <p>How can I have CMAKE_BUILD_TYPE being propagated to sublibraries included via add_subdirectory?</p>