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


Ignore:
Timestamp:
07/19/13 12:42:35 (11 years ago)
Author:
morasjul
Message:

add cmake macro
and improve serial component

File:
1 edited

Legend:

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

    r120 r121  
    1313## Qt macro compatibility Qt4 / Qt5
    1414## ========================================
    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)
     15function(qt_wrap_cpp OUT_MOC_SRCS FILES_TO_MOC)
     16
     17    if(QT4_FOUNDED)
     18        qt4_wrap_cpp(MOC_SRCS ${FILES_TO_MOC})
     19
     20    elseif(Qt5Core_FOUND)
     21        qt5_wrap_cpp(MOC_SRCS ${FILES_TO_MOC})
     22
     23    else()
     24        message(WARNING "QT not found, can't wrap moc File")
     25    endif()
     26
     27    set(${OUT_MOC_SRCS} ${MOC_SRCS} PARENT_SCOPE)
     28
     29endfunction(qt_wrap_cpp)
    3030
    3131## ========================================
    3232## Qt macro compatibility Qt4 / Qt5
    3333## ========================================
    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()
     34function(qt_wrap_ui OUT_UI_SRCS UI_FILES)
     35    if(QT4_FOUND)
     36        qt4_wrap_ui( UI_SRCS ${UI_FILES})
     37
     38    elseif(Qt5Core_FOUND)
     39        qt5_wrap_ui( UI_SRCS ${UI_FILES})
     40
     41    else()
     42        message(WARNING "QT not found, can't wrap ui File")
     43    endif()
     44
     45    set(${OUT_UI_SRCS} ${UI_SRCS} PARENT_SCOPE)
     46
     47endfunction()
    4748
    4849# ========================================
     
    5354    if(QT4_FOUND)
    5455        pacpus_plugin_qt4(PLUGIN_CPP PLUGIN_H ${PROJECT_NAME} )
     56        #message("Create QT4 Plugin")
    5557
    5658    elseif(Qt5Core_FOUND)
     
    6163    endif()
    6264
     65    set(${OUT_CPP} ${PLUGIN_CPP} PARENT_SCOPE)
     66    set(${OUT_H} ${PLUGIN_H} PARENT_SCOPE)
    6367
    6468endfunction(PACPUS_PLUGIN)
     
    162166        "    Q_OBJECT\n"
    163167        "    //Qt5 Plugins Macro\n"
    164         "    Q_PLUGIN_METADATA(IID \"papus.pacpuscityvip." ${PLUGIN_NAME} "\" FILE \"" ${PLUGIN_NAME} ".json\")\n"
     168        "    Q_PLUGIN_METADATA(IID \"papus." ${PLUGIN_NAME} "\" FILE \"" ${PLUGIN_NAME} ".json\")\n"
    165169        "    Q_INTERFACES(PacpusPluginInterface)\n"   
    166170        "\n"
     
    366370  SET(${result} ${dirlist})
    367371ENDMACRO()
     372
     373
     374# ========================================
     375# Create export header for plugins
     376# ========================================
     377function(CREATE_EXPORT OUT_H PLUGIN_NAME)
     378
     379    set(${OUT_H} "export_${PLUGIN_NAME}.h" PARENT_SCOPE)
     380
     381    string(TOUPPER ${PLUGIN_NAME} PLUGIN_NAME_UPPER)
     382
     383    # create the header file
     384    file(WRITE "export_${PLUGIN_NAME}.h"
     385        "// Autogenerated file by PacpusUtilities.cmake\n"
     386        "// DO NOT EDIT!!! ALL CHANGES WOULD BE REMOVED BY THE NEXT CALL OF CMAKE\n"
     387        "\n"
     388
     389        "#ifndef __EXPORT_${PLUGIN_NAME_UPPER}__H__\n"
     390        "#define __EXPORT_${PLUGIN_NAME_UPPER}_H__\n"
     391        "\n"
     392        "// Export macro for use DLL for Windows only\n"
     393        "#ifdef WIN32\n"
     394        "#   ifdef ${PLUGIN_NAME_UPPER}_EXPORT\n"
     395        "//      make DLL\n"
     396        "#       define ${PLUGIN_NAME_UPPER}_API __declspec(dllexport)\n"
     397        "#   else\n"
     398        "//      use DLL\n"
     399        "#       define ${PLUGIN_NAME_UPPER}_API __declspec(dllimport)\n"
     400        "#   endif\n"
     401        "#else\n"
     402        "//      On other platforms, simply ignore this\n"
     403        "#       define ${PLUGIN_NAME_UPPER}_API\n"
     404        "//#endif\n"
     405
     406        "#endif // __EXPORT_${PLUGIN_NAME_UPPER}_H__\n"
     407        )
     408endfunction(CREATE_EXPORT)
Note: See TracChangeset for help on using the changeset viewer.