title: Using Cmake to add compiler options to existing cmake
body: <p>I have a submodule with a CMakeLists.txt, which I would like to &quot;amend&quot; in a  way to make it work for my specific purpose (I need to add compiler flags and a different output directory) The output is a static library. My current approach is as follows:</p>
  <p>I have a CMakeLists.txt in the root directory, which adds the submodule CMakeLists.txt via <code>add_subdirectory()</code> like so:</p>
  <pre><code>set(CMAKE_CXX_FLAGS &quot;-my_needed_flags &quot;
  add_subdirectory(SubmoduleLibrary)
  set_target_properties(SubmoduleLibrary PROPERTIES ARCHIVE_OUTPUT_DIRECTORY output_folder)
  add_custom_target(BuildLib)
  add_dependencies(BuildLib SubmoduleLibrary)
  </code></pre>
  <p>Now this seems to work in some ways (the output directory is correctly chosen). But I get linker errors which I don't get when I compile the library adding the flags etc to the original CMakeLists.txt.<br />
  What is the correct way to build a library from an existing CMakeLists.txt with added parameters?</p>