1 | #################################################
|
---|
2 | # ___________ ____ ______ __ __ _____ #
|
---|
3 | # \____ \__ \ _/ ___\\____ \| | \/ ___/ #
|
---|
4 | # | |_> > __ \\ \___| |_> > | /\___ \ #
|
---|
5 | # | __(____ /\___ > __/|____//____ > #
|
---|
6 | # |__| \/ \/|__| \/ #
|
---|
7 | # #
|
---|
8 | #################################################
|
---|
9 |
|
---|
10 | # ========================================
|
---|
11 | # Output
|
---|
12 | # ========================================
|
---|
13 | set(PACPUS_DEFINITIONS "")
|
---|
14 | set(PACPUS_DEPENDENCIES_INC "")
|
---|
15 | set(PACPUS_DEPENDENCIES_LIB "")
|
---|
16 |
|
---|
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()
|
---|
25 | endif()
|
---|
26 |
|
---|
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}
|
---|
34 | )
|
---|
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 | )
|
---|
41 | endif()
|
---|
42 | # ========================================
|
---|
43 | # All the Pacpus modules depend on Qt5
|
---|
44 | # However, since each module requires specific Qt's modules, they have to include their own QT_USE_FILE
|
---|
45 | # ========================================
|
---|
46 |
|
---|
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}
|
---|
69 | )
|
---|
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)
|
---|
91 | endif()
|
---|
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 | # ========================================
|
---|
107 | if(PACPUS_USE_LOG)
|
---|
108 | list(APPEND PACPUS_DEFINITIONS " -DPACPUS_USE_LOG ")
|
---|
109 | list(APPEND PACPUS_DEFINITIONS " -DBOOST_ALL_DYN_LINK ")
|
---|
110 |
|
---|
111 | find_package(Boost 1.54.0 REQUIRED
|
---|
112 | COMPONENTS
|
---|
113 | log
|
---|
114 | log_setup
|
---|
115 | program_options
|
---|
116 | )
|
---|
117 | include_directories(${Boost_INCLUDE_DIRS})
|
---|
118 | link_directories(${Boost_LIBRARY_DIRS})
|
---|
119 |
|
---|
120 | list(APPEND PACPUS_DEPENDENCIES_INC ${Boost_INCLUDE_DIRS})
|
---|
121 | list(APPEND PACPUS_DEPENDENCIES_LIB ${Boost_LIBRARIES})
|
---|
122 | #message("\${PACPUS_DEPENDENCIES_LIB} = ${PACPUS_DEPENDENCIES_LIB}")
|
---|
123 | endif()
|
---|
124 |
|
---|
125 | # ========================================
|
---|
126 | # Doxygen
|
---|
127 | # ========================================
|
---|
128 | if(PACPUS_BUILD_DOC)
|
---|
129 | find_package(Doxygen)
|
---|
130 | if(NOT DOXYGEN_FOUND)
|
---|
131 | message(FATAL_ERROR "Doxygen is needed to build the documentation. Please install it correctly")
|
---|
132 | endif()
|
---|
133 | endif()
|
---|