title: CMake and Ninja - "missing and no known rule to make it"
body: <p>I have this <a href="https://cmake.org/cmake/help/latest/manual/cmake-language.7.html#organization" rel="noreferrer">CMakeLists.txt</a> file:</p>
  <pre><code>cmake_minimum_required(VERSION 3.8)
  
  include(${CMAKE_CURRENT_SOURCE_DIR}/src/Something.cmake)
  
  add_executable(execute main.cpp)
  add_dependencies(somethingInterface Something)
  add_dependencies(execute somethingInterface)
  
  include_directories(
      ${CMAKE_CURRENT_SOURCE_DIR}/src
      )
  target_compile_options(execute
      PRIVATE
          -std=c++11
          -g
  )
  
  add_library(library SHARED IMPORTED)
  set_target_properties(library PROPERTIES IMPORTED_LOCATION ${CMAKE_BINARY_DIR}/library.so)
  target_link_libraries(execute
      PRIVATE
          library
  )
  </code></pre>
  <p>The library shared imported will be created in file <em>Something.cmake</em>, but <strong>tt must be built first</strong>.
  It was a add_custom_command(TARGET POST_BUILD...) in file <em>Something.cmake</em>.</p>
  <p>I don't have any problem in using CMake builds here, but when I am using <a href="https://ninja-build.org/manual.html" rel="noreferrer">Ninja</a> there an <em><strong>error</strong></em>.</p>
  <blockquote>
  <p>ninja: error: 'library.so', needed by 'execute', missing and no known rule to make it</p>
  </blockquote>
  <p>Or do you have any suggestion on how can you do this?</p>
  <p>I think Ninja has a requirement that &quot;library.so&quot; must exist first, but CMake it is different. It checks whether the library is there at runtime.</p>