title: Qt - How to write a FindXXX.cmake file for a certain Qt library
body: <p>So I really want to start developing my Qt project inside a different IDE (Clion to be exact). I've written my CMake file for the project. It successfully finds Qt Core, Widgets and other libraries but when it comes to including Qt Charts Cmake throws an error:</p>
  
  <blockquote>
    <p>CMake Error at CMakeLists.txt:44 (find_package):
      By not providing "FindQt5Charts.cmake" in CMAKE_MODULE_PATH this project
      has asked CMake to find a package configuration file provided by
      "Qt5Charts", but CMake did not find one.</p>
  </blockquote>
  
  <p>This error is successfully removed when I add <strong>by hand</strong> a "FindQt5Charts.cmake" file in my CLion>bin>Cmake>share>modules (where FindQt.cmake and othere search package files are) but as of now this file is empty.</p>
  
  <p>The Cmake compiles successfully but since it hasn't found the library I'm looking for, my project won't compile. I need your help to write "FindQt5Charts.cmake" file because I'm not 100% sure of its syntax.</p>
  
  <p>NOTE: Qt Charts is installed and its folder could be found in Qt's installation directory. I just need the code for the FindQt5Charts.cmake.</p>
  
  <p><a href="https://pastebin.com/Ems1tzSH" rel="nofollow noreferrer">Here's a reference to the FindQt.cmake file</a></p>
  
  <p>Here is how the beggining of my project's cmake looks:</p>
  
  <pre><code>#Pull needed header files generated by QT first
  set(QT_GENERATED qtGenerated)
  add_custom_target(${QT_GENERATED})
  
  #Get all header files in the directory
  file(GLOB QT_GEN_HEADERS ${QT_BIN}/*.h)
  
  #Copy them to the project dir
  foreach (QT_GEN_HEADERS ${QT_GEN_HEADERS})
      add_custom_command(TARGET ${QT_GENERATED} PRE_BUILD COMMAND
              ${CMAKE_COMMAND} -E copy_if_different
              ${QT_GEN_HEADERS} ${CMAKE_SOURCE_DIR})
  endforeach ()
  
  
  # Find the Qt libraries
  foreach (QT_LIBRARIES_REQUIRED ${QT_LIBRARIES_REQUIRED})
      find_package(${QT_LIBRARIES_REQUIRED} REQUIRED)
  endforeach ()
  </code></pre>