semlanik / qtprotobuf

Protobuf generator and bindings for Qt framework
https://semlanik.github.io/qtprotobuf
MIT License
170 stars 37 forks source link

Install/Use QtProtobuf in custom Qt installation location #236

Closed cooked closed 3 years ago

cooked commented 3 years ago

Question Hi, how do I build and install QtProtobuf to be used by a Qt installation (qmake) not on the system path? Additional context I'm on Debian and I have Qt installed in /home//Qt as is standard for an installation via the Qt online installer. I'd like to use QtProtobuf with this Qt and not the system one (i.e. pulled/installed from apt repo). What are the build and install configuration parameters i should use during QtProtobuf build?

semlanik commented 3 years ago

Hi @cooked , as per https://github.com/semlanik/qtprotobuf#build-1 you need to specify a path to the Qt cmake directory using CMAKE_PREFIX_PATH variable.

cooked commented 3 years ago

Hi @semlanik thanks for the prompt reply. Indeed I'm following that step. Do I need to install after building? if yes, do I have to specify the installation folder to be my custom Qt folder?

cooked commented 3 years ago

Hi @cooked , as per https://github.com/semlanik/qtprotobuf#build-1 you need to specify a path to the Qt cmake directory using CMAKE_PREFIX_PATH variable.

when I run the configuration it does not complete and I get an error about the script not finding the "qmake"

-- Looking for unistd.h - found -- Found WrapProtobuf: /usr/include found components: Protoc Generator Protobuf CMake Error at cmake/QtProtobufInternalHelpers.cmake:117 (message): Could not find qmake executable Call Stack (most recent call first): src/protobuf/CMakeLists.txt:1 (qt_protobuf_extract_qt_variable) -- Configuring incomplete, errors occurred!

Please note that I've omitted to install any library related to qt form the list in https://github.com/semlanik/qtprotobuf#for-ubuntu-1910-or-higher

semlanik commented 3 years ago

Hi @semlanik thanks for the prompt reply. Indeed I'm following that step. Do I need to install after building? if yes, do I have to specify the installation folder to be my custom Qt folder?

Yeah, it only supports prefixed builds or as a part of a top-level project for now. You may specify the install prefix outside the Qt installation, it's ok. But when you use qmake make sure that you included qtprotobuf modules manually.

semlanik commented 3 years ago

Hi @cooked , as per https://github.com/semlanik/qtprotobuf#build-1 you need to specify a path to the Qt cmake directory using CMAKE_PREFIX_PATH variable.

when I run the configuration it does not complete and I get an error about the script not finding the "qmake"

-- Looking for unistd.h - found -- Found WrapProtobuf: /usr/include found components: Protoc Generator Protobuf CMake Error at cmake/QtProtobufInternalHelpers.cmake:117 (message): Could not find qmake executable Call Stack (most recent call first): src/protobuf/CMakeLists.txt:1 (qt_protobuf_extract_qt_variable) -- Configuring incomplete, errors occurred!

Please note that I've omitted to install any library related to qt form the list in https://github.com/semlanik/qtprotobuf#for-ubuntu-1910-or-higher

Sorry, previous comment was wrong(about protoc). I didn't read the log carefully.

What Qt version do you use?

Overall specifying -DCMAKE_FIND_ROOT_PATH=/home/Qt/path_before_bin should solve the issue

cooked commented 3 years ago

Overall specifying -DCMAKE_FIND_ROOT_PATH=/home/Qt/path_before_bin should solve the issue thanks @semlanik this got me through the configuration steps successfully. but I'm not entirely sure about the install though.

I use Qt 5.15.2 that is located in /home/username/Qt/5.15.2/gcc_64

do I have to add -DCMAKE_INSTALL_PREFIX=/home/username/Qt/5.15.2/gcc_64 (is this path correct or a specific subfolder shall be specified?) to the configuration flags to be able to install qtprotobuf into my Qt installation ?

semlanik commented 3 years ago

@cooked yep, it should work. Let me know if it doesn't :)

cooked commented 3 years ago

@semlanik thanks for the great support. I managed to get my dream configuration and build with the following lines. Hope this can help others :-)

cd qtprotobuf
mkdir build
cd build
/home/$USER/Qt/Tools/CMake/bin/cmake .. -DCMAKE_PREFIX_PATH="/home/$USER/Qt/5.15.2/gcc_64/lib/cmake" -DCMAKE_FIND_ROOT_PATH=/home/$USER/Qt/Qt/5.15.2/gcc_64 -DCMAKE_INSTALL_PREFIX=/home/$USER/Qt/5.15.2/gcc_64 -DQT_PROTOBUF_MAKE_TESTS=FALSE -DQT_PROTOBUF_MAKE_EXAMPLES=FALSE
/home/$USER/Qt/Tools/CMake/bin/cmake --build . -j8 --target install