Index: trunk/cmake/PacpusDependencies.cmake
===================================================================
--- trunk/cmake/PacpusDependencies.cmake	(revision 178)
+++ trunk/cmake/PacpusDependencies.cmake	(revision 187)
@@ -8,122 +8,113 @@
 #################################################
 
-# ========================================
-# Output
-# ========================================
+################################################################################
+# OUTPUT
 set(PACPUS_DEFINITIONS "")
 set(PACPUS_DEPENDENCIES_INC "")
 set(PACPUS_DEPENDENCIES_LIB "")
 
-# FIXME: first find_package(Qt5Widgets QUIET), then Qt4
-set(PACPUS_USE_QT5 FALSE CACHE BOOL "Whether to use Qt5")
-if(NOT PACPUS_USE_QT5)
-    find_package(Qt4 QUIET)
-    if(NOT QT4_FOUND)
-        message(WARNING "Qt4 not found try to find Qt5")
-        set(PACPUS_USE_QT5 TRUE)
-    endif()
+################################################################################
+# Necessary for Qt5
+# message(STATUS "Set CMake variable 'CMAKE_PREFIX_PATH' to the path like '%QT_BIN%/../lib/cmake'")
+set(QT_CMAKE_DIR "$ENV{QT_BIN}/../lib/cmake")
+get_filename_component(QT_CMAKE_DIR "${QT_CMAKE_DIR}" ABSOLUTE)
+#message(STATUS "\${QT_CMAKE_DIR} = '${QT_CMAKE_DIR}'")
+list(APPEND CMAKE_PREFIX_PATH
+    ${QT_CMAKE_DIR}
+)
+if(WIN32)
+    message(STATUS "Environment variable 'WINSDK_LIB' should be set to something like 'C:/Program Files (x86)/Windows Kits/8.0/Lib/win8/um/x86'")
+    #message(STATUS "\$ENV{WINSDK_LIB} = '$ENV{WINSDK_LIB}'")
+    list(APPEND CMAKE_PREFIX_PATH
+        $ENV{WINSDK_LIB}
+    )
 endif()
 
-if(PACPUS_USE_QT5)
-    # message(STATUS "Set CMake variable 'CMAKE_PREFIX_PATH' to the path like '%QT_BIN%/../lib/cmake'")
-    set(QT_CMAKE_DIR "$ENV{QT_BIN}/../lib/cmake")
-    get_filename_component(QT_CMAKE_DIR "${QT_CMAKE_DIR}" ABSOLUTE)
-    message(STATUS "\${QT_CMAKE_DIR} = '${QT_CMAKE_DIR}'")
-    list(APPEND CMAKE_PREFIX_PATH
-        ${QT_CMAKE_DIR}
+################################################################################
+# Find Qt
+find_package(Qt5Widgets QUIET)
+if(Qt5Widgets_FOUND)
+    # Tell CMake to run moc when necessary:
+    #set(CMAKE_AUTOMOC ON)
+    # As moc files are generated in the binary dir, tell CMake
+    # to always look for includes there:
+    set(CMAKE_INCLUDE_CURRENT_DIR ON)        
+    
+    find_package(Qt5Core REQUIRED)
+    find_package(Qt5Xml REQUIRED)
+    find_package(Qt5Gui REQUIRED)
+    find_package(Qt5OpenGL REQUIRED)
+    find_package(Qt5Network REQUIRED)
+    find_package(Qt5SerialPort REQUIRED)
+        
+    set(QT_DEFINITIONS
+        ${Qt5Widgets_DEFINITIONS}
+        ${Qt5Core_DEFINITIONS}
+        ${Qt5Xml_DEFINITIONS}
+        ${Qt5Gui_DEFINITIONS}
+        ${Qt5OpenGL_DEFINITIONS}
+        ${Qt5Network_DEFINITIONS}
+        ${Qt5SerialPort_DEFINITIONS}
     )
-    if(WIN32)
-        message(STATUS "Environment variable 'WINSDK_LIB' should be set to something like 'C:/Program Files (x86)/Windows Kits/8.0/Lib/win8/um/x86'")
-        message(STATUS "\$ENV{WINSDK_LIB} = '$ENV{WINSDK_LIB}'")
-        list(APPEND CMAKE_PREFIX_PATH
-            $ENV{WINSDK_LIB}
-        )
+    set(QT_INCLUDE_DIR
+        ${Qt5Widgets_INCLUDE_DIRS}
+        ${Qt5Core_INCLUDE_DIRS}
+        ${Qt5Xml_INCLUDE_DIRS}
+        ${Qt5Gui_INCLUDE_DIRS}
+        ${Qt5OpenGL_INCLUDE_DIRS}
+        ${Qt5Network_INCLUDE_DIRS}
+        ${Qt5SerialPort_INCLUDE_DIRS}
+    )
+    set(QT_LIBRARIES
+        ${Qt5Widgets_LIBRARIES}
+        ${Qt5Core_LIBRARIES}
+        ${Qt5Xml_LIBRARIES}
+        ${Qt5Gui_LIBRARIES}
+        ${Qt5OpenGL_LIBRARIES}
+        ${Qt5Network_LIBRARIES}
+        ${Qt5SerialPort_LIBRARIES}
+    )
+    
+    if(Qt5_POSITION_INDEPENDENT_CODE)
+      set(CMAKE_POSITION_INDEPENDENT_CODE ON)
     endif()
-# ========================================
+else()
+    message(STATUS "Qt5 not found: try to find Qt4")
+    
+    find_package(Qt4 REQUIRED)
+endif()
+
+################################################################################
 # All the Pacpus modules depend on Qt5
 # However, since each module requires specific Qt's modules, they have to include their own QT_USE_FILE
-# ========================================
 
-# Tell CMake to run moc when necessary:
-#set(CMAKE_AUTOMOC ON)
-# As moc files are generated in the binary dir, tell CMake
-# to always look for includes there:
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-find_package(Qt5Widgets REQUIRED)
-find_package(Qt5Core REQUIRED)
-find_package(Qt5Xml REQUIRED)
-find_package(Qt5Gui REQUIRED)
-find_package(Qt5OpenGL REQUIRED)
-find_package(Qt5Network REQUIRED)
-find_package(Qt5SerialPort REQUIRED)
-
-set(QT_DEFINITIONS
-    ${Qt5Widgets_DEFINITIONS}
-    ${Qt5Core_DEFINITIONS}
-    ${Qt5Xml_DEFINITIONS}
-    ${Qt5Gui_DEFINITIONS}
-    ${Qt5OpenGL_DEFINITIONS}
-    ${Qt5Network_DEFINITIONS}
-    ${Qt5SerialPort_DEFINITIONS}
+################################################################################
+# Boost
+list(APPEND PACPUS_DEFINITIONS " -DBOOST_ALL_DYN_LINK ")
+find_package(Boost 1.54.0
+    COMPONENTS
+        program_options
 )
-set(QT_INCLUDE_DIR
-    ${Qt5Widgets_INCLUDE_DIRS}
-    ${Qt5Core_INCLUDE_DIRS}
-    ${Qt5Xml_INCLUDE_DIRS}
-    ${Qt5Gui_INCLUDE_DIRS}
-    ${Qt5OpenGL_INCLUDE_DIRS}
-    ${Qt5Network_INCLUDE_DIRS}
-    ${Qt5SerialPort_INCLUDE_DIRS}
-)
-set(QT_LIBRARIES
-    ${Qt5Widgets_LIBRARIES}
-    ${Qt5Core_LIBRARIES}
-    ${Qt5Xml_LIBRARIES}
-    ${Qt5Gui_LIBRARIES}
-    ${Qt5OpenGL_LIBRARIES}
-    ${Qt5Network_LIBRARIES}
-    ${Qt5SerialPort_LIBRARIES}
-)
-
-if(Qt5_POSITION_INDEPENDENT_CODE)
-  set(CMAKE_POSITION_INDEPENDENT_CODE ON)
+if(Boost_FOUND)
+    include_directories(${Boost_INCLUDE_DIRS})
+    link_directories(${Boost_LIBRARY_DIRS})
+    list(APPEND PACPUS_DEPENDENCIES_INC ${Boost_INCLUDE_DIRS})
+    list(APPEND PACPUS_DEPENDENCIES_LIB ${Boost_LIBRARIES})
 endif()
-
-else()
-
-# ========================================
-# All the Pacpus modules depend on Qt4
-# However, since each module requires specific Qt modules, they have to include their own QT_USE_FILE
-# ========================================
-find_package(Qt4 REQUIRED)
-
-endif()
-
-# ========================================
-# Boost
-# Do not use compiled modules, include-only headers.
-# ========================================
 if(PACPUS_USE_LOG)
     list(APPEND PACPUS_DEFINITIONS " -DPACPUS_USE_LOG ")
-    list(APPEND PACPUS_DEFINITIONS " -DBOOST_ALL_DYN_LINK ")
-    
     find_package(Boost 1.54.0 REQUIRED
         COMPONENTS
             log
             log_setup
-            program_options
     )
     include_directories(${Boost_INCLUDE_DIRS})
     link_directories(${Boost_LIBRARY_DIRS})
-    
     list(APPEND PACPUS_DEPENDENCIES_INC ${Boost_INCLUDE_DIRS})
     list(APPEND PACPUS_DEPENDENCIES_LIB ${Boost_LIBRARIES})
-    #message("\${PACPUS_DEPENDENCIES_LIB} = ${PACPUS_DEPENDENCIES_LIB}")
 endif()
 
-# ========================================
-# Doxygen
-# ========================================
+################################################################################
+# DOCUMENTATION
 if(PACPUS_BUILD_DOC)
     find_package(Doxygen)
