QTest and .pro workflow - c++

This is my (very simplified) directory tree :
C:.
| common.h
| QMelt.pro
|
+---src
| +---app
| | main.cpp
| | melt.cpp
| | melt.h
| |
| +---io
| | alsfilestreambase.h
| | alsfilesystem.cpp
| | alsfilesystem.h
|
\---test
+---io
| io_test.pro
| io_test.pro.user
|
\---src
alsfilesystemtest.cpp
alsfilesystemtest.h
What I'm trying to achieve is to configure io_test.pro - which is an unit test project (using QTest) - to be able to test the io namespace.
Here is my current io_test.pro :
QT += testlib
QT -= gui
TARGET = tst_io
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
#Test sources
SOURCES += src/alsfilesystemtest.cpp
HEADERS += src/alsfilesystemtest.h
#Testing sources
SOURCES += ../../src/io/alsfilesystem.cpp
HEADERS += ../../src/io/alsfilesystem.h
DEFINES += SRCDIR=\\\"$$PWD/src\\\"
INCLUDEPATH += $$PWD/../..
My problem is that I have linker errors at build time. These errors are on method using QMelt project (the project I want to test) dependecy, included by alsfilesystem.
So my question is what modifications should I bring to io_test.pro in order to use the .obj built by QMelt.pro ?

Related

GLOB_RECURSE grabbing the wrong source file

My source project directory is something like this,
|── CMakeLists.txt
|
├── src
| |
| |
| |
| └── a
| | |
| | |__ a.cpp
| |
| |
| |
| └── b
| |
| |__ b.cpp
|
|___test
|
|__test.cpp
I need to make a executable out of source a.cpp and b.cpp,
file(GLOB_RECURSE SRC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/*/ *.cpp)
I expect this to take a.cpp and b.cpp as the only source files, but when I print
message("All source file - ${SRC_FILES}")
It picks up test.cpp as well, which I don't know why it's happening. My understanding here is ${CMAKE_CURRENT_SOURCE_DIR}/src/*/ *.cpp, in this statement
due to wildcard * it would go through each subdirectory of src folder, and then with *.cpp it would append all the cpp files inside each of these subdirectory.

Is there any way to compile source code in subdirectories via gnu make

I'm trying to write Makefile script which will compile my project in VS Code which contains sub directories. My project structure looks like:
src
| - subdirectory1
| | - file1.cpp
| | - file2.cpp
| - subdirectory2
| | - sub3
| | | - file4.cpp

How cmake handle include_directories() for a project with nested folder

The problem is solved, it is due to other dependency of my project, it has nothing wrong with cmake. Thanks for everyone trying to help in the question.
Here is my project tree Tree 1:
project
| + src
| | + other_src
| | | - abc.cpp
| | | - abc.h
| | - main.cpp
| - CMakeLists.txt
3rd_party
| + pcap
| | - pcap.h
| - pcap.h
Inside my CMakeLists.txt, I do:
include_directories("/path/to/3rd_party")
Inside my abc.cpp, I have:
#include "pcap.h"
Then I do cmake and make. I get error pcap.h: No such file or directory
I then change my project tree Tree 2:
project
| + src
| | - abc.cpp
| | - abc.h
| | - main.cpp
| - CMakeLists.txt
3rd_party
| + pcap
| | - pcap.h
| - pcap.h
Without modifying my CMakeLists.txt, I do cmake and make again. The header file is found.
How can I build this project while my source code is placed in different folders?

How to organize project using cmake and separated headers

I am currently starting a new project using C++ and CMake,
in my last project I organized the code the following:
src
|--foo
| |--bar.cpp
| |--bar.hpp
| |--CMakeLists.txt
|--baz
| |--anotherFoo
| | |--Bahama.cpp
| | |--Bahama.hpp
| | |--CMakeLists.txt
| |--baz.cpp
| |--baz.hpp
| |--CMakeLists.txt
|--CMakeLists.txt
so every subdirectory got its own CMakeLists.txt, which was included as library from other CMakeList files.
Now I want to separate the .hpp and the .cpp files.
Something like this:
src
|--foo
| |--bar.cpp
| |--CMakeLists.txt
|--baz
| |--anotherFoo
| | |--Bahama.cpp
| | |--CMakeLists.txt
| |--baz.cpp
| |--CMakeLists.txt
|--CMakeLists.txt
include
|--foo
| |--bar.hpp
| |--CMakeLists.txt
|--baz
| |--anotherFoo
| | |--Bahama.hpp
| | |--CMakeLists.txt
| |--baz.hpp
| |--CMakeLists.txt
|--CMakeLists.txt
What I am supposed to do with the CmakeLists files?
Do I also need a CMakeLists file in every subdirectory, like I did in my example above? Or is there another way to do this?
What do I write in this CMake files
In the future I also want to add documentation with doxygen, how can I enable Doxygen support via Cmake in a structure like this?
should also every subdirectory get its own?

Embedded pdfium in C++ application

I'm currently trying to build a C++ application witch is able to convert PDF files to images.
I want to use pdfium to do this.
So I built pdfium as explain in the wiki and copied headers and generated libs in my cmake project.
When I try to build my application I get the following error:
src/include/pdfium-linux64/v8/include/libplatform/libplatform.h:8:33: fatal error: include/v8-platform.h: no such file or directory
In fact in this file there is:
#include "include/v8-platform.h"
But directories are like this:
include
| pdfium-linux64
| | v8
| | | include
| | | | libplatform
| | | | \ libplatform.h
| | | | v8-platform.h
| | | \ ...
| | \ ...
| \ ...
\ ...
So it could not work..
Does anyone have an idea of what to do to fix this issue?
Thanks in advance.
Thanks to pdfshaver project, I found a solution:
directly install pdfium through .deb package
add gcc option:
-I/usr/include/pdfium/v8
-L/usr/lib/pdfium
-lpthread
-lpdfium
-lfpdfapi
-lfxge
-lfdrm
-lfpdfdoc
-lfxcodec
-lfxcrt
-lfxedit
-lpdfwindow
-ljsapi
-lv8_libplatform
-lv8_snapshot
-lv8_base
-lv8_libbase
-licui18n
-licuuc
-licudata
-lformfiller
-lfpdftext
-lfpdfdoc
-lbigint
-ljavascript
-lpthread