Compiling nginx using CLion (via CMake) - nginx

I'm trying to compile nginx 1.9.5 via CLion for debugging purposes.
Because CLion doesn't currently support vanilla Makefiles/Autoconf I ran the autoconf auto/configure script to generate a valid Makefile, opened the project in CLion, then made a very simple CMakeLists.txt to delegate the CLion build to the autoconf generated Makefile (as advised by Using local makefile for CLion instead of CMake).
Unfortunately, my simple CMakeLists.txt seems to have a flaw, as when I reload and run CLion's build command, CMake seems to generate yet a new Makefile and run this empty Make task instead of running the one in ${nginx_SOURCE_DIR}.
How can I change the CMakeLists.txt file below to delegate to the nginx Makefile instead of regenerating a new one?
cmake_minimum_required(VERSION 2.8.4)
project(nginx)
add_custom_target(nginx ALL COMMAND make -C ${nginx_SOURCE_DIR} CLION_EXE_DIR=${PROJECT_BINARY_DIR})

Related

Qt Creator running CMake with different configuration

I'm trying to build a CMakeLists project using Qt Creator 4.8.1. The problem is, I need to run CMake inside a different nativesysroot.
I tried to create a bash script that runs CMake inside the other environment and added it to my kit. As follows:
#!/bin/bash
cd ~/Desktop/Workspace/my_proj/build &&\
~/Desktop/Workspace/my_proj/sdk-x86_64/opt/nativesysroot/usr/bin/sysroot\
~/Desktop/Workspace/my_proj/sdk-vmwx86-x86_64/opt/nativesysroot/usr/bin/cmake "$#"
Such that, sysroot is an executable that changes the current nativesysroot.
The problem is this does not work because Qt Creator is trying to run CMake using the following configuration:
Running "/home/***/Desktop/Workspace/my_proj/script.sh -E server --pipe=/tmp/cmake-.ewYqvn/socket --experimental" in /tmp/QtCreator-kruzfX/qtc-cmake-YOZsCIQx.
This of course causes CMake server connection lost. I tried the look around how to disable the CMake running in server mode but I did not find anything in Qt Creator.
My question is, how to disable CMake in server mode? Or, how to instruct Qt Creator to run my script without adding any flags or options?
Thanks.

Do I really need a './configure' script for my qt-based project?

I have already a Makefile generated from a .pro file (via qmake). The only error message that gcc would report would probably be that Qt is not installed on the target machine.
qmake is the "configure" - and it actually allows implementing configure tests, that's how modern Qt is built. The old "configure" script is no more, even for Qt. qmake does it all.
You cannot redistribute a qmake-generated Makefile, as it's not portable at all. It is specific to whichever Qt installation you want to build the project with. Recall that a user may have multiple of those.
You can include the following "configure" script with a Qt project:
#! /bin/sh
qmake .

How to modify the PATH variable in Qt Creator's project file (.pro)

I use Qt Creator 3.4.2 for Windows and MSVC2013 compiler. When I build the project I get an error:
LNK1158: cannot run 'rc.exe'
I managed to fix it by adding
"C:/Program Files (x86)/Microsoft SDKs/Windows/v7.1A/Bin"
to the PATH variable under
Projects -> Build Environment
But I need to modify the PATH variable by editing the .pro file. This would make it easier to open and build my project on another computer because all the paths would be stored in the .pro file. This solution does not work:
PATH += "C:/Program Files (x86)/Microsoft SDKs/Windows/v7.1A/Bin"
Is it possible at all?
It is strange that you have such error, since Qt Creator should detect MSVC compilers and build project in appropriate environment. Qt Creator knows that it should run required batch file to prepare environment of VS Command Prompt console, for example C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat x86
Anyway, it is possible to write qmake project file (.pro) that creates Makefiles that run any custom shell command before actual project compilation.
When qmake processes .pro file it only creates Makefiles. Then the compilation is done by other make build tool. Qt Creator uses its jom make utility. From VS console it is possible to run nmake.
Make utility runs different tools according to specified in Makefiles rules. It is possible to create additional phony target with build command that sets PATH variable. The main target should depend on this target.
The following lines in .pro file create such rules:
QMAKE_EXTRA_TARGETS += customtarget1
customtarget1.target = dummy
customtarget1.commands = set PATH=C:/Program Files (x86)/Microsoft SDKs/Windows/v7.1A/Bin;$(PATH)
PRE_TARGETDEPS += dummy
So, during processing Makefiles the first target is dummy. Its "build" command sets PATH. Then all other tools run in that environment.

Configure Qt Creator to build statically (Ubuntu)

I'm trying to build a static application on Ubuntu (if it matters, Ubuntu running in a virtual machine in Windows), following the Qt documentation. Accordingly, I have build the libraries from source, using the configuration from the documentation:
./configure -static -prefix /path/to/Qt
There were no error messages from the build from source. I have tried setting the PATH variable in the build environment to the directory that contains my static build files. I've also tried specifying this path in the .pro file's LIBPATH variable. Nevertheless, whenever I build the application, a call to ldd shows that there are still dependencies to the Qt's dynamic libraries. I'm at a loss to understand how I need to configure Qt Creator to fix this.
You should download sources of interested Qt version, configure for static build and compile them yourself.

Qt creator: qmake is not recognized

I am trying to understand 'qmake' by following this tutorial . but when I come the the following command:
qmake -o Makefile hello.pro
my command line console shows me this message:
'qmake' is not recognized as an internal or external command, operable program or batch file
I understood that qmake is part of Qt creator and thus it should be executed whenever I run it within my project's folder. so, why it is not recognized ?
In the start menu entry that was created by the installer for Qt, you should find an item that opens a command prompt with all the needed environment variables (including the PATH) already set. For my Qt 5.0.2 install using MingW, it is called "Qt 5.0.2 for Desktop (MinGW 4.7)".
On Windows, you can add path to qmake to PATH or run qmake from directory where it placed, or use absolute path.
Sorry my friend, i donĀ“t speak English very well.
In Qt 5.10.1 I resolved this problem running the command prompt in the next path, C:\Qt\5.10.1\mingw53_32>, after you need change the directory where is the file hello.pro and run the commnand qmake -o Makefile hello.pro after you can see the makefile in the respective folder.

Resources