Salome HOME
Revert "Synchronize adm files"
[modules/yacs.git] / adm / cmake / FindQScintilla.cmake
1 # QScintilla is a port to Qt of Neil Hodgson's Scintilla C++ editor control
2 # available at http://www.riverbankcomputing.com/software/qscintilla/
3 #
4 # The module defines the following variables:
5 #  QSCINTILLA_FOUND - the system has QScintilla
6 #  QSCINTILLA_INCLUDE_DIR - where to find Qsci/qsciscintilla.h
7 #  QSCINTILLA_INCLUDE_DIRS - qwt includes
8 #  QSCINTILLA_LIBRARY - where to find the QScintilla library
9 #  QSCINTILLA_LIBRARIES - aditional libraries
10 #  QSCINTILLA_MAJOR_VERSION - major version
11 #  QSCINTILLA_MINOR_VERSION - minor version
12 #  QSCINTILLA_PATCH_VERSION - patch version
13 #  QSCINTILLA_VERSION_STRING - version (ex. 2.6.2)
14 #  QSCINTILLA_ROOT_DIR - root dir (ex. /usr/local)
15
16 #=============================================================================
17 # Copyright 2010-2013, Julien Schueller
18 # All rights reserved.
19
20 # Redistribution and use in source and binary forms, with or without
21 # modification, are permitted provided that the following conditions are met: 
22
23 # 1. Redistributions of source code must retain the above copyright notice, this
24 #    list of conditions and the following disclaimer. 
25 # 2. Redistributions in binary form must reproduce the above copyright notice,
26 #    this list of conditions and the following disclaimer in the documentation
27 #    and/or other materials provided with the distribution. 
28 #
29 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
30 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
31 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
32 # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
33 # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
34 # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
35 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
36 # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
38 # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39
40 # The views and conclusions contained in the software and documentation are those
41 # of the authors and should not be interpreted as representing official policies, 
42 # either expressed or implied, of the FreeBSD Project.
43 #=============================================================================
44
45
46 find_path ( QSCINTILLA_INCLUDE_DIR
47   NAMES Qsci/qsciscintilla.h
48   HINTS ${QT_INCLUDE_DIR}
49 )
50
51 set ( QSCINTILLA_INCLUDE_DIRS ${QSCINTILLA_INCLUDE_DIR} ${QSCINTILLA_INCLUDE_DIR}/Qsci )
52
53 # version
54 set ( _VERSION_FILE ${QSCINTILLA_INCLUDE_DIR}/Qsci/qsciglobal.h )
55 if ( EXISTS ${_VERSION_FILE} )
56   file ( STRINGS ${_VERSION_FILE} _VERSION_LINE REGEX "define[ ]+QSCINTILLA_VERSION_STR" )
57   if ( _VERSION_LINE )
58     string ( REGEX REPLACE ".*define[ ]+QSCINTILLA_VERSION_STR[ ]+\"(.*)\".*" "\\1" QSCINTILLA_VERSION_STRING "${_VERSION_LINE}" )
59     string ( REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9]+)" "\\1" QSCINTILLA_MAJOR_VERSION "${QSCINTILLA_VERSION_STRING}" )
60     string ( REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9]+)" "\\2" QSCINTILLA_MINOR_VERSION "${QSCINTILLA_VERSION_STRING}" )
61     string ( REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9]+)" "\\3" QSCINTILLA_PATCH_VERSION "${QSCINTILLA_VERSION_STRING}" )
62   endif ()
63 endif ()
64
65
66 # check version
67 set ( _QSCINTILLA_VERSION_MATCH TRUE )
68 if ( QScintilla_FIND_VERSION AND QSCINTILLA_VERSION_STRING )
69   if ( QScintilla_FIND_VERSION_EXACT )
70     if ( NOT QScintilla_FIND_VERSION VERSION_EQUAL QSCINTILLA_VERSION_STRING )
71       set ( _QSCINTILLA_VERSION_MATCH FALSE )
72     endif ()
73   else ()
74     if ( QSCINTILLA_VERSION_STRING VERSION_LESS QScintilla_FIND_VERSION )
75       set ( _QSCINTILLA_VERSION_MATCH FALSE )
76     endif ()
77   endif ()
78 endif ()
79
80
81 find_library ( QSCINTILLA_LIBRARY
82   NAMES qscintilla qscintilla2 libqscintilla2
83   HINTS ${QT_LIBRARY_DIR}
84 )
85
86 set ( QSCINTILLA_LIBRARIES ${QSCINTILLA_LIBRARY} )
87
88
89 # try to guess root dir from include dir
90 if ( QSCINTILLA_INCLUDE_DIR )
91   string ( REGEX REPLACE "(.*)/include.*" "\\1" QSCINTILLA_ROOT_DIR ${QSCINTILLA_INCLUDE_DIR} )
92 # try to guess root dir from library dir
93 elseif ( QSCINTILLA_LIBRARY )
94   string ( REGEX REPLACE "(.*)/lib[/|32|64].*" "\\1" QSCINTILLA_ROOT_DIR ${QSCINTILLA_LIBRARY} )
95 endif ()
96
97
98 # handle the QUIETLY and REQUIRED arguments
99 include ( FindPackageHandleStandardArgs )
100 if ( CMAKE_VERSION LESS 2.8.3 )
101   find_package_handle_standard_args( QScintilla DEFAULT_MSG QSCINTILLA_LIBRARY QSCINTILLA_INCLUDE_DIR _QSCINTILLA_VERSION_MATCH )
102 else ()
103   find_package_handle_standard_args( QScintilla REQUIRED_VARS QSCINTILLA_LIBRARY QSCINTILLA_INCLUDE_DIR _QSCINTILLA_VERSION_MATCH VERSION_VAR QSCINTILLA_VERSION_STRING )
104 endif ()
105
106 mark_as_advanced (
107   QSCINTILLA_LIBRARY
108   QSCINTILLA_LIBRARIES
109   QSCINTILLA_INCLUDE_DIR
110   QSCINTILLA_INCLUDE_DIRS
111   QSCINTILLA_MAJOR_VERSION
112   QSCINTILLA_MINOR_VERSION
113   QSCINTILLA_PATCH_VERSION
114   QSCINTILLA_VERSION_STRING
115   QSCINTILLA_ROOT_DIR
116 )