# Shared QMake file to ease creation of new projects # Author: Jeroen Dierckx # The root directory of the source code # Note: for now, we use the path where this .pri file is stored. # TODO $$PWD seems to be incorrect when qmake is not run on the main file (so I guess it uses the .pro file location, not the .pri file location) SRCROOT = $$PWD #message (Source root path: $$SRCROOT) # The relative path of this target (against the source root) RELSRCPATH = $$replace(_PRO_FILE_PWD_, ^$$SRCROOT/?, "") #message($$TARGET relative path: $$RELSRCPATH) # The build root directory BUILDROOT = $$replace(OUT_PWD, /?$$RELSRCPATH$, "") #message(Build root path: $$BUILDROOT) # The plugin directory #RELPLUGINPATH = plugins RELPLUGINPATH = . PLUGINPATH = $$BUILDROOT/$$RELPLUGINPATH # The target output directory contains(TEMPLATE, app) { message($$TARGET is an application) # For applications, the output path is the build root DESTDIR = $$BUILDROOT } else:static|staticlib { message($$TARGET is a static library) # Note: we leave the output path as is for now } # Note: a plugin has the plugin CONFIG option set else:plugin { message($$TARGET is a plugin) # Note: we only set the DLL output dir (windows only) DLLDESTDIR = $$PLUGINPATH } else { message($$TARGET is a shared library) # Note: we only set the DLL output dir (windows only) DLLDESTDIR = $$BUILDROOT } # Include paths INCLUDEPATH += $$SRCROOT/$$RELSRCPATH $$SRCROOT $$SRCROOT/deps/include $$SRCROOT/JeDi $$SRCROOT/Plugins # Windows-specific win32:LIBS += -L$$SRCROOT/deps/win32/lib # Link with the libraries in the STATICLIBS list for(LIBRARY, STATICLIBS) { message("$$TARGET: Linking with static library " $$LIBRARY) LIBRARYBASE = $$basename(LIBRARY) win32:CONFIG(release, debug|release): LIBS += -L$$BUILDROOT/$$LIBRARY/release/ -l$$LIBRARYBASE else:win32:CONFIG(debug, debug|release): LIBS += -L$$BUILDROOT/$$LIBRARY/debug/ -l$$LIBRARYBASE else:macx: LIBS += -L$$BUILDROOT/$$LIBRARY/ -l$$LIBRARYBASE win32:CONFIG(release, debug|release): PRE_TARGETDEPS += $$BUILDROOT/$$LIBRARY/release/$${LIBRARYBASE}.lib else:win32:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$BUILDROOT/$$LIBRARY/debug/$${LIBRARYBASE}.lib else:macx: PRE_TARGETDEPS += $$BUILDROOT/$$LIBRARY/lib$${LIBRARYBASE}.a DEPENDPATH += $$SRCROOT/$$LIBRARY } # Link with the libraries in the DYNAMICLIBS list # Note: on Mac, the libraries are also copied to the application bundle for(LIBRARY, DYNAMICLIBS) { message("$$TARGET: Linking with dynamic library " $$LIBRARY) LIBRARYBASE = $$basename(LIBRARY) win32:CONFIG(release, debug|release): LIBS += -L$$BUILDROOT/$$LIBRARY/release/ -l$$LIBRARYBASE else:win32:CONFIG(debug, debug|release): LIBS += -L$$BUILDROOT/$$LIBRARY/debug/ -l$$LIBRARYBASE else:macx: LIBS += -L$$BUILDROOT/$$LIBRARY/ -l$$LIBRARYBASE win32:CONFIG(release, debug|release): PRE_TARGETDEPS += $$BUILDROOT/$$LIBRARY/release/$${LIBRARYBASE}.lib else:win32:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$BUILDROOT/$$LIBRARY/debug/$${LIBRARYBASE}.lib #else:macx: PRE_TARGETDEPS += $$BUILDROOT/$$LIBRARY/lib$${LIBRARYBASE}.a DEPENDPATH += $$SRCROOT/$$LIBRARY # Copy dylib to application bundle (mac only) #eval($${LIBRARYBASE}_BUNDLE.files = $$files("$$BUILDROOT/$$LIBRARY/lib$${LIBRARYBASE}*.dylib")) # TODO: The application only seems to load the .1.dylib file. Is this always true? # Note: the file has tobe explicitly quoted, so it is one item in the list (even if the path contains a space) # Note 2: For plugins (targets that end with Plugin), we use the dylib without versioning information ISPLUGIN = $$find(LIBRARYBASE, Plugin$) !isEmpty(ISPLUGIN): eval(LIBRARY_$${LIBRARYBASE}_BUNDLE.files = \"$$BUILDROOT/$$LIBRARY/lib$${LIBRARYBASE}.dylib\") else: eval(LIBRARY_$${LIBRARYBASE}_BUNDLE.files += \"$$BUILDROOT/$$LIBRARY/lib$${LIBRARYBASE}.1.dylib\") eval(LIBRARY_$${LIBRARYBASE}_BUNDLE.path = Contents/MacOS) #eval(LIBRARY_$${LIBRARYBASE}_BUNDLE.path = Contents/Frameworks) QMAKE_BUNDLE_DATA += "LIBRARY_$${LIBRARYBASE}_BUNDLE" } # On Mac, copy plugins to the application bundle for(PLUGIN, PLUGINS) { message("$$TARGET: Adding plugin " $$PLUGIN) PLUGINBASE = $$basename(PLUGIN) # Copy dylib to application bundle (mac only) eval(PLUGIN_$${PLUGINBASE}_BUNDLE.files = \"$$BUILDROOT/$$PLUGIN/lib$${PLUGINBASE}.dylib\") eval(PLUGIN_$${PLUGINBASE}_BUNDLE.path = Contents/MacOS/$$RELPLUGINPATH) #eval(PLUGIN_$${PLUGINBASE}_BUNDLE.path = Contents/PlugIns) QMAKE_BUNDLE_DATA += "PLUGIN_$${PLUGINBASE}_BUNDLE" }