[Development] Notes on "Qt Build Systems" @ QtCon 2016

Stephen Kelly stephen.kelly at ableton.com
Fri Sep 9 12:30:16 CEST 2016



On 08/09/16 14:34, Christian Kandeler wrote:
> On 09/08/2016 02:03 PM, Bo Thorsen wrote:
>> Ok, go try it. Create a simple python or perl script that reads a file.
>> The file just has a single number N inside it. And based on N the script
>> outputs those files:

Here's the CMake version:

     cmake_minimum_required(VERSION 3.5.0)
     project(cmaketest)

     find_package(Qt5Core REQUIRED)

     execute_process(
       COMMAND python ${CMAKE_CURRENT_SOURCE_DIR}/generator.py --list 
${CMAKE_CURRENT_BINARY_DIR}/genoutput 5
       OUTPUT_VARIABLE fileList
     )

     string(REPLACE "\n" ";" fileList ${fileList})

     add_custom_command(OUTPUT ${fileList}
       COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/generator.py 
${CMAKE_CURRENT_BINARY_DIR}/genoutput 5
     )

     qt5_wrap_cpp(moc_files ${fileList})

     add_executable(servertest servertest.cpp ${fileList} ${moc_files})
     target_link_libraries(servertest Qt5::Core)
     target_include_directories(servertest PRIVATE 
${CMAKE_CURRENT_BINARY_DIR}/genoutput)



However, it is cheating in the same way that the QBS version from 
Christian is cheating - it assumes '--list' exists:

> In qbs:
>
>      outputArtifacts: {
>          var p = new Process();
>          try {
>              p.exec("path_to_script", ["--list", input.filePath]);
>              var files = p.readStdout.split("\n");
>

Christian, can you create a version which does not require --list? As 
far as I understand, that is the point of the QBS dynamic build graph. I 
would like to make sure my understanding is correct. I've attached the 
generator and servertest.cpp if that helps.

Thanks,

-- 
Ableton AG, Schoenhauser Allee 6-7, 10119 Berlin, Germany
Management Board: Gerhard Behles, Jan Bohl
Chair of the Supervisory Board: Uwe Struck
Registered Office: Berlin, Amtsgericht Berlin-Charlottenburg, HRB 72838

-------------- next part --------------
A non-text attachment was scrubbed...
Name: generator.py
Type: text/x-python-script
Size: 1125 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/development/attachments/20160909/8bee3419/attachment.bin>
-------------- next part --------------

#include "server.h"

#include <QObject>
#include <QDebug>

int main(int argc, char** argv)
{
    Server server;
    auto m2 = server.call2();
    if (m2->metaObject()->className() == QStringLiteral("Method2")) {
        qDebug() << "PASS";
        return 0;
    }
    qDebug() << "FAIL";
    return 1;
}


More information about the Development mailing list