FindQwt5.cmake 7.99 KB
Newer Older
Jan Möbius's avatar
Jan Möbius committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# Find the Qwt 5.x includes and library, either the version linked to Qt3 or the version linked to Qt4
#
# On Windows it makes these assumptions:
#    - the Qwt DLL is where the other DLLs for Qt are (QT_DIR\bin) or in the path
#    - the Qwt .h files are in QT_DIR\include\Qwt or in the path
#    - the Qwt .lib is where the other LIBs for Qt are (QT_DIR\lib) or in the path
#
# Qwt5_INCLUDE_DIR - where to find qwt.h if Qwt
# Qwt5_Qt4_LIBRARY - The Qwt5 library linked against Qt4 (if it exists)#
# Qwt5_Qt4_LIBRARY_DIR 
# Qwt5_Qt3_LIBRARY - The Qwt5 library linked against Qt4 (if it exists)
# Qwt5_Qt4_FOUND   - Qwt5 was found and uses Qt4
# Qwt5_Qt3_FOUND   - Qwt5 was found and uses Qt3
# Qwt5_FOUND - Set to TRUE if Qwt5 was found (linked either to Qt3 or Qt4)

# Copyright (c) 2007, Pau Garcia i Quiles, <pgquiles@elpauer.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.

# Condition is "(A OR B) AND C", CMake does not support parentheses but it evaluates left to right
IF(Qwt5_Qt4_LIBRARY OR Qwt5_Qt3_LIBRARY AND Qwt5_INCLUDE_DIR)
    SET(Qwt5_FIND_QUIETLY TRUE)
ENDIF(Qwt5_Qt4_LIBRARY OR Qwt5_Qt3_LIBRARY AND Qwt5_INCLUDE_DIR)

IF(NOT QT4_FOUND)
	FIND_PACKAGE( Qt4 REQUIRED QUIET )
ENDIF(NOT QT4_FOUND)

IF( QT4_FOUND )
	# Is Qwt5 installed? Look for header files
	FIND_PATH( Qwt5_INCLUDE_DIR qwt.h 
Jan Möbius's avatar
Jan Möbius committed
33
34
35
               PATHS ${QT_INCLUDE_DIR} 
				/usr/local/qwt/include 
				/usr/local/include 
36
37
                                /opt/local/include
				/usr/include
Jan Möbius's avatar
Jan Möbius committed
38
				/usr/include 
Jan Möbius's avatar
Jan Möbius committed
39
                                c:\\libs\\VS2010\\x32\\Qwt-6.0.2
Jan Möbius's avatar
Jan Möbius committed
40
41
42
43
				c:\\libs\\Qwt-6.0.1
				c:\\Program\ Files\\qwt\\qwt-5.2.0 
				c:\\qwt-5.2.0 
				C:\\libs\\qwt-5.2.0
Jan Möbius's avatar
Jan Möbius committed
44
               PATH_SUFFIXES qwt qwt5 qwt-qt4 qwt5-qt4 qwt-qt3 qwt5-qt3 include qwt/include qwt5/include qwt-qt4/include qwt5-qt4/include qwt-qt3/include qwt5-qt3/include ENV PATH)
45

Jan Möbius's avatar
Jan Möbius committed
46
47
48
49
50
51
52
53
	# Find Qwt version
	IF( Qwt5_INCLUDE_DIR )
		FILE( READ ${Qwt5_INCLUDE_DIR}/qwt_global.h QWT_GLOBAL_H )
		STRING( REGEX MATCH "#define *QWT_VERSION *(0x05*)" QWT_IS_VERSION_5 ${QWT_GLOBAL_H})
		
		IF( QWT_IS_VERSION_5 )
		STRING(REGEX REPLACE ".*#define[\\t\\ ]+QWT_VERSION_STR[\\t\\ ]+\"([0-9]+\\.[0-9]+\\.[0-9]+)\".*" "\\1" Qwt_VERSION "${QWT_GLOBAL_H}")

54
55
56
57
58
59
60
		IF( APPLE ) #Apple
		    # Find Qwt5 library linked to Qt4
		    FIND_LIBRARY( Qwt5_Qt4_TENTATIVE_LIBRARY_RELEASE NAMES qwt5-qt4 qwt-qt4 qwt5 qwt PATHS /usr/local/qwt/lib /opt/local/lib /usr/local/lib /usr/lib )

                    FIND_LIBRARY( Qwt5_Qt4_TENTATIVE_LIBRARY_DEBUG NAMES qwt_debug PATHS /usr/local/qwt/lib /opt/local/lib /usr/local/lib /usr/lib )

                    get_filename_component(_Qwt5_Qt4_LIBRARY_DIR ${Qwt5_Qt4_TENTATIVE_LIBRARY_RELEASE} PATH)
Jan Möbius's avatar
Jan Möbius committed
61
                    set ( Qwt5_Qt4_LIBRARY_DIR ${_Qwt5_Qt4_LIBRARY_DIR} CACHE FILEPATH "Library dir of qwt" )
62
63
64
65
66

                    set ( Qwt5_Qt4_TENTATIVE_LIBRARY "optimized;${Qwt5_Qt4_TENTATIVE_LIBRARY_RELEASE};debug;${Qwt5_Qt4_TENTATIVE_LIBRARY_DEBUG}")
                ELSEIF( WIN32 )
		    # Find Qwt5 library linked to Qt4 Release Version
                    FIND_LIBRARY( Qwt5_Qt4_TENTATIVE_LIBRARY_RELEASE NAMES qwt qwt5-qt4 qwt-qt4 qwt5  PATHS 
Jan Möbius's avatar
Jan Möbius committed
67
                                                           "c:\\libs\\VS2010\\x32\\Qwt-6.0.2\\lib"
Jan Möbius's avatar
Jan Möbius committed
68
							   "c:\\libs\\Qwt-6.0.1\\lib"
Jan Möbius's avatar
Jan Möbius committed
69
				                           "c:\\Program\ Files\\qwt\\qwt-5.2.0\\lib" 
Jan Möbius's avatar
Jan Möbius committed
70
71
							   "c:\\libs\\qwt-5.2.0\\lib"
							   )
72
73
		    # Find Qwt5 library linked to Qt4 Debug Version
		    FIND_LIBRARY( Qwt5_Qt4_TENTATIVE_LIBRARY_DEBUG NAMES qwtd qwt5d  PATHS 
Jan Möbius's avatar
Jan Möbius committed
74
                                        "c:\\libs\\VS2010\\x32\\Qwt-6.0.2\\lib"
Jan Möbius's avatar
Jan Möbius committed
75
76
77
			                "c:\\libs\\Qwt-6.0.1\\lib"
			                "c:\\Program\ Files\\qwt\\qwt-5.2.0\\lib" 
							"c:\\libs\\qwt-5.2.0\\lib")
Jan Möbius's avatar
Jan Möbius committed
78

79
80
81
82
83
84
85
86
87
                    set ( Qwt5_Qt4_TENTATIVE_LIBRARY "optimized;${Qwt5_Qt4_TENTATIVE_LIBRARY_RELEASE};debug;${Qwt5_Qt4_TENTATIVE_LIBRARY_DEBUG}")
                    get_filename_component(_Qwt5_Qt4_LIBRARY_DIR ${Qwt5_Qt4_TENTATIVE_LIBRARY_RELEASE} PATH)
                    set ( Qwt5_Qt4_LIBRARY_DIR ${_Qwt5_Qt4_LIBRARY_DIR} CACHE FILEPATH "Library dir of qwt" )
                ELSE() #Linux
                    # Find Qwt5 library linked to Qt4
                    FIND_LIBRARY( Qwt5_Qt4_TENTATIVE_LIBRARY NAMES qwt5-qt4 qwt-qt4 qwt5 qwt PATHS /usr/local/qwt/lib /opt/local/lib /usr/local/lib /usr/lib )
                    get_filename_component(_Qwt5_Qt4_LIBRARY_DIR ${Qwt5_Qt4_TENTATIVE_LIBRARY} PATH)
                    set ( Qwt5_Qt4_LIBRARY_DIR ${_Qwt5_Qt4_LIBRARY_DIR} CACHE FILEPATH "Library dir of qwt" )
		ENDIF()
Jan Möbius's avatar
Jan Möbius committed
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128

		IF( UNIX AND NOT CYGWIN AND NOT APPLE)
			IF( Qwt5_Qt4_TENTATIVE_LIBRARY )
				#MESSAGE("Qwt5_Qt4_TENTATIVE_LIBRARY = ${Qwt5_Qt4_TENTATIVE_LIBRARY}")
				EXECUTE_PROCESS( COMMAND "ldd" ${Qwt5_Qt4_TENTATIVE_LIBRARY} OUTPUT_VARIABLE Qwt_Qt4_LIBRARIES_LINKED_TO )
				STRING( REGEX MATCH "QtCore" Qwt5_IS_LINKED_TO_Qt4 ${Qwt_Qt4_LIBRARIES_LINKED_TO})
				IF( Qwt5_IS_LINKED_TO_Qt4 )
					SET( Qwt5_Qt4_LIBRARY ${Qwt5_Qt4_TENTATIVE_LIBRARY} CACHE FILEPATH "Qt4 linked version of the qwt lib")
					SET( Qwt5_Qt4_FOUND TRUE )
					IF (NOT Qwt5_FIND_QUIETLY)
						MESSAGE( STATUS "Found Qwt: ${Qwt5_Qt4_LIBRARY}" )
					ENDIF (NOT Qwt5_FIND_QUIETLY)
				ENDIF( Qwt5_IS_LINKED_TO_Qt4 )
			ENDIF( Qwt5_Qt4_TENTATIVE_LIBRARY )
		ELSE( UNIX AND NOT CYGWIN AND NOT APPLE )
                        IF ( WIN32 )
                                IF( Qwt5_Qt4_TENTATIVE_LIBRARY )
 		        		# Assumes qwt.dll is in the Qt dir
					SET( Qwt5_Qt4_LIBRARY ${Qwt5_Qt4_TENTATIVE_LIBRARY} CACHE FILEPATH "Qt4 linked version of the qwt lib")
			  		SET( Qwt5_Qt4_FOUND TRUE )
			  		IF (NOT Qwt5_FIND_QUIETLY)
						MESSAGE( STATUS "Found Qwt version ${Qwt_VERSION} linked to Qt4" )
			  	 	ENDIF (NOT Qwt5_FIND_QUIETLY)
                                ENDIF( Qwt5_Qt4_TENTATIVE_LIBRARY )
                        ENDIF( WIN32 )

                        IF ( APPLE )
                                IF( Qwt5_Qt4_TENTATIVE_LIBRARY )
					SET( Qwt5_Qt4_LIBRARY ${Qwt5_Qt4_TENTATIVE_LIBRARY} CACHE FILEPATH "Qt4 linked version of the qwt lib")
			  		SET( Qwt5_Qt4_FOUND TRUE )
			  		IF (NOT Qwt5_FIND_QUIETLY)
						MESSAGE( STATUS "Found Qwt version ${Qwt_VERSION} linked to Qt4" )
			  		ENDIF (NOT Qwt5_FIND_QUIETLY)
                                ENDIF( Qwt5_Qt4_TENTATIVE_LIBRARY )
                        ENDIF( APPLE )

		ENDIF( UNIX AND NOT CYGWIN AND NOT APPLE)

		
                IF ( NOT APPLE )
			# Find Qwt5 library linked to Qt3
Jan Möbius's avatar
Jan Möbius committed
129
			FIND_LIBRARY( Qwt5_Qt3_TENTATIVE_LIBRARY NAMES qwt-qt3 qwt qwt5-qt3 qwt5 qwt )
Jan Möbius's avatar
Jan Möbius committed
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
			IF( UNIX AND NOT CYGWIN)
				IF( Qwt5_Qt3_TENTATIVE_LIBRARY )
					#MESSAGE("Qwt5_Qt3_TENTATIVE_LIBRARY = ${Qwt5_Qt3_TENTATIVE_LIBRARY}")
					EXECUTE_PROCESS( COMMAND "ldd" ${Qwt5_Qt3_TENTATIVE_LIBRARY} OUTPUT_VARIABLE Qwt-Qt3_LIBRARIES_LINKED_TO )
					STRING( REGEX MATCH "qt-mt" Qwt5_IS_LINKED_TO_Qt3 ${Qwt-Qt3_LIBRARIES_LINKED_TO})
					IF( Qwt5_IS_LINKED_TO_Qt3 )
						SET( Qwt5_Qt3_LIBRARY ${Qwt5_Qt3_TENTATIVE_LIBRARY} CACHE FILEPATH "Qt3 linked version of the qwt lib")
						SET( Qwt5_Qt3_FOUND TRUE )
						IF (NOT Qwt5_FIND_QUIETLY)
							MESSAGE( STATUS "Found Qwt version ${Qwt_VERSION} linked to Qt3" )
						ENDIF (NOT Qwt5_FIND_QUIETLY)
					ENDIF( Qwt5_IS_LINKED_TO_Qt3 )
				ENDIF( Qwt5_Qt3_TENTATIVE_LIBRARY )
			ELSE( UNIX AND NOT CYGWIN)
				SET( Qwt5_Qt3_LIBRARY ${Qwt5_Qt3_TENTATIVE_LIBRARY} CACHE FILEPATH "Qt3 linked version of the qwt lib")
				SET( Qwt5_Qt3_FOUND TRUE )
				IF (NOT Qwt5_FIND_QUIETLY)
					MESSAGE( STATUS "Found Qwt: ${Qwt5_Qt3_LIBRARY}" )
				ENDIF (NOT Qwt5_FIND_QUIETLY)
			ENDIF( UNIX AND NOT CYGWIN )
		ENDIF( NOT APPLE )
		
		ENDIF( QWT_IS_VERSION_5 )
		
		IF( Qwt5_Qt4_FOUND OR Qwt5_Qt3_FOUND )
			SET( Qwt5_FOUND TRUE )
		ENDIF( Qwt5_Qt4_FOUND OR Qwt5_Qt3_FOUND )
		
		MARK_AS_ADVANCED( Qwt5_INCLUDE_DIR Qwt5_Qt4_LIBRARY Qwt5_Qt3_LIBRARY )
	ENDIF( Qwt5_INCLUDE_DIR )

   	IF (NOT Qwt5_FOUND AND Qwt5_FIND_REQUIRED)
      		MESSAGE(FATAL_ERROR "Could not find Qwt 5.x")
   	ENDIF (NOT Qwt5_FOUND AND Qwt5_FIND_REQUIRED)

ENDIF( QT4_FOUND )