I try to deploy my custom widget with this doc but when I compile only .h and dll are copied, .lib and .pdb are not:
This is my .pro when i configurer the copy directive
message(Building...)
QT += widgets designer
PLUGIN_CLASS_NAME = QKWidgets
QTDIR_build {
message(Qt Build)
# This is only for the Qt build. Do not use externally. We mean it.
PLUGIN_TYPE = designer
load(qt_plugin)
CONFIG += install_ok
} else {
message(Public Build)
# Public example:
TARGET = $$qtLibraryTarget($$TARGET)
CONFIG += plugin debug_and_release
TEMPLATE = lib
target.path = $$[QT_INSTALL_PLUGINS]/designer
#INSTALLS += target
headersDataFiles.path = $$[QT_INSTALL_HEADERS]/$$PLUGIN_CLASS_NAME/
headersDataFiles.files = $$PWD/*.h
#INSTALLS += headersDataFiles
libraryFiles.path = $$[QT_INSTALL_LIBS]
CONFIG(debug, debug|release): libraryFiles.files = $$OUT_PWD/debug/*.lib $$OUT_PWD/release/*.pdb
CONFIG(release, debug|release): libraryFiles.files = $$OUT_PWD/release/*.lib
INSTALLS += target headersDataFiles libraryFiles
message(Lib dest: $$[QT_INSTALL_LIBS])
message(Lib src: $$libraryFiles.files)
}
message(General Build)
Edit:
install_libraryFiles doesn't appear in Makefile
Edit2:
Output :
Project MESSAGE: Building...
Project MESSAGE: Public Build
Project MESSAGE: Lib dest: C:/Qt/Qt5.9.0/5.9.1/msvc2017_64/lib
Project MESSAGE: Lib src: C:/Users/SD/Documents/Studio/MyProject/Widgets/Build/Release/release/*.lib
Project MESSAGE: General Build
Project MESSAGE: Building...
Project MESSAGE: Public Build
Project MESSAGE: Lib dest: C:/Qt/Qt5.9.0/5.9.1/msvc2017_64/lib
Project MESSAGE: Lib src: C:/Users/SD/Documents/Studio/MyProject/Widgets/Build/Release/release/*.lib
Project MESSAGE: General Build
Project MESSAGE: Building...
Project MESSAGE: Public Build
Project MESSAGE: Lib dest: C:/Qt/Qt5.9.0/5.9.1/msvc2017_64/lib
Project MESSAGE: Lib src: C:/Users/SD/Documents/Studio/MyProject/Widgets/Build/Release/debug/*.lib C:/Users/SD/Documents/Studio/MyProject/Widgets/Build/Release/release/*.pdb
Project MESSAGE: General Build
Use QMAKE_POST_LINK solved my problem :
message(Building...)
QT += widgets designer
PLUGIN_CLASS_NAME = QKWidgets
QTDIR_build {
message(Qt Build)
# This is only for the Qt build. Do not use externally. We mean it.
PLUGIN_TYPE = designer
load(qt_plugin)
CONFIG += install_ok
} else {
message(Public Build)
# Public example:
TARGET = $$qtLibraryTarget($$TARGET)
CONFIG += plugin debug_and_release
TEMPLATE = lib
target.path = $$[QT_INSTALL_PLUGINS]/designer
INSTALLS += target # headersDataFiles libraryFiles
headersDataFiles.path = $$[QT_INSTALL_HEADERS]/$$PLUGIN_CLASS_NAME/
headersDataFiles.files = $$PWD/*.h
libraryFiles.path = $$[QT_INSTALL_LIBS]
CONFIG(debug, debug|release): libraryFiles.files = $$OUT_PWD/debug/*.lib $$OUT_PWD/debug/*.pdb
CONFIG(release, debug|release): libraryFiles.files = $$OUT_PWD/release/*.lib
win32 {
# Copy *.lib
DESTDIR_WIN = $$libraryFiles.path
DESTDIR_WIN ~= s,/,\\,g
FILES = $$libraryFiles.files
FILES ~= s,/,\\,g
for(FILE, FILES){
QMAKE_POST_LINK += $$quote(cmd /c copy /y $${FILE} $${DESTDIR_WIN}$$escape_expand(\\n\\t))
}
# Copy *.h
DESTDIR_WIN = $$headersDataFiles.path
DESTDIR_WIN ~= s,/,\\,g
FILES = $$headersDataFiles.files
FILES ~= s,/,\\,g
for(FILE, FILES){
QMAKE_POST_LINK += $$quote(cmd /c copy /y $${FILE} $${DESTDIR_WIN}$$escape_expand(\\n\\t))
}
}
}
Related
I'm currently struggling to get a sub folder of my project to copy to the out directory. I had thought i had it all set up correctly but i guess i'm missing a step. When I run the make i get a "No rule to make target 'copyfiles'" message.
I know I could just make a new build step with a OS specific method, but i was hoping to avoid it cause I would like to build and run on a different OS eventually.
Edit:
Yes this question has been asked before. However the solutions given in those questions have not worked for me. They throw errors or simply do nothing.
CONFIG(release, debug|release): DESTDIR = $$OUT_PWD/release
CONFIG(debug, debug|release): DESTDIR = $$OUT_PWD/debug
copytarget.path = $$DESTDIR/etc
copytarget.files += $$files(etc/*)
## === os specific dir separator ===
win32 {
copytarget.files ~= s,/,\\,g
copytarget.path ~= s,/,\\,g
}
message("found files for copytarget: "$$copytarget.files)
message("found files destination: "$$copytarget.path)
## === copy compiler for makefile ===
DirSep = /
win32: DirSep = \\
for(f,copytarget.files) tmp += $$PWD$$DirSep$${f} ## make absolute paths
copycompiler.input = tmp
isEmpty(DESTDIR):DESTDIR=.
copycompiler.output = $$DESTDIR$$DirSep${QMAKE_FILE_BASE}${QMAKE_FILE_EXT}
copycompiler.commands = $(COPY_FILE) ${QMAKE_FILE_IN} ${QMAKE_FILE_OUT}
copycompiler.CONFIG = no_link no_clean
## other CONFIG options are: depends explicit_dependencies target_predeps
copycompiler.variable_out = QMAKE_DISTCLEAN
QMAKE_EXTRA_COMPILERS += copycompiler
## == makefile copy target ===
copyfiles.recurse_target = compiler_copycompiler_make_all
copyfiles.depends = $$copyfiles.recurse_target
copyfiles.CONFIG += recursive
MAKE_EXTRA_TARGETS += copyfiles
POST_TARGETDEPS += copyfiles ## copy files after source compilation
INSTALLS += copytarget
I am trying to use qmake's subdirs template. The problem is that the output directory specified in the sub projects is created in the build directory instead of the directory that is being referenced in the projects. other then that everything works normally. I was wondering if there is a way to fix this.
Dir Structure
build-project_dir/
-Apps/ --this gets created
-Other things
project_dir/
-main.pro
-Apps/ -- I want it to use this instead
-Server/
----Server.pro
----some logic files
-Parser/
----Parser.pro
----Parser files
-muparser/
-build/
----muparser.pro
----main.cpp
Main.pro
TEMPLATE = subdirs
# where to find the sub projects - give the folders
Server.subdir = Server
Parser.subdir = Parser
muparser.file = muparser-2.2.5\build\muparser.pro
# what subproject depends on others
Server.depends = Parser
Parser.depends = muparser
SUBDIRS = muparser Parser Server
Server.pro
TEMPLATE = app
QT += core sql websockets xml
QT -= gui
TARGET = Server
CONFIG += console
CONFIG -= app_bundle
CONFIG += thread
SOURCES += $$files(src/*.cpp, true) $$files(src/*.c, true)
HEADERS += $$files(src/*.h, true)
INCLUDEPATH += src src/things/include
LIBS += -L../lib -lParser
DESTDIR = ../Apps
Parser.pro
TEMPLATE = lib
QT -= gui
TARGET = Parser
DEFINES += PARSER_LIBRARY
SOURCES += parser.cpp
HEADERS += parser.h
INCLUDEPATH += ./include
DEPENDPATH += $$PWD/./
LIBS += -L../lib -lmuparser
DESTDIR += ../lib
DLLDESTDIR += ../Apps
The reason for this is because there are DLL that are needed there.
Thank to Bill I was able to find a solution to the problem
I simply had to change the DESTDIR location for my apps to DESTDIR = $$_PRO_FILE_PWD_/../Apps_Win
I made a muparser.pri which had the following content,
macx|win32|equals(build_muparser, "true")|!packagesExist(muparser){
message("Using bundled muparser")
MUPARSER_DIR = src/rel/muparser
DEPENDPATH += $$MUPARSER_DIR/include \
$$MUPARSER_DIR/src
INCLUDEPATH += $$MUPARSER_DIR/include
GEN_LIB_DIR = ../../generated/lib
LIBS += -L$$GEN_LIB_DIR -lmuparser
PRE_TARGETDEPS += $$GEN_LIB_DIR/libmuparser.a
}else{
message("Using external muparser")
CONFIG += link_pkgconfig
PKGCONFIG += muparser
}
I, then, added a
include(./muparser.pri)
in my application's make file.
This gave me an error
":-1: error: No rule to make target '../../generated/lib/libmuparser.a', needed by 'debug/Akaar1.exe'. Stop."
What did I do wrong? How else am I supposed to include this library in my project?
In your .pro file you can do:
LIBS += -L*path to the library* -l*library name: foo for libfoo.a*
I have a Qt project (.pro) which has some dependencies that put the include directory in a "release" or "debug" directory when built. What is the best practice method of "switching" which directories are in the include in debug and release? At the moment I have this in my .pro:
CONFIG(debug, debug|release) {
CONFIGURATION = debug
DESTDIR = $${PWD}/../../Interface/Debug
} else {
CONFIGURATION = release
DESTDIR = $${PWD}/../../Interface/Release
}
GENDIR = $${DESTDIR}/Generated
OBJECTS_DIR = $${GENDIR}/obj
MOC_DIR = $${GENDIR}/moc
RCC_DIR = $${GENDIR}/rcc
UI_DIR = $${GENDIR}/ui
INCLUDEPATH += $(LIBOPC_DIR)/$${CONFIGURATION}/include
However if I import this into VS2012 via the Qt VisualStudio plugin it puts $(LIBOPC_DIR)/debug/include into both the debug and release configurations... am I doing something wrong or is this a limitation of the VS plugin and/or qmake?
I've read all post about it and none of solutions works in windows and linux. My current solution works pretty well in Windows, creating, if doesn't exist, the respective directory for debug or release.
I want to create all my object files (*.o) inside one of these folders. In windows I achieved this in linux my DESTDIR variable is empty. =|
TEMPLATE = app
TARGET =
DEPENDPATH += .
INCLUDEPATH += .
# Input
HEADERS += Config.h \
keyboard.h \
keyboardgui.h \
keyboardkey.h \
Log.h \
main.h \
mainwindow.h \
Settings.h
FORMS += mainwindow.ui
SOURCES += Config.cpp \
keyboard.cpp \
keyboardgui.cpp \
keyboardkey.cpp \
Log.cpp \
main.cpp \
mainwindow.cpp
RESOURCES += Resources.qrc
OTHER_FILES += \
default_layout.kl
# se for Windows
win32 {
# inclui a lib para acessar o DMI
LIBS += -lqaxcontainer
}
# Habilita a opcao de copia de diretorios
CONFIG += copy_dir_files
Debug:DESTDIR = debug
Release:DESTDIR = release
# copia a pasta configuracao para o diretorio de saida
win32 {
QMAKE_POST_LINK += copy /Y default_layout.kl $$DESTDIR
}
else {
QMAKE_POST_LINK += cp -a default_layout.kl $$DESTDIR
}
I tried to use the INSTALL var but without success. The debug directory is created and all object files is put there but when I changed the compilation mode to RELEASE the objects files continue to be moved to the debug directory and the RELEASE directory isn't created (I've tried to run qmake again). In both configurations my files (default_layout and layout) aren't copied to the output directory.
# Habilita a opcao de copia de diretorios
CONFIG += copy_dir_files
release:DESTDIR = release
release:OBJECTS_DIR = release/
release:MOC_DIR = release/
release:RCC_DIR = release/
release:UI_DIR = release/
debug:DESTDIR = debug
debug:OBJECTS_DIR = debug/
debug:MOC_DIR = debug/
debug:RCC_DIR = debug/
debug:UI_DIR = debug/
INSTALLS += config_files
config_files.path = $$DESTDIR
config_files.filename = default_layout.kl
config_files.filename += layout.kl
thx!
I think the reason it works on Windows and not on Linux is because you capitalized "Debug" and "Release". The examples I have found all have them as lower case (see second example in this section on the qmake document page.)
The other thing I question is the use of DESTDIRS. DESTDIRS tells qmake where you want to put the TARGET. If you want to directly control where only the object files are put, you should use OBJECT_DIRS.
Personally, I use qmake's INSTALLS keyword to do copy extra files where they need to go. It does mean executing both a make and a make install, but it does produce a more platform dependent code.
If I assume you want the TARGET and the objects in 'debug' or 'release', I would do it like this:
# Habilita a opcao de copia de diretorios
debug {
DESTDIR = debug
OBJ_DIR = debug
}
release
{
DESTDIR = release
OBJ_DIR = release
}
# copia a pasta configuracao para o diretorio de saida
config_files.path = $$DESTDIR
config_files.files = default_layout.kl
INSTALLS += config_files
If you are running QtCreator, you can add the make install step to the building settings by selecting the "Projects" icon in the left hand tool bar. Next, select "Add Build Step", "Make", and set the "Make arguments" to install. You will have to do this for each build configuration.