# From QMake to CMake. (Different path levels)

**URL:** <https://discourse.cmake.org/t/from-qmake-to-cmake-different-path-levels/2843>\
**Category:** Code\
**Tags:** os:linux, os:windows\
**Created:** [February 25, 2021, 2:02pm UTC](https://discourse.cmake.org/t/from-qmake-to-cmake-different-path-levels/2843 "2021-02-25T14:02:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jos](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/j/2bfe46/32.png) [@Jos](https://discourse.cmake.org/u/Jos)\
**Post date:** [February 25, 2021, 2:02pm UTC](https://discourse.cmake.org/t/from-qmake-to-cmake-different-path-levels/2843/1 "2021-02-25T14:02:52Z")

</div>

Hi evereyone,

I’m trying to port a multilevel project from QMake to CMake.

Below show I the desired structure:

The location of the root CMakeLists.txt a path level before than the main and the lib is a requirement

```auto
    ├── CMakeLists.txt
    ├── app02
    │ ├── CMakeLists.txt
    │ └── main.cpp
    └── lib
        ├── CMakeLists.txt
        ├── myprint.cpp
        └── myprint.h

```

The root CMakeLists.txt is so written:

```auto
    cmake_minimum_required(VERSION 3.13)

    set(CMAKE_PROJECT_NAME "testProject")
    project(${CMAKE_PROJECT_NAME})

    list(APPEND CMAKE_PREFIX_PATH "/home/enigma/Qt/5.15.2/gcc_64")

    set(CMAKE_CXX_STANDARD 17)
    set(CMAKE_CXX_STANDARD_REQUIRED ON)

    set(CMAKE_AUTOMOC ON)
    set(CMAKE_INCLUDE_CURRENT_DIR ON)

    find_package(Qt5Core REQUIRED)
    find_package(Qt5Widgets REQUIRED)

    add_subdirectory(lib app02)

    set(TARGET "app02Build")
    add_executable(${TARGET} ${SOURCES})

    target_link_libraries(${TARGET} thePrintLibrary Qt5::Core Qt5::Widgets)

```

The main.cpp in app002 path is written so:

```auto
    #include "../lib/myprint.h"

    int main(int argc, char *argv[])
    {
        myPrint::print("This the second App");
    }

```

And here is its correspondig CMakeLists.txt:

```auto
    cmake_minimum_required(VERSION 3.13)

    set(SOURCES
        main.cpp
    )

```

The lib path contains the next files:

myprint.h

```auto
    #ifndef MYPRINT_H
    #define MYPRINT_H

    #include <QDebug>
    #include <string>

    class myPrint
    {
    public:
        static void print(std::string toPrint) {
            qDebug() << toPrint.c_str();
        }
    };

    #endif // MYPRINT_H

```

myPrint.cpp

```auto
    #include "myprint.h"
    //yes, there is no more code :-)

```

and the corresponding CMakeLists.txt

```auto
    cmake_minimum_required(VERSION 3.13)

    add_library( 
    	thePrintLibrary
    	myprint.h
    	myprint.cpp
    )

```

The CMake prescan runs fine, but when I compile I become the next error:

```auto
    [28%] Building CXX object app02/CMakeFiles/thePrintLibrary.dir/myprint.cpp.o
    In file included from /home/enigma/APD_Programas/Port/test/lib/myprint.cpp:1:
    /home/enigma/APD_Programas/Port/test/lib/myprint.h:4:10: fatal error: QDebug: No such file or directory
     #include <QDebug>
              ^ ~~~~~~~
    compilation terminated.
    gmake[2]: *** [app02/CMakeFiles/thePrintLibrary.dir/build.make:63: app02/CMakeFiles/thePrintLibrary.dir/myprint.cpp.o] Error 1
    gmake[1]: *** [CMakeFiles/Makefile2:162: app02/CMakeFiles/thePrintLibrary.dir/all] Error 2
    gmake: *** [Makefile:84: all] Error 2

```

Someone so kind to help me?

Thanks in advance

---

<div class="post-metadata">

**Author:** ![ClausKlein](https://discourse.cmake.org/user_avatar/discourse.cmake.org/clausklein/32/352_2.png) [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)\
**Post date:** [March 3, 2021, 12:13pm UTC](https://discourse.cmake.org/t/from-qmake-to-cmake-different-path-levels/2843/2 "2021-03-03T12:13:21Z")

</div>

> [@Jos](#):
>
> I’m trying to port a multilevel project from QMake to CMake.

> **[qmake to cmake, are there any tools to help automate this?](https://forum.qt.io/topic/121248/qmake-to-cmake-are-there-any-tools-to-help-automate-this)**
>
> Hey folks, so I'm a total noob to cmake, and I'm trying to convert my current qmake setup over (since I figure that it has to happen sooner or later). However, I my qmake has a bunch of weird stuff in it that I'm not sure how to convert over: # For...

---

<div class="post-metadata">

**Author:** ![Jos](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/j/2bfe46/32.png) [@Jos](https://discourse.cmake.org/u/Jos)\
**Post date:** [March 3, 2021, 12:22pm UTC](https://discourse.cmake.org/t/from-qmake-to-cmake-different-path-levels/2843/3 "2021-03-03T12:22:18Z")

</div>

Thank you Claus,  
I’ll take a look

---

<div class="post-metadata">

**Author:** ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)\
**Post date:** [March 3, 2021, 12:36pm UTC](https://discourse.cmake.org/t/from-qmake-to-cmake-different-path-levels/2843/4 "2021-03-03T12:36:20Z")

</div>

Your `thePrintLibrary` doesn’t link against any Qt libraries. Try adding the following to its CMakeLists.txt file:

```cmake
target_link_libraries(thePrintLibrary PUBLIC Qt5::Core)

```

---

<div class="post-metadata">

**Author:** ![Jos](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/j/2bfe46/32.png) [@Jos](https://discourse.cmake.org/u/Jos)\
**Post date:** [March 11, 2021, 2:59pm UTC](https://discourse.cmake.org/t/from-qmake-to-cmake-different-path-levels/2843/5 "2021-03-11T14:59:29Z")

</div>

Thank you Craig, that is!
