source: pacpusframework/trunk/cmake/PacpusDependencies.cmake@ 177

Last change on this file since 177 was 175, checked in by morasjul, 11 years ago

[cmake] Fixed: Qt5 dependencies on Windows.

  • Property svn:executable set to *
File size: 4.1 KB
Line 
1#################################################
2# ___________ ____ ______ __ __ _____ #
3# \____ \__ \ _/ ___\\____ \| | \/ ___/ #
4# | |_> > __ \\ \___| |_> > | /\___ \ #
5# | __(____ /\___ > __/|____//____ > #
6# |__| \/ \/|__| \/ #
7# #
8#################################################
9
10# ========================================
11# Output
12# ========================================
13set(PACPUS_DEFINITIONS "")
14set(PACPUS_DEPENDENCIES_INC "")
15set(PACPUS_DEPENDENCIES_LIB "")
16
17set(PACPUS_USE_QT5 FALSE CACHE BOOL "Whether to use Qt5")
18if(NOT PACPUS_USE_QT5)
19 find_package(Qt4)
20 if(NOT QT4_FOUND)
21 message(WARNING "Qt4 not found try to find Qt5")
22 set(PACPUS_USE_QT5 TRUE)
23 endif()
24endif()
25
26if(PACPUS_USE_QT5)
27 # message(STATUS "Set CMake variable 'CMAKE_PREFIX_PATH' to the path like '%QT_BIN%/../lib/cmake'")
28 set(QT_CMAKE_DIR "$ENV{QT_BIN}/../lib/cmake")
29 get_filename_component(QT_CMAKE_DIR "${QT_CMAKE_DIR}" ABSOLUTE)
30 message(STATUS "\${QT_CMAKE_DIR} = '${QT_CMAKE_DIR}'")
31 list(APPEND CMAKE_PREFIX_PATH
32 ${QT_CMAKE_DIR}
33 )
34 if(WIN32)
35 message(STATUS "Environment variable 'WINSDK_LIB' should be set to something like 'C:/Program Files (x86)/Windows Kits/8.0/Lib/win8/um/x86'")
36 message(STATUS "\$ENV{WINSDK_LIB} = '$ENV{WINSDK_LIB}'")
37 list(APPEND CMAKE_PREFIX_PATH
38 $ENV{WINSDK_LIB}
39 )
40 endif()
41# ========================================
42# All the Pacpus modules depend on Qt5
43# However, since each module requires specific Qt's modules, they have to include their own QT_USE_FILE
44# ========================================
45
46# Tell CMake to run moc when necessary:
47#set(CMAKE_AUTOMOC ON)
48# As moc files are generated in the binary dir, tell CMake
49# to always look for includes there:
50set(CMAKE_INCLUDE_CURRENT_DIR ON)
51
52find_package(Qt5Widgets REQUIRED)
53find_package(Qt5Core REQUIRED)
54find_package(Qt5Xml REQUIRED)
55find_package(Qt5Gui REQUIRED)
56find_package(Qt5OpenGL REQUIRED)
57find_package(Qt5Network REQUIRED)
58find_package(Qt5SerialPort REQUIRED)
59
60set(QT_DEFINITIONS
61 ${Qt5Widgets_DEFINITIONS}
62 ${Qt5Core_DEFINITIONS}
63 ${Qt5Xml_DEFINITIONS}
64 ${Qt5Gui_DEFINITIONS}
65 ${Qt5OpenGL_DEFINITIONS}
66 ${Qt5Network_DEFINITIONS}
67 ${Qt5SerialPort_DEFINITIONS}
68)
69set(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)
78set(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
88if(Qt5_POSITION_INDEPENDENT_CODE)
89 set(CMAKE_POSITION_INDEPENDENT_CODE ON)
90endif()
91
92else()
93
94# ========================================
95# All the Pacpus modules depend on Qt4
96# However, since each module requires specific Qt modules, they have to include their own QT_USE_FILE
97# ========================================
98find_package(Qt4 REQUIRED)
99
100endif()
101
102# ========================================
103# Boost
104# Do not use compiled modules, include-only headers.
105# ========================================
106if(PACPUS_USE_LOG)
107 list(APPEND PACPUS_DEFINITIONS " -DPACPUS_USE_LOG ")
108 list(APPEND PACPUS_DEFINITIONS " -DBOOST_ALL_DYN_LINK ")
109
110 find_package(Boost 1.54.0 REQUIRED
111 COMPONENTS
112 log
113 log_setup
114 )
115 include_directories(${Boost_INCLUDE_DIRS})
116 link_directories(${Boost_LIBRARY_DIRS})
117
118 list(APPEND PACPUS_DEPENDENCIES_INC ${Boost_INCLUDE_DIRS})
119 list(APPEND PACPUS_DEPENDENCIES_LIB ${Boost_LIBRARIES})
120 #message("\${PACPUS_DEPENDENCIES_LIB} = ${PACPUS_DEPENDENCIES_LIB}")
121endif()
122
123# ========================================
124# Doxygen
125# ========================================
126if(PACPUS_BUILD_DOC)
127 find_package(Doxygen)
128 if(NOT DOXYGEN_FOUND)
129 message(FATAL_ERROR "Doxygen is needed to build the documentation. Please install it correctly")
130 endif()
131endif()
Note: See TracBrowser for help on using the repository browser.