Changeset 129 in pacpusframework


Ignore:
Timestamp:
Jul 30, 2013, 2:04:56 PM (11 years ago)
Author:
Marek Kurdej
Message:

Update: FindPacpus.cmake revisited.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.0-beta1/cmake/FindPacpus.cmake

    r89 r129  
    1010# TODO: write the output variables of this CMake file.
    1111
    12 # Check PACPUS_ROOT
    13 if(NOT PACPUS_ROOT)
    14     if(NOT ENV{PACPUS_ROOT} STREQUAL "")
    15         set(PACPUS_ROOT $ENV{PACPUS_ROOT})
    16         message(STATUS "Detected PACPUS_ROOT, set to '${PACPUS_ROOT}'")
    17     else()
    18       if(PACPUS_FIND_REQUIRED)
    19         MESSAGE(FATAL_ERROR "Could'not find PACPUS_ROOT ")
    20       else()
    21         MESSAGE(STATUS "Could'not find PACPUS_ROOT ")
    22         return()
    23       endif()
    24     endif()
     12# Locate the include files
     13set(PACPUS_INCLUDE_HINTS
     14    "${PACPUS_ROOT}/include"
     15    "$ENV{PACPUS_ROOT}/include"
     16)
     17if(WIN32)
     18    list(APPEND PACPUS_INCLUDE_HINTS
     19        "C:/Program Files/Pacpus/include"
     20        "C:/Program Files (x86)/Pacpus/include"
     21        "C:/Pacpus/include"
     22        "C:/lib/Pacpus/include"
     23        "D:/Program Files/Pacpus/include"
     24        "D:/Program Files (x86)/Pacpus/include"
     25        "D:/Pacpus/include"
     26        "D:/lib/Pacpus/include"
     27    )
     28else()
     29    # TODO: add default paths no Unix-like systems
     30    list(APPEND PACPUS_INCLUDE_HINTS
     31    )
     32endif()
     33find_path(PACPUS_INCLUDE_DIR
     34    NAMES "Pacpus/kernel/pacpus.h"
     35    HINTS ${PACPUS_INCLUDE_HINTS}
     36    DOC "The Pacpus include directory"
     37)
     38
     39if(NOT PACPUS_INCLUDE_DIR)
     40    message(FATAL_ERROR "Could not find PACPUS. Please set CMake variable PACPUS_ROOT or environment variable PACPUS_ROOT.")
    2541endif()
    2642
    27 
    28 
    29 # Hint directories
    30 set(PACPUS_INCLUDE_HINT ${PACPUS_ROOT}/include)
    31 set(PACPUS_LIBRARY_HINT ${PACPUS_ROOT}/lib)
    32 
    33 # Locate the include files
    34 find_path(
    35     PACPUS_INCLUDE_DIR
    36     NAMES
    37         "Pacpus"
    38     HINTS
    39         ${PACPUS_INCLUDE_HINT}
    40     DOC
    41         "The Pacpus include directory"
    42 )
     43get_filename_component(PACPUS_ROOT ${PACPUS_INCLUDE_DIR}/.. ABSOLUTE)
     44set(PACPUS_LIB_DIR ${PACPUS_ROOT}/lib)
    4345
    4446# List of required modules
     
    5355# Check the presence of each module
    5456foreach(module ${PACPUS_MODULES})
     57    # release version
    5558    find_library(
    5659        PACPUS_${module}_LIB
    57         NAMES
    58             ${module}
    59         HINTS
    60             ${PACPUS_LIBRARY_HINT}
     60        NAMES ${module}
     61        HINTS ${PACPUS_LIB_DIR}
    6162    )
     63    if(PACPUS_${module}_LIB AND PACPUS_${module}_LIBD)
     64        list(APPEND PACPUS_LIBRARIES optimized ${PACPUS_${module}_LIB})
     65    else()
     66        message(SEND_ERROR "Cannot find Pacpus module ${module} (release version)")
     67        set(MODULE_MISSING TRUE)
     68    endif()
     69   
     70    # debug version
    6271    find_library(
    6372        PACPUS_${module}_LIBD
    64         NAMES
    65             ${module}_d
    66         HINTS
    67             ${PACPUS_LIBRARY_HINT}
     73        NAMES ${module}_d
     74        HINTS ${PACPUS_LIB_DIR}
    6875    )
    69 
    7076    if(PACPUS_${module}_LIB AND PACPUS_${module}_LIBD)
    71         list(APPEND PACPUS_LIBRARIES optimized ${PACPUS_${module}_LIB})
    7277        list(APPEND PACPUS_LIBRARIES debug ${PACPUS_${module}_LIBD})
    7378    else()
     79        message(SEND_ERROR "Cannot find Pacpus module ${module}_d (debug version)")
    7480        set(MODULE_MISSING TRUE)
    7581    endif()
    7682endforeach()
    7783
    78 if(NOT MODULE_MISSING AND PACPUS_INCLUDE_DIR)
    79     set(PACPUS_FOUND TRUE)
     84# handle the QUIETLY and REQUIRED arguments and set PACPUS_FOUND to TRUE if
     85# all listed variables are TRUE
     86include (FindPackageHandleStandardArgs)
     87set(PACPUS_ALL_MODULES_FOUND NOT MODULE_MISSING)
     88find_package_handle_standard_args (PACPUS DEFAULT_MSG PACPUS_LIBRARIES PACPUS_INCLUDE_DIR PACPUS_ALL_MODULES_FOUND)
    8089
    81     # Configure Pacpus
    82     list(APPEND CMAKE_MODULE_PATH "${PACPUS_ROOT}/cmake")
    83     include(${PACPUS_ROOT}/cmake/PacpusUtilities.cmake)
    84     include(${PACPUS_ROOT}/cmake/PacpusConfiguration.cmake)
    85     include(${PACPUS_ROOT}/cmake/PacpusDependencies.cmake)
    86     include(${PACPUS_ROOT}/cmake/PacpusPlatforms.cmake)
    87 
    88     #set(CMAKE_INSTALL_PREFIX ${PACPUS_ROOT})
     90if(PACPUS_FOUND)
    8991    set(PACPUS_INSTALL_DIR ${PACPUS_ROOT})
    90     set(PACPUS_LIB_DIR "${PACPUS_ROOT}/lib"
    91 )
    92     MESSAGE(STATUS "PACPUS_ROOT found ${PACPUS_ROOT}")
    93 
    94 else()
    95     set(PACPUS_FOUND FALSE)
    96 
    97     if(PACPUS_FIND_REQUIRED)
    98       MESSAGE(FATAL_ERROR "Could'not find PACPUS_ROOT ")
    99     else()
    100       MESSAGE(STATUS "Could'not find PACPUS_ROOT ")
    101     endif()
    102 
     92    set(PACPUS_CMAKE_DIR ${PACPUS_ROOT}/cmake)
     93    set(CMAKE_INSTALL_PREFIX ${PACPUS_INSTALL_DIR})
     94    list(APPEND CMAKE_PREFIX_PATH ${PACPUS_CMAKE_DIR})
     95    list(APPEND CMAKE_MODULE_PATH "${PACPUS_CMAKE_DIR}")
     96   
     97    include(${PACPUS_CMAKE_DIR}/PacpusUtilities.cmake)
     98    include(${PACPUS_CMAKE_DIR}/PacpusConfiguration.cmake)
     99    include(${PACPUS_CMAKE_DIR}/PacpusDependencies.cmake)
     100    include(${PACPUS_CMAKE_DIR}/PacpusPlatforms.cmake)
    103101endif()
Note: See TracChangeset for help on using the changeset viewer.