2
0
mirror of https://github.com/boostorg/build.git synced 2026-02-16 13:22:11 +00:00
Files
build/v2/tools/qt4.jam
2007-01-31 19:45:54 +00:00

592 lines
20 KiB
Plaintext

# Copyright 2002-2006 Vladimir Prus
# Copyright 2005 Alo Sarv
# Copyright 2005-2006 Juergen Hunold
#
# Distributed under the Boost Software License, Version 1.0. (See
# accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
# Qt4 library support module
#
# The module attempts to auto-detect QT installation location from QTDIR
# environment variable; failing that, installation location can be passed as
# argument:
#
# toolset.using qt4 : /usr/local/Trolltech/Qt-4.0.0 ;
#
# The module supports code generation from .ui and .qrc files, as well as
# running the moc preprocessor on headers. Note that you must list all your
# moc-able headers in sources.
#
# Example:
#
# exe myapp : myapp.cpp myapp.h myapp.ui myapp.qrc
# /qt4//QtGui /qt4//QtNetwork ;
#
# It's also possible to run moc on cpp sources:
#
# import cast ;
#
# exe myapp : myapp.cpp [ cast _ moccable-cpp : myapp.cpp ] /qt4//QtGui ;
#
# When moccing source file myapp.cpp you need to include "myapp.moc" from
# myapp.cpp. When moccing .h files, the output of moc will be automatically
# compiled and linked in, you don't need any includes.
#
# This is consistent with Qt guidelines:
# http://doc.trolltech.com/4.0/moc.html
import modules ;
import feature ;
import errors ;
import type ;
import "class" : new ;
import generators ;
import project ;
import toolset : flags ;
import os ;
import virtual-target ;
# Qt3Support control feature
#
# Qt4 configure defaults to build Qt4 libraries with Qt3Support.
# The autodetection is missing, so we default to disable Qt3Support.
# This prevents the user from inadvertedly using a deprecated API.
#
# The Qt3Support library can be activated by adding
# "<qt3support>on" to requirements
#
# Use "<qt3support>on:<define>QT3_SUPPORT_WARNINGS"
# to get warnings about deprecated Qt3 support funtions and classes.
# Files ported by the "qt3to4" conversion tool contain _tons_ of
# warnings, so this define is not set as default.
#
# Todo: Detect Qt3Support from Qt's configure data.
# Or add more auto-configuration (like python).
feature.feature qt3support : off on : propagated link-incompatible ;
project.initialize $(__name__) ;
project qt ;
# Save the project so that we tolerate 'import + using' combo.
.project = [ project.current ] ;
# Initialized the QT support module. The 'prefix' parameter
# tells where QT is installed.
rule init ( prefix )
{
project.push-current $(.project) ;
if $(.initialized)
{
if $(prefix) != $(.prefix)
{
errors.error
"Attempt the reinitialize QT with different installation prefix" ;
}
}
else
{
.initialized = true ;
.prefix = $(prefix) ;
#~ Setup prefixes for include, binaries and libs.
#~ TODO: Implement overrides in "init" parameter list.
.incprefix = $(.prefix)/include ;
.libprefix = $(.prefix)/lib ;
.binprefix = $(.prefix)/bin ;
# Generates cpp files from header files using "moc" tool
generators.register-standard qt4.moc : H : CPP(moc_%) : <allow>qt4 ;
# The OBJ result type is a fake, 'H' will be really produces.
# See comments on the generator calss, defined below
# the 'init' function.
generators.register [ new uic-h-generator qt4.uic-h : UI : OBJ
: <allow>qt4 ] ;
# The OBJ result type is a fake here too.
generators.register [ new moc-h-generator
qt4.moc.inc : MOCCABLE_CPP : OBJ : <allow>qt4 ] ;
generators.register [ new moc-inc-generator
qt4.moc.inc : MOCCABLE_H : OBJ : <allow>qt4 ] ;
# Generates .cpp file from qrc file
generators.register-standard qt4.rcc : QRC : CPP(qrc_%) ;
# Test for a buildable Qt.
if [ glob $(.prefix)/Jamroot ]
{
# Import all Qt Modules
local all-libraries = QtCore QtGui QtNetwork QtXml QtSql QtSvg QtOpenGL Qt3Support QtTest QtAssistantClient QtDesigner QtUiTools QtDBus ;
for local l in $(all-libraries)
{
alias $(l)
: $(.prefix)//$(l)
:
:
: <allow>qt4
;
explicit $(l) ;
}
}
else
# Use pre-built Qt
{
local usage-requirements =
<include>$(.incprefix)
<library-path>$(.libprefix)
<dll-path>$(.libprefix)
<threading>multi
<allow>qt4
;
local suffix ;
if [ os.name ] = NT
{
# On NT, the libs have "4" suffix, and "d" suffix in debug builds
# Also, on NT we must link against qtmain library (for WinMain)
suffix_version = "4" ;
suffix_debug = "d" ;
lib qtmain
: # sources
: # requirements
<name>qtmain$(suffix_debug)
<variant>debug
;
lib qtmain
: # sources
: # requirements
<name>qtmain
;
main = qtmain ;
}
else if [ os.name ] = MACOSX
{
# On MacOS X, both debug and release libraries are available.
suffix_version = "" ;
suffix_debug = "_debug" ;
}
else
{
# Since Qt-4.2, debug versions on unix have to be built separately
# and therefore have no suffix.
suffix_version = "" ;
suffix_debug = "" ;
}
lib QtCore : $(main)
: # requirements
<name>QtCore$(suffix_version)
: # default-build
: # usage-requirements
<define>QT_CORE_LIB
<define>QT_NO_DEBUG
<include>$(.incprefix)/QtCore
$(usage-requirements)
;
lib QtCore : $(main)
: # requirements
<name>QtCore$(suffix_debug)$(suffix_version)
<variant>debug
: # default-build
: # usage-requirements
<define>QT_CORE_LIB
<include>$(.incprefix)/QtCore
$(usage-requirements)
;
lib QtGui : QtCore
: # requirements
<name>QtGui$(suffix_version)
: # default-build
: # usage-requirements
<define>QT_GUI_LIB
<include>$(.incprefix)/QtGui
<user-interface>gui
;
lib QtGui : QtCore
: # requirements
<name>QtGui$(suffix_debug)$(suffix_version)
<variant>debug
: # default-build
: # usage-requirements
<define>QT_GUI_LIB
<include>$(.incprefix)/QtGui
<user-interface>gui
;
lib QtNetwork : QtCore
: # requirements
<name>QtNetwork$(suffix_version)
: # default-build
: # usage-requirements
<define>QT_NETWORK_LIB
<include>$(.incprefix)/QtNetwork
;
lib QtNetwork : QtCore
: # requirements
<name>QtNetwork$(suffix_debug)$(suffix_version)
<variant>debug
: # default-build
: # usage-requirements
<define>QT_NETWORK_LIB
<include>$(.incprefix)/QtNetwork
;
lib QtSql : QtCore
: # requirements
<name>QtSql$(suffix_version)
: # default-build
: # usage-requirements
<define>QT_SQL_LIB
<include>$(.incprefix)/QtSql
;
lib QtSql : QtCore
: # requirements
<name>QtSql$(suffix_debug)$(suffix_version)
<variant>debug
: # default-build
: # usage-requirements
<define>QT_SQL_LIB
<include>$(.incprefix)/QtSql
;
lib QtXml : QtCore
: # requirements
<name>QtXml$(suffix_version)
: # default-build
: # usage-requirements
<define>QT_XML_LIB
<include>$(.incprefix)/QtXml
;
lib QtXml : QtCore
: # requirements
<name>QtXml$(suffix_debug)$(suffix_version)
<variant>debug
: # default-build
: # usage-requirements
<define>QT_XML_LIB
<include>$(.incprefix)/QtXml
;
lib Qt3Support : QtGui QtNetwork QtXml QtSql
: # requirements
<name>Qt3Support$(suffix_version)
<qt3support>on
: # default-build
: # usage-requirements
<define>QT_QT3SUPPORT_LIB
<define>QT3_SUPPORT
<include>$(.incprefix)/Qt3Support
;
lib Qt3Support : QtGui QtNetwork QtXml QtSql
: # requirements
<name>Qt3Support$(suffix_debug)$(suffix_version)
<qt3support>on
<variant>debug
: # default-build
: # usage-requirements
<define>QT_QT3SUPPORT_LIB
<define>QT3_SUPPORT
<include>$(.incprefix)/Qt3Support
;
# Dummy target to enable "<qt3support>off" and "<library>/qt//Qt3Support" at the same time.
# This enables quick switching from one to the other for test/porting purposes.
alias Qt3Support : : <qt3support>off ;
# OpenGl Support
lib QtOpenGL : QtGui
: # requirements
<name>QtOpenGL$(suffix_version)
: # default-build
: # usage-requirements
<define>QT_OPENGL_LIB
<include>$(.incprefix)/QtOpenGL
;
lib QtOpenGL : QtGui
: # requirements
<name>QtOpenGL$(suffix_debug)$(suffix_version)
<variant>debug
: # default-build
: # usage-requirements
<define>QT_OPENGL_LIB
<include>$(.incprefix)/QtOpenGL
;
# SVG-Support (Qt 4.1)
lib QtSvg : QtXml QtOpenGL
: # requirements
<name>QtSvg$(suffix_version)
: # default-build
: # usage-requirements
<define>QT_SVG_LIB
<include>$(.incprefix)/QtSvg
;
lib QtSvg : QtXml QtOpenGL
: # requirements
<name>QtSvg$(suffix_debug)$(suffix_version)
<variant>debug
: # default-build
: # usage-requirements
<define>QT_SVG_LIB
<include>$(.incprefix)/QtSvg
;
# Test-Support (Qt 4.1)
lib QtTest : QtCore
: # requirements
<name>QtTest$(suffix_version)
: # default-build
: # usage-requirements
<include>$(.incprefix)/QtTest
;
lib QtTest : QtCore
: # requirements
<name>QtTest$(suffix_debug)$(suffix_version)
<variant>debug
: # default-build
: # usage-requirements
<include>$(.incprefix)/QtTest
;
# AssistantClient Support
lib QtAssistantClient : QtGui
: # requirements
<name>QtAssistantClient$(suffix_version)
: # default-build
: # usage-requirements
<include>$(.incprefix)/QtAssistant
;
lib QtAssistantClient : QtGui
: # requirements
<name>QtAssistantClient$(suffix_debug)$(suffix_version)
<variant>debug
: # default-build
: # usage-requirements
<include>$(.incprefix)/QtAssistant
;
# Qt designer library
lib QtDesigner : QtGui QtXml
: # requirements
<name>QtDesigner$(suffix_version)
: # default-build
: # usage-requirements
<include>$(.incprefix)/QtDesigner
;
lib QtDesigner : QtGui QtXml
: # requirements
<name>QtDesigner$(suffix_debug)$(suffix_version)
<variant>debug
: # default-build
: # usage-requirements
<include>$(.incprefix)/QtDesigner
;
# Support for dynamic Widgets (Qt 4.1)
lib QtUiTools : QtGui QtXml
: # requirements
<name>QtUiTools
: # default-build
: # usage-requirements
<include>$(.incprefix)/QtUiTools
;
lib QtUiTools : QtGui QtXml
: # requirements
<name>QtUiTools$(suffix_debug)
<variant>debug
: # default-build
: # usage-requirements
<include>$(.incprefix)/QtUiTools
;
# DBus-Support (Qt 4.2)
lib QtDBus : QtXml
: # requirements
<name>QtDBus$(suffix_version)
: # default-build
: # usage-requirements
<include>$(.incprefix)/QtDBus
;
lib QtDBus : QtXml
: # requirements
<name>QtDBus$(suffix_debug)$(suffix_version)
<variant>debug
: # default-build
: # usage-requirements
<include>$(.incprefix)/QtDBus
;
}
}
project.pop-current ;
}
rule initialized ( )
{
return $(.initialized) ;
}
# This custom generator is needed because it QT4, UI files are translated
# only in H files, and no C++ files are created. Further, the H files
# need not be passed via MOC. The header is used only via inclusion.
# If we define standard UI -> H generator, Boost.Build will run
# MOC on H, and the compile resulting cpp. It will give a warning, since
# output from moc will be empty.
#
# This generator is declared with UI -> OBJ signature, so it's
# invoked when linking generator tries to convert sources to OBJ,
# but it produces target of type H. This is non-standard, but allowed.
# That header won't be mocced.
#
class uic-h-generator : generator
{
rule __init__ ( * : * )
{
generator.__init__ $(1) : $(2) : $(3) : $(4) : $(5) : $(6) : $(7) : $(8) : $(9) ;
}
rule run ( project name ? : property-set : sources * )
{
if ! $(name)
{
name = [ $(sources[0]).name ] ;
name = $(name:B) ;
}
local a = [ new action $(sources[1]) : qt4.uic-h :
$(property-set) ] ;
# The 'ui_' prefix is to match qmake's default behavior.
local target = [
new file-target ui_$(name) : H : $(project) : $(a) ] ;
local r = [ virtual-target.register $(target) ] ;
# Since this generator will return H target, the linking generator
# won't use it at all, and won't set any dependency on it.
# However, we need to target to be seen by bjam, so that dependency
# from sources to this generated header is detected -- if jam does
# not know about this target, it won't do anything.
DEPENDS all : [ $(r).actualize ] ;
return $(r) ;
}
}
class moc-h-generator : generator
{
rule __init__ ( * : * )
{
generator.__init__ $(1) : $(2) : $(3) : $(4) : $(5) : $(6) : $(7) : $(8) : $(9) ;
}
rule run ( project name ? : property-set : sources * )
{
if ! $(sources[2]) && [ $(sources[1]).type ] = MOCCABLE_CPP
{
name = [ $(sources[0]).name ] ;
name = $(name:B) ;
local a = [ new action $(sources[1]) : qt4.moc.inc :
$(property-set) ] ;
local target = [
new file-target $(name) : MOC : $(project) : $(a) ] ;
local r = [ virtual-target.register $(target) ] ;
# Since this generator will return H target, the linking generator
# won't use it at all, and won't set any dependency on it.
# However, we need to target to be seen by bjam, so that dependency
# from sources to this generated header is detected -- if jam does
# not know about this target, it won't do anything.
DEPENDS all : [ $(r).actualize ] ;
return $(r) ;
}
}
}
class moc-inc-generator : generator
{
rule __init__ ( * : * )
{
generator.__init__ $(1) : $(2) : $(3) : $(4) : $(5) : $(6) : $(7) : $(8) : $(9) ;
}
rule run ( project name ? : property-set : sources * )
{
if ! $(sources[2]) && [ $(sources[1]).type ] = MOCCABLE_H
{
name = [ $(sources[0]).name ] ;
name = $(name:B) ;
local a = [ new action $(sources[1]) : qt4.moc.inc :
$(property-set) ] ;
local target = [
new file-target moc_$(name) : CPP : $(project) : $(a) ] ;
# Since this generator will return H target, the linking generator
# won't use it at all, and won't set any dependency on it.
# However, we need to target to be seen by bjam, so that dependency
# from sources to this generated header is detected -- if jam does
# not know about this target, it won't do anything.
DEPENDS all : [ $(target).actualize ] ;
return [ virtual-target.register $(target) ] ;
}
}
}
# Query the installation directory
# This is needed in at least two scenarios
# First, when re-using sources from the Qt-Tree.
# Second, to "install" custom Qt plugins to the Qt-Tree.
rule directory
{
return $(.prefix) ;
}
# Get <include> and <defines> from current toolset
flags qt4.moc INCLUDES <include> ;
flags qt4.moc DEFINES <define> ;
# Processes headers to create Qt MetaObject information
# Qt4-moc has its c++-parser, so pass INCLUDES and DEFINES.
actions moc
{
$(.binprefix)/moc -I$(INCLUDES) -D$(DEFINES) -f $(>) -o $(<)
}
# When moccing files for include only, we don't need -f,
# otherwise the generated code will include the .cpp
# and we'll get duplicated symbols.
actions moc.inc
{
$(.binprefix)/moc -I$(INCLUDES) -D$(DEFINES) $(>) -o $(<)
}
# Generates source files from resource files
actions rcc
{
$(.binprefix)/rcc $(>) -name $(>:B) -o $(<)
}
# Generates user-interface source from .ui files
actions uic-h
{
$(.binprefix)/uic $(>) -o $(<)
}