Changeset 120 in pacpusframework for branches/2.0-beta1/cmake/PacpusUtilities.cmake


Ignore:
Timestamp:
Jul 15, 2013, 4:59:37 PM (11 years ago)
Author:
morasjul
Message:
  • add PacpusSerialport (QT 5.1 required)
  • add part of QT4 / QT5 cmake script
  • fix CMake (link)
  • add ComponentBase virtual function addInput() & addOutput() call before component configuration
File:
1 edited

Legend:

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

    r99 r120  
    88#################################################
    99
    10 # ========================================
    11 # Create a Pacpus plugin
     10
     11# TODO  Compatibility macro
     12## ========================================
     13## Qt macro compatibility Qt4 / Qt5
     14## ========================================
     15#function(qt_wrap_moc MOC_SRCS FILES_TO_MOC)
     16
     17#    if(QT4_FOUNDED)
     18#        qt4_wrap_cpp(TEMP_VAR ${FILES_TO_MOC})
     19
     20#    elseif(Qt5Core_FOUND)
     21#        qt5_wrap_cpp(${MOC_SRCS} ${FILES_TO_MOC} PARENT_SCOPE)
     22
     23#    else()
     24#        message(WARNING "QT ui found, can't wrap moc File")
     25#    endif()
     26
     27#    #set(${MOC_SRCS} ${TEMP_VAR} PARENT_SCOPE)
     28
     29#endfunction(qt_wrap_moc)
     30
     31## ========================================
     32## Qt macro compatibility Qt4 / Qt5
     33## ========================================
     34#function(qt_wrap_ui UI_SRCS UI_FILES)
     35#    if(QT4_FOUND)
     36#        qt4_wrap_ui( TEMP_VAR ${UI_FILES})
     37
     38#    elseif(Qt5Core_FOUND)
     39#        qt5_wrap_ui( TEMP_VAR ${UI_FILES})
     40
     41#    else()
     42#        message(WARNING "QT ui found, can't wrap ui File")
     43#    endif()
     44
     45#    set(${UI_SRCS} ${TEMP_VAR} PARENT_SCOPE)
     46#endfunction()
     47
     48# ========================================
     49# Generic macro for Pacpus plugin
    1250# ========================================
    1351function(PACPUS_PLUGIN OUT_CPP OUT_H PLUGIN_NAME)
     52
     53    if(QT4_FOUND)
     54        pacpus_plugin_qt4(PLUGIN_CPP PLUGIN_H ${PROJECT_NAME} )
     55
     56    elseif(Qt5Core_FOUND)
     57        pacpus_plugin_qt5(PLUGIN_CPP PLUGIN_H ${PROJECT_NAME} )
     58
     59    else()
     60        message(WARNING "QT not found, can't create Plugin")
     61    endif()
     62
     63
     64endfunction(PACPUS_PLUGIN)
     65
     66# ========================================
     67# Create a Pacpus plugin QT4
     68# ========================================
     69function(PACPUS_PLUGIN_QT4 OUT_CPP OUT_H PLUGIN_NAME)
     70
     71    set(PLUGIN_NAME ${PLUGIN_NAME}Plugin)
     72    set(${OUT_CPP} ${PLUGIN_NAME}.cpp PARENT_SCOPE)
     73    set(${OUT_H} ${PLUGIN_NAME}.h PARENT_SCOPE)
     74
     75    string(TOUPPER ${PLUGIN_NAME} PLUGIN_NAME_UPPER)
     76
     77    # create the header file
     78    file(WRITE ${PLUGIN_NAME}.h
     79        "// Autogenerated file by PacpusPlugin.cmake\n"
     80        "// DO NOT EDIT!!! ALL CHANGES WOULD BE REMOVED BY THE NEXT CALL OF CMAKE\n"
     81        "\n"
     82        "#ifndef __${PLUGIN_NAME_UPPER}_H__\n"
     83        "#define __${PLUGIN_NAME_UPPER}_H__\n"
     84        "\n"
     85        "#include <QObject>\n"
     86        "#include <qplugin.h>\n"
     87        "\n"
     88        "#include <Pacpus/kernel/PacpusPluginInterface.h>\n"
     89        "\n"
     90        "/// Auto-generated plugin class\n"
     91        "class ${PLUGIN_NAME}\n"
     92        "    : public QObject\n"
     93        "    , public PacpusPluginInterface\n"
     94        "{\n"
     95        "    Q_OBJECT\n"
     96        "    Q_INTERFACES(PacpusPluginInterface)\n"
     97        "\n"
     98        "public:\n"
     99        "    ${PLUGIN_NAME}();\n"
     100        "    ~${PLUGIN_NAME}();\n"
     101        "\n"
     102        "protected:\n"
     103        "    QString name();\n"
     104        "};\n"
     105        "\n"
     106        "#endif // __${PLUGIN_NAME_UPPER}_H__\n"
     107    )
     108
     109    # create the cpp file
     110    file(WRITE ${PLUGIN_NAME}.cpp
     111        "// Autogenerated file by PacpusPlugin.cmake\n"
     112        "// DO NOT EDIT!!! ALL CHANGES WOULD BE REMOVED BY THE NEXT CALL OF CMAKE\n"
     113        "\n"
     114        "#include \"${PLUGIN_NAME}.h\"\n"
     115        "\n"
     116        "${PLUGIN_NAME}::${PLUGIN_NAME}()\n"
     117        "{\n"
     118        "}\n"
     119        "\n"
     120        "${PLUGIN_NAME}::~${PLUGIN_NAME}()\n"
     121        "{\n"
     122        "}\n"
     123        "\n"
     124        "QString ${PLUGIN_NAME}::name()\n"
     125        "{\n"
     126        "    return \"${PLUGIN_NAME}\";\n"
     127        "}\n"
     128        "\n"
     129        "Q_EXPORT_PLUGIN2(${PLUGIN_NAME}, ${PLUGIN_NAME})\n"
     130    )
     131endfunction(PACPUS_PLUGIN_QT4)
     132
     133# ========================================
     134# Create a Pacpus plugin QT5
     135# ========================================
     136function(PACPUS_PLUGIN_QT5 OUT_CPP OUT_H PLUGIN_NAME)
    14137
    15138    set(PLUGIN_NAME ${PLUGIN_NAME}Plugin)
     
    82205        "}\n"
    83206        )
    84 endfunction(PACPUS_PLUGIN)
     207endfunction(PACPUS_PLUGIN_QT5)
    85208
    86209# ========================================
Note: See TracChangeset for help on using the changeset viewer.