I think I've found a solution, the problem was the CmakeLists file
cmake_minimum_required(VERSION 3.16)
find_package(Qt6 REQUIRED COMPONENTS Quick QuickControls2)
qt_add_qml_module(authentication_module
URI AuthenticationModule
VERSION 1.0
RESOURCE_PREFIX /qt/qml
QML_FILES
qml/UseLogin.qml
SOURCES
src/LoginManager.cpp
include/auth/LoginManager.hpp
)
# Now configure the created target
target_include_directories(authentication_module
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/include/auth
)
target_link_libraries(authentication_module
PRIVATE Qt6::Quick Qt6::QuickControls2
)
Needed target_include_directories with path to header file folder (auth) and parent folder to it too (include), target_link_libraries after qt_add_qml_module. Was able to remove "qt_add_library" and NO_PLUGIN. And I believe I needed header file in SOURCES of qt_add_qml_module
Without latter one
target_include_directories(authentication_module
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/include/auth
)
build/Android-Debug/AuthenticationModule/authentication_module_qmltyperegistrations.cpp:23:34: error: use of undeclared identifier 'auth'
23 | qmlRegisterTypesAndRevisions<auth::LoginManager>("AuthenticationModule", 1);
| ^
1 error generated.
Without former one in associated cpp file
projects\testapp\AuthenticationModule\src\LoginManager.cpp:1: error: 'auth/LoginManager.hpp' file not found
projects/testapp/AuthenticationModule/src/LoginManager.cpp:1:10: fatal error: 'auth/LoginManager.hpp' file not found
1 | #include "auth/LoginManager.hpp"
| ^~~~~~~~~~~~~~~~~~~~~~~
:-1: error: ninja: build stopped: subcommand failed.
projects\testapp\AuthenticationModule\src\LoginManager.cpp:1: error: 'auth/LoginManager.hpp' file not found
projects\testapp\AuthenticationModule\src\LoginManager.cpp:4: error: Expected namespace name
projects\testapp\AuthenticationModule\src\LoginManager.cpp:6: error: Use of undeclared identifier 'LoginManager'
projects\testapp\AuthenticationModule\src\LoginManager.cpp:11: error: Use of undeclared identifier 'LoginManager'
I could, however, just change header reference in .cpp file to this (adding "include/") in order to stop that from complaining but I think that's a worse approach with lots of cpp files
#include "include/auth/LoginManager.hpp"