Changeset 187 in pacpusframework


Ignore:
Timestamp:
10/23/13 10:58:40 (11 years ago)
Author:
morasjul
Message:

Fixed: towards Qt4/Qt5 compatibility.

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/CMakeLists.txt

    r185 r187  
    3030set(PACPUS_DOC_DIR          ${PACPUS_ROOT_DIR}/doc)
    3131set(PACPUS_EXAMPLES_DIR     ${PACPUS_ROOT_DIR}/examples)
    32 set(PACPUS_INCLUDE_DIR      ${PACPUS_ROOT_DIR}/include/)
     32set(PACPUS_INCLUDE_DIR      ${PACPUS_ROOT_DIR}/include)
    3333set(PACPUS_SCRIPTS_DIR      ${PACPUS_ROOT_DIR}/scripts)
    3434set(PACPUS_SOURCE_DIR       ${PACPUS_ROOT_DIR}/src)
  • trunk/cmake/PacpusConfiguration.cmake

    r163 r187  
    2525set(PACPUS_USE_SOLUTION_FOLDERS  FALSE CACHE BOOL "Use solution folders to classify projects, works in MS Visual Studio")
    2626
    27 set(QT5      FALSE CACHE BOOL " Use Qt5 or Qt4")
    28 
    2927if(PACPUS_USE_SOLUTION_FOLDERS)
    3028    if(CMAKE_VERSION VERSION_GREATER "2.8.0")
  • trunk/cmake/PacpusDependencies.cmake

    r178 r187  
    88#################################################
    99
    10 # ========================================
    11 # Output
    12 # ========================================
     10################################################################################
     11# OUTPUT
    1312set(PACPUS_DEFINITIONS "")
    1413set(PACPUS_DEPENDENCIES_INC "")
    1514set(PACPUS_DEPENDENCIES_LIB "")
    1615
    17 # FIXME: first find_package(Qt5Widgets QUIET), then Qt4
    18 set(PACPUS_USE_QT5 FALSE CACHE BOOL "Whether to use Qt5")
    19 if(NOT PACPUS_USE_QT5)
    20     find_package(Qt4 QUIET)
    21     if(NOT QT4_FOUND)
    22         message(WARNING "Qt4 not found try to find Qt5")
    23         set(PACPUS_USE_QT5 TRUE)
    24     endif()
     16################################################################################
     17# Necessary for Qt5
     18# message(STATUS "Set CMake variable 'CMAKE_PREFIX_PATH' to the path like '%QT_BIN%/../lib/cmake'")
     19set(QT_CMAKE_DIR "$ENV{QT_BIN}/../lib/cmake")
     20get_filename_component(QT_CMAKE_DIR "${QT_CMAKE_DIR}" ABSOLUTE)
     21#message(STATUS "\${QT_CMAKE_DIR} = '${QT_CMAKE_DIR}'")
     22list(APPEND CMAKE_PREFIX_PATH
     23    ${QT_CMAKE_DIR}
     24)
     25if(WIN32)
     26    message(STATUS "Environment variable 'WINSDK_LIB' should be set to something like 'C:/Program Files (x86)/Windows Kits/8.0/Lib/win8/um/x86'")
     27    #message(STATUS "\$ENV{WINSDK_LIB} = '$ENV{WINSDK_LIB}'")
     28    list(APPEND CMAKE_PREFIX_PATH
     29        $ENV{WINSDK_LIB}
     30    )
    2531endif()
    2632
    27 if(PACPUS_USE_QT5)
    28     # message(STATUS "Set CMake variable 'CMAKE_PREFIX_PATH' to the path like '%QT_BIN%/../lib/cmake'")
    29     set(QT_CMAKE_DIR "$ENV{QT_BIN}/../lib/cmake")
    30     get_filename_component(QT_CMAKE_DIR "${QT_CMAKE_DIR}" ABSOLUTE)
    31     message(STATUS "\${QT_CMAKE_DIR} = '${QT_CMAKE_DIR}'")
    32     list(APPEND CMAKE_PREFIX_PATH
    33         ${QT_CMAKE_DIR}
     33################################################################################
     34# Find Qt
     35find_package(Qt5Widgets QUIET)
     36if(Qt5Widgets_FOUND)
     37    # Tell CMake to run moc when necessary:
     38    #set(CMAKE_AUTOMOC ON)
     39    # As moc files are generated in the binary dir, tell CMake
     40    # to always look for includes there:
     41    set(CMAKE_INCLUDE_CURRENT_DIR ON)       
     42   
     43    find_package(Qt5Core REQUIRED)
     44    find_package(Qt5Xml REQUIRED)
     45    find_package(Qt5Gui REQUIRED)
     46    find_package(Qt5OpenGL REQUIRED)
     47    find_package(Qt5Network REQUIRED)
     48    find_package(Qt5SerialPort REQUIRED)
     49       
     50    set(QT_DEFINITIONS
     51        ${Qt5Widgets_DEFINITIONS}
     52        ${Qt5Core_DEFINITIONS}
     53        ${Qt5Xml_DEFINITIONS}
     54        ${Qt5Gui_DEFINITIONS}
     55        ${Qt5OpenGL_DEFINITIONS}
     56        ${Qt5Network_DEFINITIONS}
     57        ${Qt5SerialPort_DEFINITIONS}
    3458    )
    35     if(WIN32)
    36         message(STATUS "Environment variable 'WINSDK_LIB' should be set to something like 'C:/Program Files (x86)/Windows Kits/8.0/Lib/win8/um/x86'")
    37         message(STATUS "\$ENV{WINSDK_LIB} = '$ENV{WINSDK_LIB}'")
    38         list(APPEND CMAKE_PREFIX_PATH
    39             $ENV{WINSDK_LIB}
    40         )
     59    set(QT_INCLUDE_DIR
     60        ${Qt5Widgets_INCLUDE_DIRS}
     61        ${Qt5Core_INCLUDE_DIRS}
     62        ${Qt5Xml_INCLUDE_DIRS}
     63        ${Qt5Gui_INCLUDE_DIRS}
     64        ${Qt5OpenGL_INCLUDE_DIRS}
     65        ${Qt5Network_INCLUDE_DIRS}
     66        ${Qt5SerialPort_INCLUDE_DIRS}
     67    )
     68    set(QT_LIBRARIES
     69        ${Qt5Widgets_LIBRARIES}
     70        ${Qt5Core_LIBRARIES}
     71        ${Qt5Xml_LIBRARIES}
     72        ${Qt5Gui_LIBRARIES}
     73        ${Qt5OpenGL_LIBRARIES}
     74        ${Qt5Network_LIBRARIES}
     75        ${Qt5SerialPort_LIBRARIES}
     76    )
     77   
     78    if(Qt5_POSITION_INDEPENDENT_CODE)
     79      set(CMAKE_POSITION_INDEPENDENT_CODE ON)
    4180    endif()
    42 # ========================================
     81else()
     82    message(STATUS "Qt5 not found: try to find Qt4")
     83   
     84    find_package(Qt4 REQUIRED)
     85endif()
     86
     87################################################################################
    4388# All the Pacpus modules depend on Qt5
    4489# However, since each module requires specific Qt's modules, they have to include their own QT_USE_FILE
    45 # ========================================
    4690
    47 # Tell CMake to run moc when necessary:
    48 #set(CMAKE_AUTOMOC ON)
    49 # As moc files are generated in the binary dir, tell CMake
    50 # to always look for includes there:
    51 set(CMAKE_INCLUDE_CURRENT_DIR ON)
    52 
    53 find_package(Qt5Widgets REQUIRED)
    54 find_package(Qt5Core REQUIRED)
    55 find_package(Qt5Xml REQUIRED)
    56 find_package(Qt5Gui REQUIRED)
    57 find_package(Qt5OpenGL REQUIRED)
    58 find_package(Qt5Network REQUIRED)
    59 find_package(Qt5SerialPort REQUIRED)
    60 
    61 set(QT_DEFINITIONS
    62     ${Qt5Widgets_DEFINITIONS}
    63     ${Qt5Core_DEFINITIONS}
    64     ${Qt5Xml_DEFINITIONS}
    65     ${Qt5Gui_DEFINITIONS}
    66     ${Qt5OpenGL_DEFINITIONS}
    67     ${Qt5Network_DEFINITIONS}
    68     ${Qt5SerialPort_DEFINITIONS}
     91################################################################################
     92# Boost
     93list(APPEND PACPUS_DEFINITIONS " -DBOOST_ALL_DYN_LINK ")
     94find_package(Boost 1.54.0
     95    COMPONENTS
     96        program_options
    6997)
    70 set(QT_INCLUDE_DIR
    71     ${Qt5Widgets_INCLUDE_DIRS}
    72     ${Qt5Core_INCLUDE_DIRS}
    73     ${Qt5Xml_INCLUDE_DIRS}
    74     ${Qt5Gui_INCLUDE_DIRS}
    75     ${Qt5OpenGL_INCLUDE_DIRS}
    76     ${Qt5Network_INCLUDE_DIRS}
    77     ${Qt5SerialPort_INCLUDE_DIRS}
    78 )
    79 set(QT_LIBRARIES
    80     ${Qt5Widgets_LIBRARIES}
    81     ${Qt5Core_LIBRARIES}
    82     ${Qt5Xml_LIBRARIES}
    83     ${Qt5Gui_LIBRARIES}
    84     ${Qt5OpenGL_LIBRARIES}
    85     ${Qt5Network_LIBRARIES}
    86     ${Qt5SerialPort_LIBRARIES}
    87 )
    88 
    89 if(Qt5_POSITION_INDEPENDENT_CODE)
    90   set(CMAKE_POSITION_INDEPENDENT_CODE ON)
     98if(Boost_FOUND)
     99    include_directories(${Boost_INCLUDE_DIRS})
     100    link_directories(${Boost_LIBRARY_DIRS})
     101    list(APPEND PACPUS_DEPENDENCIES_INC ${Boost_INCLUDE_DIRS})
     102    list(APPEND PACPUS_DEPENDENCIES_LIB ${Boost_LIBRARIES})
    91103endif()
    92 
    93 else()
    94 
    95 # ========================================
    96 # All the Pacpus modules depend on Qt4
    97 # However, since each module requires specific Qt modules, they have to include their own QT_USE_FILE
    98 # ========================================
    99 find_package(Qt4 REQUIRED)
    100 
    101 endif()
    102 
    103 # ========================================
    104 # Boost
    105 # Do not use compiled modules, include-only headers.
    106 # ========================================
    107104if(PACPUS_USE_LOG)
    108105    list(APPEND PACPUS_DEFINITIONS " -DPACPUS_USE_LOG ")
    109     list(APPEND PACPUS_DEFINITIONS " -DBOOST_ALL_DYN_LINK ")
    110    
    111106    find_package(Boost 1.54.0 REQUIRED
    112107        COMPONENTS
    113108            log
    114109            log_setup
    115             program_options
    116110    )
    117111    include_directories(${Boost_INCLUDE_DIRS})
    118112    link_directories(${Boost_LIBRARY_DIRS})
    119    
    120113    list(APPEND PACPUS_DEPENDENCIES_INC ${Boost_INCLUDE_DIRS})
    121114    list(APPEND PACPUS_DEPENDENCIES_LIB ${Boost_LIBRARIES})
    122     #message("\${PACPUS_DEPENDENCIES_LIB} = ${PACPUS_DEPENDENCIES_LIB}")
    123115endif()
    124116
    125 # ========================================
    126 # Doxygen
    127 # ========================================
     117################################################################################
     118# DOCUMENTATION
    128119if(PACPUS_BUILD_DOC)
    129120    find_package(Doxygen)
  • trunk/cmake/PacpusInstall.cmake

    r185 r187  
    2323        ${PACPUS_INCLUDE_DIR}
    2424    DESTINATION
    25         ${PACPUS_INSTALL_DIR}/include
     25        ${PACPUS_INSTALL_DIR}
    2626)
    2727
  • trunk/examples/ProducerConsumerExample/CMakeLists.txt

    r185 r187  
    7373    optimized PacpusLib debug PacpusLib_d
    7474)
    75 message(STATUS "\${PACPUS_LIBRARIES} = ${PACPUS_LIBRARIES}")
    76 message(STATUS "\${PACPUS_DEPENDENCIES_LIB} = ${PACPUS_DEPENDENCIES_LIB}")
     75#message(STATUS "\${PACPUS_LIBRARIES} = ${PACPUS_LIBRARIES}")
     76#message(STATUS "\${PACPUS_DEPENDENCIES_LIB} = ${PACPUS_DEPENDENCIES_LIB}")
    7777# LIBS
    7878set(LIBS
Note: See TracChangeset for help on using the changeset viewer.