File size: 3,566 Bytes
a5ffdcd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
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
129
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

# Necessary Boost libraries, e. g. BOOST_LIBS = iostreams math_c99 regex
# XXX: this will not play nice with the win case as-is

exists( custom.pro ):include( custom.pro )
exists( custom.pri ):include( custom.pri )

BOOST_LIBS =

unix {
    defineTest( checkBoostIncDir ) {

        boostIncDir = $${1}

        exists( $${boostIncDir}/boost/version.hpp ) {
            return( true )
        }

        return(false)
    }

    defineTest( checkBoostLibDir ) {

        boostLibDir = $${1}

        # If no Boost libs are used, always succeed
        isEmpty( BOOST_LIBS ) {
            return( true )
        }

        exists( $${boostLibDir}/libboost_* ) {
            return( true )
        }

        return( false )
    }

    defineTest( checkBoostLib ) {

        boostLib = $${1}

        exists( $${BOOST_LIBDIR}/libboost_$${boostLib}.* ) {
            return( true )
        }

        return( false )
    }

    defineTest( checkBoostLibs ) {

        boostLibs = $${ARGS}

        # If no Boost libs are used, always succeed
        isEmpty( BOOST_LIBS ) {
            return( true )
        }

        for( boostLib, boostLibs ) {
            checkBoostLib( $${boostLib} ) {
                return( true )
            } else {
                error( Required Boost library $${boostLib} not found )
            }
        }

        return( false )
    }

    defineReplace( findBoostDirIn ) {

        boostDirs = $${ARGS}

        for( boostDir, boostDirs ) {
            checkBoostIncDir( $${boostDir}/include ) : checkBoostLibDir( $${boostDir}/lib ) {
                return( $${boostDir} )
            }
        }

        return( )
    }

    isEmpty( BOOST_DIR ) {

        BOOST_DIR = $$findBoostDirIn($${INSTALL_PREFIX} /usr /usr/local /usr/pkg /opt/local /opt/homebrew /opt/homebrew/Cellar )

        isEmpty( BOOST_DIR ) {
            error( Boost installation not found. )
        } else {
            message( Found Boost in $${BOOST_DIR} )
        }

    }

    checkBoostIncDir( $${BOOST_DIR}/include ) {
        BOOST_INCDIR = $${BOOST_DIR}/include
        message( Using Boost includes from $${BOOST_INCDIR} )
    } else {
        error( $${BOOST_DIR} does not contain a Boost installation )
    }

    !isEmpty( BOOST_LIBS ) {

        checkBoostLibDir( $${BOOST_DIR}/lib ) {
            BOOST_LIBDIR = $${BOOST_DIR}/lib
        } else {
            error( Boost libraries not installed in $${BOOST_DIR}/lib )
        }

        !checkBoostLibs( $${BOOST_LIBS} ) {
            # NOTREACHED
            error( Required Boost libraries not found )
        }
    }


    #BOOST_INCDIR -= $$QMAKE_DEFAULT_INCDIRS
    INCLUDEPATH += $${BOOST_INCDIR}
    HEADERS += $${BOOST_INCDIR}

    !isEmpty( BOOST_LIBS ) {

        LIBS += -L$${BOOST_LIBDIR}

        message( Using Boost libraries from $${BOOST_LIBDIR} )
        message( Using Boost libraries: )

        for( boostLib, BOOST_LIBS ) {
            message( -> $${boostLib} )
            LIBS += -lboost_$${boostLib}
        }
    }

}

win32 {
	!equals($$(BOOST_DIR), ""):exists( "$$(BOOST_DIR)" ) {
		# BOOST_DIR environment variable is set, use it:
		BOOST_DIR = "$$(BOOST_DIR)"
	} else:isEmpty( BOOST_DIR ) {
		# BOOST_DIR QMake variable is not set at all (in custom.pro), use a hardcoded default:
		BOOST_DIR = "/boost/boost_1_53_0"
    }

    !exists( "$${BOOST_DIR}/boost/version.hpp" ) {
        error( "Can not find Boost installation in $${BOOST_DIR}" )
    }

    BOOST_INCDIR = "$${BOOST_DIR}"

    INCLUDEPATH += "$${BOOST_INCDIR}"
    HEADERS += "$${BOOST_INCDIR}"

}