title: CMake with Qt to include modules xmlpatterns
body: <p>I am trying to switch from QMake to CMake. I get my first error like this:</p>
  
  <pre><code>Target "aacmakeqt" links to target "Qt::xmlpatterns" but the target was not found.
  Perhaps a find_package() call is missing for an IMPORTED target, or an ALIAS target is missing?
  </code></pre>
  
  <p>I wonder how to know or find the name of the module? Why it is <code>find_package(Qt5Widgets)</code> but not <code>find_package(Qt5widgets)</code>?
  Why it is <code>target_link_libraries(project Qt5::Widgets)</code> but not <code>Qt5::widgets</code> or <code>Qt5Widgets</code>? Where can I find these information? And the most important is how to use link the <a href="http://doc.qt.io/qt-5/qtxmlpatterns-index.html" rel="nofollow">Qt XML Patterns</a>?</p>
  
  <p>My .pro file in QtCreator</p>
  
  <pre><code>#-------------------------------------------------
  #
  # Project created by QtCreator 2015-11-07T19:23:43
  #
  #-------------------------------------------------   
  QT       += core gui xmlpatterns widgets
  
  TARGET = myapp
  TEMPLATE = app
  
  SOURCES += main.cpp ......... 
  HEADERS  += mainwindow.h ........
  FORMS    += mainwindow.ui ........
  RESOURCES += resources.qrc
  </code></pre>
  
  <p>My CMakeList File</p>
  
  <pre><code>cmake_minimum_required(VERSION 3.0)
  
  ## Setting ProjectId by current directory
  get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME)
  string(REPLACE " " "_" ProjectId ${ProjectId})
  MESSAGE(STATUS "\tProjectId: " ${ProjectId} ) ## Debug Message
  
  ## Defining project
  project(${ProjectId})
  set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
  
  # Find the library
  find_package(Qt5Widgets)
  find_package(Qt5Xmlpatterns)
  
  MESSAGE(STATUS "Project Source Directory: " ${PROJECT_SOURCE_DIR} ) ## Debug Message
  
  file(GLOB_RECURSE SRC_CPP ${PROJECT_SOURCE_DIR} *.cpp)
  MESSAGE(STATUS "\tsource: " ${SRC_CPP}) ## Debug Message
  add_executable(${ProjectId} ${SRC_CPP})
  
  # Use the Widgets module from Qt 5.
  target_link_libraries(${ProjectId} Qt5::Widgets)
  target_link_libraries(${ProjectId} Qt5::xmlpatterns)
  </code></pre>
  
  <p><strong>Solution:</strong></p>
  
  <p>With a more detailed error message provided by <code>find_package(Qt5XmlPatterns REQUIRED)</code>, I understanding CMake cannot find either <code>Qt5XmlPatternsConfig.cmake</code> or <code>qt5xmlpatterns-config.cmake</code>.</p>
  
  <p>The required <code>.cmake</code> files should come with Qt. It turns out that my Qt directory is located in my home directory rather than <code>\usr\lib</code>. (I don't know how this happen. I should have install Qt with default options.)</p>
  
  <p>So, I simply help cmake to locate the correct directory. In my case, all the <code>.cmake</code> files for Qt located under <code>~/Qt5.5.1/5.5/gcc_64/lib/cmake</code>.
  Base on the document for <a href="https://cmake.org/cmake/help/v3.0/command/find_package.html" rel="nofollow">find_package</a>, it searches <code>CMAKE_PREFIX_PATH</code> <code>CMAKE_FRAMEWORK_PATH</code> <code>CMAKE_APPBUNDLE_PATH</code> for packages in turn. So I just add</p>
  
  <pre><code>set(CMAKE_FRAMEWORK_PATH ${CMAKE_FRAMEWORK_PATH} "~/Qt5.5.1/5.5/gcc_64/lib/cmake")
  </code></pre>
  
  <p>for it to search correctly.</p>
  
  <p>Finally, we can find the name of the package under <code>Your_Qt_Install_directory/Qt5.5.1/5.5/gcc_64/lib/cmake"</code>.</p>