Index: branches/2.0-beta1/cmake/FindPacpus.cmake
===================================================================
--- branches/2.0-beta1/cmake/FindPacpus.cmake	(revision 89)
+++ branches/2.0-beta1/cmake/FindPacpus.cmake	(revision 129)
@@ -10,35 +10,37 @@
 # TODO: write the output variables of this CMake file.
 
-# Check PACPUS_ROOT
-if(NOT PACPUS_ROOT)
-    if(NOT ENV{PACPUS_ROOT} STREQUAL "")
-        set(PACPUS_ROOT $ENV{PACPUS_ROOT})
-        message(STATUS "Detected PACPUS_ROOT, set to '${PACPUS_ROOT}'")
-    else()
-      if(PACPUS_FIND_REQUIRED)
-	MESSAGE(FATAL_ERROR "Could'not find PACPUS_ROOT ")
-      else()
-	MESSAGE(STATUS "Could'not find PACPUS_ROOT ")
-	return()
-      endif()
-    endif()
+# Locate the include files
+set(PACPUS_INCLUDE_HINTS
+    "${PACPUS_ROOT}/include"
+    "$ENV{PACPUS_ROOT}/include"
+)
+if(WIN32)
+    list(APPEND PACPUS_INCLUDE_HINTS
+        "C:/Program Files/Pacpus/include"
+        "C:/Program Files (x86)/Pacpus/include"
+        "C:/Pacpus/include"
+        "C:/lib/Pacpus/include"
+        "D:/Program Files/Pacpus/include"
+        "D:/Program Files (x86)/Pacpus/include"
+        "D:/Pacpus/include"
+        "D:/lib/Pacpus/include"
+    )
+else()
+    # TODO: add default paths no Unix-like systems
+    list(APPEND PACPUS_INCLUDE_HINTS
+    )
+endif()
+find_path(PACPUS_INCLUDE_DIR
+    NAMES "Pacpus/kernel/pacpus.h"
+    HINTS ${PACPUS_INCLUDE_HINTS}
+    DOC "The Pacpus include directory"
+)
+
+if(NOT PACPUS_INCLUDE_DIR)
+    message(FATAL_ERROR "Could not find PACPUS. Please set CMake variable PACPUS_ROOT or environment variable PACPUS_ROOT.")
 endif()
 
-
-
-# Hint directories
-set(PACPUS_INCLUDE_HINT ${PACPUS_ROOT}/include)
-set(PACPUS_LIBRARY_HINT ${PACPUS_ROOT}/lib)
-
-# Locate the include files
-find_path(
-    PACPUS_INCLUDE_DIR
-    NAMES
-        "Pacpus"
-    HINTS
-        ${PACPUS_INCLUDE_HINT}
-    DOC
-        "The Pacpus include directory"
-)
+get_filename_component(PACPUS_ROOT ${PACPUS_INCLUDE_DIR}/.. ABSOLUTE)
+set(PACPUS_LIB_DIR ${PACPUS_ROOT}/lib)
 
 # List of required modules
@@ -53,51 +55,47 @@
 # Check the presence of each module
 foreach(module ${PACPUS_MODULES})
+    # release version
     find_library(
         PACPUS_${module}_LIB
-        NAMES
-            ${module}
-        HINTS
-            ${PACPUS_LIBRARY_HINT}
+        NAMES ${module}
+        HINTS ${PACPUS_LIB_DIR}
     )
+    if(PACPUS_${module}_LIB AND PACPUS_${module}_LIBD)
+        list(APPEND PACPUS_LIBRARIES optimized ${PACPUS_${module}_LIB})
+    else()
+        message(SEND_ERROR "Cannot find Pacpus module ${module} (release version)")
+        set(MODULE_MISSING TRUE)
+    endif()
+    
+    # debug version
     find_library(
         PACPUS_${module}_LIBD
-        NAMES
-            ${module}_d
-        HINTS
-            ${PACPUS_LIBRARY_HINT}
+        NAMES ${module}_d
+        HINTS ${PACPUS_LIB_DIR}
     )
-
     if(PACPUS_${module}_LIB AND PACPUS_${module}_LIBD)
-        list(APPEND PACPUS_LIBRARIES optimized ${PACPUS_${module}_LIB})
         list(APPEND PACPUS_LIBRARIES debug ${PACPUS_${module}_LIBD})
     else()
+        message(SEND_ERROR "Cannot find Pacpus module ${module}_d (debug version)")
         set(MODULE_MISSING TRUE)
     endif()
 endforeach()
 
-if(NOT MODULE_MISSING AND PACPUS_INCLUDE_DIR)
-    set(PACPUS_FOUND TRUE)
+# handle the QUIETLY and REQUIRED arguments and set PACPUS_FOUND to TRUE if
+# all listed variables are TRUE
+include (FindPackageHandleStandardArgs)
+set(PACPUS_ALL_MODULES_FOUND NOT MODULE_MISSING)
+find_package_handle_standard_args (PACPUS DEFAULT_MSG PACPUS_LIBRARIES PACPUS_INCLUDE_DIR PACPUS_ALL_MODULES_FOUND)
 
-    # Configure Pacpus
-    list(APPEND CMAKE_MODULE_PATH "${PACPUS_ROOT}/cmake")
-    include(${PACPUS_ROOT}/cmake/PacpusUtilities.cmake)
-    include(${PACPUS_ROOT}/cmake/PacpusConfiguration.cmake)
-    include(${PACPUS_ROOT}/cmake/PacpusDependencies.cmake)
-    include(${PACPUS_ROOT}/cmake/PacpusPlatforms.cmake)
-
-    #set(CMAKE_INSTALL_PREFIX ${PACPUS_ROOT})
+if(PACPUS_FOUND)
     set(PACPUS_INSTALL_DIR ${PACPUS_ROOT})
-    set(PACPUS_LIB_DIR "${PACPUS_ROOT}/lib"
-)
-    MESSAGE(STATUS "PACPUS_ROOT found ${PACPUS_ROOT}")
-
-else()
-    set(PACPUS_FOUND FALSE)
-
-    if(PACPUS_FIND_REQUIRED)
-      MESSAGE(FATAL_ERROR "Could'not find PACPUS_ROOT ")
-    else()
-      MESSAGE(STATUS "Could'not find PACPUS_ROOT ")
-    endif()
-
+    set(PACPUS_CMAKE_DIR ${PACPUS_ROOT}/cmake)
+    set(CMAKE_INSTALL_PREFIX ${PACPUS_INSTALL_DIR})
+    list(APPEND CMAKE_PREFIX_PATH ${PACPUS_CMAKE_DIR})
+    list(APPEND CMAKE_MODULE_PATH "${PACPUS_CMAKE_DIR}")
+    
+    include(${PACPUS_CMAKE_DIR}/PacpusUtilities.cmake)
+    include(${PACPUS_CMAKE_DIR}/PacpusConfiguration.cmake)
+    include(${PACPUS_CMAKE_DIR}/PacpusDependencies.cmake)
+    include(${PACPUS_CMAKE_DIR}/PacpusPlatforms.cmake)
 endif()
