GenPkgConfig.cmake 4.41 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
###
#
# @copyright (c) 2009-2014 The University of Tennessee and The University
#                          of Tennessee Research Foundation.
#                          All rights reserved.
# @copyright (c) 2012-2014 Inria. All rights reserved.
# @copyright (c) 2012-2014 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, Univ. Bordeaux. All rights reserved.
#
###
#
#  @file GenPkgConfig.cmake
#
#  @project MORSE
#  MORSE is a software package provided by:
#     Inria Bordeaux - Sud-Ouest,
#     Univ. of Tennessee,
#     King Abdullah Univesity of Science and Technology
#     Univ. of California Berkeley,
#     Univ. of Colorado Denver. 
#
#  @version 0.9.0
#  @author Cedric Castagnede
#  @author Emmanuel Agullo
#  @author Mathieu Faverge
#  @author Florent Pruvost
#  @date 10-11-2014
#
###

###
#
# GENERATE_PKGCONFIG_FILE: generate a file .pc according to the options
#
###
MACRO(GENERATE_PKGCONFIG_FILE _file)

    # The link flags specific to this package and any required libraries
    # that don't support PkgConfig
    set(CHAMELEON_PKGCONFIG_LIBS "")
    # The link flags for private libraries required by this package but not
    # exposed to applications
    set(CHAMELEON_PKGCONFIG_LIBS_PRIVATE "")
    # A list of packages required by this package
    set(CHAMELEON_PKGCONFIG_REQUIRED "")
    # A list of private packages required by this package but not exposed to
    # applications
    set(CHAMELEON_PKGCONFIG_REQUIRED_PRIVATE "")

    list(APPEND CHAMELEON_PKGCONFIG_LIBS -lchameleon)
    if(CHAMELEON_SCHED_STARPU)
        list(APPEND CHAMELEON_PKGCONFIG_LIBS -lchameleon_starpu)
        if ( CHAMELEON_USE_MPI )
53
            list(APPEND CHAMELEON_PKGCONFIG_REQUIRED libstarpumpi)
54
        else()
55
            list(APPEND CHAMELEON_PKGCONFIG_REQUIRED libstarpu)
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
        endif()
    elseif(CHAMELEON_SCHED_QUARK)
        list(APPEND CHAMELEON_PKGCONFIG_LIBS -lchameleon_quark)
        list(APPEND CHAMELEON_PKGCONFIG_LIBS "-l${QUARK_quark_LIBRARY}")
    endif()


    if(NOT CHAMELEON_SIMULATION)

        if(CHAMELEON_USE_CUDA)
            list(APPEND CHAMELEON_PKGCONFIG_LIBS ${CUDA_LIBRARIES})
        endif()

        if(CHAMELEON_USE_MAGMA)
            list(APPEND CHAMELEON_PKGCONFIG_REQUIRED magma)
        endif()

        list(APPEND CHAMELEON_PKGCONFIG_LIBS
        -lcoreblas
        ${LAPACKE_LIBRARIES}
        ${CBLAS_LIBRARIES}
        ${EXTRA_LIBRARIES}
        )

        list(APPEND CHAMELEON_PKGCONFIG_REQUIRED hwloc)

    else(NOT CHAMELEON_SIMULATION)

        list(APPEND CHAMELEON_PKGCONFIG_LIBS 
        -lcoreblas
        ${EXTRA_LIBRARIES}
        )

        list(APPEND CHAMELEON_PKGCONFIG_REQUIRED hwloc)

    endif(NOT CHAMELEON_SIMULATION)

    # Define required package
    # -----------------------
    set(CHAMELEON_PKGCONFIG_LIBS_CPY "${CHAMELEON_PKGCONFIG_LIBS}")
    set(CHAMELEON_PKGCONFIG_LIBS "")
    foreach(_dep ${CHAMELEON_PKGCONFIG_LIBS_CPY})
98 99 100 101 102 103 104 105 106 107 108 109
        if (NOT ${_dep} MATCHES "^-L")
            get_filename_component(dep_we ${_dep} NAME)
            message(STATUS "dep_we : ${dep_we}")
            STRING(REPLACE "lib"    "-l" dep_we "${dep_we}")
            STRING(REPLACE ".so"    ""   dep_we "${dep_we}")
            STRING(REPLACE ".a"     ""   dep_we "${dep_we}")
            STRING(REPLACE ".dylib" ""   dep_we "${dep_we}")
            STRING(REPLACE ".dll"   ""   dep_we "${dep_we}")
            list(APPEND CHAMELEON_PKGCONFIG_LIBS ${dep_we})
        else()
            list(APPEND CHAMELEON_PKGCONFIG_LIBS ${_dep})
        endif()
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
    endforeach()

    list(REMOVE_DUPLICATES CHAMELEON_PKGCONFIG_LIBS)
    list(REMOVE_DUPLICATES CHAMELEON_PKGCONFIG_LIBS_PRIVATE)
    list(REMOVE_DUPLICATES CHAMELEON_PKGCONFIG_REQUIRED)
    list(REMOVE_DUPLICATES CHAMELEON_PKGCONFIG_REQUIRED_PRIVATE)

    STRING(REPLACE ";" " " CHAMELEON_PKGCONFIG_LIBS "${CHAMELEON_PKGCONFIG_LIBS}")
    STRING(REPLACE ";" " " CHAMELEON_PKGCONFIG_LIBS_PRIVATE "${CHAMELEON_PKGCONFIG_LIBS_PRIVATE}")
    STRING(REPLACE ";" " " CHAMELEON_PKGCONFIG_REQUIRED "${CHAMELEON_PKGCONFIG_REQUIRED}")
    STRING(REPLACE ";" " " CHAMELEON_PKGCONFIG_REQUIRED_PRIVATE "${CHAMELEON_PKGCONFIG_REQUIRED_PRIVATE}")

    # Create .pc file
    # ---------------
    SET(_output_file "${CMAKE_BINARY_DIR}/chameleon.pc")
    # TODO: add url of MORSE releases in .pc file
    CONFIGURE_FILE("${_file}" "${_output_file}" @ONLY)

    # installation
    # ------------
    INSTALL(FILES ${_output_file} DESTINATION lib/pkgconfig)

ENDMACRO(GENERATE_PKGCONFIG_FILE)

##
## @end file GenPkgConfig.cmake
##