[89] | 1 | #################################################
|
---|
| 2 | # ___________ ____ ______ __ __ _____ #
|
---|
| 3 | # \____ \__ \ _/ ___\\____ \| | \/ ___/ #
|
---|
| 4 | # | |_> > __ \\ \___| |_> > | /\___ \ #
|
---|
| 5 | # | __(____ /\___ > __/|____//____ > #
|
---|
| 6 | # |__| \/ \/|__| \/ #
|
---|
| 7 | # #
|
---|
| 8 | #################################################
|
---|
| 9 |
|
---|
[187] | 10 | ################################################################################
|
---|
| 11 | # OUTPUT
|
---|
[89] | 12 | set(PACPUS_DEPENDENCIES_INC "")
|
---|
| 13 | set(PACPUS_DEPENDENCIES_LIB "")
|
---|
| 14 |
|
---|
[187] | 15 | ################################################################################
|
---|
| 16 | # Necessary for Qt5
|
---|
| 17 | # message(STATUS "Set CMake variable 'CMAKE_PREFIX_PATH' to the path like '%QT_BIN%/../lib/cmake'")
|
---|
| 18 | set(QT_CMAKE_DIR "$ENV{QT_BIN}/../lib/cmake")
|
---|
| 19 | get_filename_component(QT_CMAKE_DIR "${QT_CMAKE_DIR}" ABSOLUTE)
|
---|
[226] | 20 | if(DEBUG)
|
---|
[267] | 21 | message(STATUS "\${QT_CMAKE_DIR} = '${QT_CMAKE_DIR}'")
|
---|
[226] | 22 | endif()
|
---|
[187] | 23 | list(APPEND CMAKE_PREFIX_PATH
|
---|
| 24 | ${QT_CMAKE_DIR}
|
---|
| 25 | )
|
---|
| 26 | if(WIN32)
|
---|
[267] | 27 | set(WINSDK_LIB "$ENV{WINSDK_LIB}" CACHE PATH "Directory of Windows Development Kit, should contain glu32.lib.")
|
---|
| 28 | if("${WINSDK_LIB}" STREQUAL "")
|
---|
| 29 | message(STATUS "Environment variable 'WINSDK_LIB' should be set to something like 'C:/Program Files (x86)/Windows Kits/8.0/Lib/win8/um/x86'")
|
---|
| 30 | endif()
|
---|
| 31 | if(DEBUG)
|
---|
| 32 | message(STATUS "\$ENV{WINSDK_LIB} = '$ENV{WINSDK_LIB}'")
|
---|
| 33 | message(STATUS "\${WINSDK_LIB} = '${WINSDK_LIB}'")
|
---|
| 34 | endif()
|
---|
[187] | 35 | list(APPEND CMAKE_PREFIX_PATH
|
---|
[226] | 36 | ${WINSDK_LIB}
|
---|
[187] | 37 | )
|
---|
[119] | 38 | endif()
|
---|
[226] | 39 | if(DEBUG)
|
---|
[267] | 40 | message(STATUS "\${CMAKE_PREFIX_PATH} = '${CMAKE_PREFIX_PATH}'")
|
---|
[226] | 41 | endif()
|
---|
[119] | 42 |
|
---|
[187] | 43 | ################################################################################
|
---|
| 44 | # Find Qt
|
---|
| 45 | find_package(Qt5Widgets QUIET)
|
---|
| 46 | if(Qt5Widgets_FOUND)
|
---|
| 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(Qt5Core REQUIRED)
|
---|
| 54 | find_package(Qt5Xml REQUIRED)
|
---|
| 55 | find_package(Qt5Gui REQUIRED)
|
---|
[234] | 56 | #find_package(Qt5OpenGL REQUIRED)
|
---|
| 57 | #find_package(Qt5Network REQUIRED)
|
---|
| 58 | #find_package(Qt5SerialPort REQUIRED)
|
---|
[187] | 59 |
|
---|
| 60 | set(QT_DEFINITIONS
|
---|
| 61 | ${Qt5Widgets_DEFINITIONS}
|
---|
| 62 | ${Qt5Core_DEFINITIONS}
|
---|
| 63 | ${Qt5Xml_DEFINITIONS}
|
---|
| 64 | ${Qt5Gui_DEFINITIONS}
|
---|
| 65 | ${Qt5OpenGL_DEFINITIONS}
|
---|
| 66 | ${Qt5Network_DEFINITIONS}
|
---|
| 67 | ${Qt5SerialPort_DEFINITIONS}
|
---|
[175] | 68 | )
|
---|
[187] | 69 | set(QT_INCLUDE_DIR
|
---|
| 70 | ${Qt5Widgets_INCLUDE_DIRS}
|
---|
| 71 | ${Qt5Core_INCLUDE_DIRS}
|
---|
| 72 | ${Qt5Xml_INCLUDE_DIRS}
|
---|
| 73 | ${Qt5Gui_INCLUDE_DIRS}
|
---|
| 74 | ${Qt5OpenGL_INCLUDE_DIRS}
|
---|
| 75 | ${Qt5Network_INCLUDE_DIRS}
|
---|
| 76 | ${Qt5SerialPort_INCLUDE_DIRS}
|
---|
| 77 | )
|
---|
| 78 | set(QT_LIBRARIES
|
---|
| 79 | ${Qt5Widgets_LIBRARIES}
|
---|
| 80 | ${Qt5Core_LIBRARIES}
|
---|
| 81 | ${Qt5Xml_LIBRARIES}
|
---|
| 82 | ${Qt5Gui_LIBRARIES}
|
---|
| 83 | ${Qt5OpenGL_LIBRARIES}
|
---|
| 84 | ${Qt5Network_LIBRARIES}
|
---|
| 85 | ${Qt5SerialPort_LIBRARIES}
|
---|
| 86 | )
|
---|
| 87 |
|
---|
| 88 | if(Qt5_POSITION_INDEPENDENT_CODE)
|
---|
| 89 | set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
---|
[175] | 90 | endif()
|
---|
[187] | 91 | else()
|
---|
| 92 | message(STATUS "Qt5 not found: try to find Qt4")
|
---|
| 93 |
|
---|
[214] | 94 | find_package(Qt4 REQUIRED QtCore QtGui QtXml)
|
---|
| 95 | include(${QT_USE_FILE})
|
---|
[187] | 96 | endif()
|
---|
| 97 |
|
---|
| 98 | ################################################################################
|
---|
[127] | 99 | # All the Pacpus modules depend on Qt5
|
---|
[89] | 100 | # However, since each module requires specific Qt's modules, they have to include their own QT_USE_FILE
|
---|
| 101 |
|
---|
[187] | 102 | ################################################################################
|
---|
| 103 | # Boost
|
---|
[239] | 104 | set(Boost_USE_STATIC_LIBS OFF)
|
---|
| 105 | set(Boost_USE_MULTITHREADED ON)
|
---|
| 106 | set(Boost_USE_STATIC_RUNTIME OFF)
|
---|
[187] | 107 | list(APPEND PACPUS_DEFINITIONS " -DBOOST_ALL_DYN_LINK ")
|
---|
[285] | 108 | if(CMAKE_COMPILER_IS_GNUC)
|
---|
| 109 | list(APPEND PACPUS_DEFINITIONS " -lpthread ")
|
---|
| 110 | endif()
|
---|
[239] | 111 | find_package(Boost 1.54.0
|
---|
[187] | 112 | COMPONENTS
|
---|
[285] | 113 | chrono # thread
|
---|
| 114 | date_time # thread
|
---|
[239] | 115 | program_options #1.32.0
|
---|
[285] | 116 | system # log, thread needed on Linux
|
---|
| 117 | thread
|
---|
[89] | 118 | )
|
---|
[187] | 119 | if(Boost_FOUND)
|
---|
| 120 | include_directories(${Boost_INCLUDE_DIRS})
|
---|
| 121 | link_directories(${Boost_LIBRARY_DIRS})
|
---|
| 122 | list(APPEND PACPUS_DEPENDENCIES_INC ${Boost_INCLUDE_DIRS})
|
---|
| 123 | list(APPEND PACPUS_DEPENDENCIES_LIB ${Boost_LIBRARIES})
|
---|
[89] | 124 | endif()
|
---|
[301] | 125 |
|
---|
[89] | 126 | if(PACPUS_USE_LOG)
|
---|
[141] | 127 | find_package(Boost 1.54.0 REQUIRED
|
---|
| 128 | COMPONENTS
|
---|
[239] | 129 | #filesystem
|
---|
| 130 | log # 1.54.0
|
---|
[285] | 131 | log_setup # log
|
---|
[141] | 132 | )
|
---|
| 133 | list(APPEND PACPUS_DEPENDENCIES_INC ${Boost_INCLUDE_DIRS})
|
---|
| 134 | list(APPEND PACPUS_DEPENDENCIES_LIB ${Boost_LIBRARIES})
|
---|
[89] | 135 | endif()
|
---|
[301] | 136 | if(PACPUS_BUILD_TESTS)
|
---|
| 137 | find_package(Boost 1.21.0 REQUIRED
|
---|
| 138 | COMPONENTS
|
---|
| 139 | unit_test_framework
|
---|
| 140 | )
|
---|
| 141 | list(APPEND PACPUS_DEPENDENCIES_INC ${Boost_INCLUDE_DIRS})
|
---|
| 142 | list(APPEND PACPUS_DEPENDENCIES_LIB ${Boost_LIBRARIES})
|
---|
| 143 | endif()
|
---|
[89] | 144 |
|
---|
[187] | 145 | ################################################################################
|
---|
| 146 | # DOCUMENTATION
|
---|
[89] | 147 | if(PACPUS_BUILD_DOC)
|
---|
| 148 | find_package(Doxygen)
|
---|
| 149 | if(NOT DOXYGEN_FOUND)
|
---|
| 150 | message(FATAL_ERROR "Doxygen is needed to build the documentation. Please install it correctly")
|
---|
| 151 | endif()
|
---|
| 152 | endif()
|
---|