Combining two projects

There are two projects: FreeRDP and cFLTK (a C wrapper for the FLTK library).
I am writing a GUI for FreeRDP and I want to combine my work with the FreeRDP source code project.

My attempt at unification:
I have separately compiled a static library from the cFLTK source code. Next, I placed my developments in a separate directory. Created an assembly file there CMakeLists.txt. My source code is also compiled as a static library.
Further in the file CMakeLists.txt I am connecting my developments to the FreeRDP project.

...

set(GFREE gfree)
add_subdirectory(${GFREE})
set(GFREE_FLAGS
    gfree
    cfltk
    fltk
    fltk_images
    fltk_jpeg
    fltk_z
    png16
    m
    X11
    Xinerama
    Xfixes
    Xcursor
    Xft
    Xrender
    fontconfig
)
ADD_LIBRARY(cfltk STATIC IMPORTED)
set_target_properties(cfltk PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/gfree_lib/libcfltk.a)
ADD_LIBRARY(fltk STATIC IMPORTED)
set_target_properties(fltk PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/gfree_lib/libfltk.a)
ADD_LIBRARY(fltk_images STATIC IMPORTED)
set_target_properties(fltk_images PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/gfree_lib/libfltk_images.a)
ADD_LIBRARY(fltk_jpeg STATIC IMPORTED)
set_target_properties(fltk_jpeg PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/gfree_lib/libfltk_jpeg.a)
ADD_LIBRARY(fltk_z STATIC IMPORTED)
set_target_properties(fltk_z PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/gfree_lib/libfltk_z.a)

....

set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} freerdp-client freerdp m ${GFREE_FLAGS})
....

Everything is assembled without errors and runs.
At first, the GUI I wrote is called, when using which I then call the FreeRDP connection.

The problem is that when I connect, I get errors.

[21:01:24:425] [4624:4625] [ERROR][com.freerdp.core.nego] - Protocol Security Negotiation Failure
[21:01:24:426] [4624:4625] [ERROR][com.freerdp.core] - rdp_client_connect:freerdp_set_last_error_ex ERRCONNECT_SECURITY_NEGO_CONNECT_FAILED [0x0002000C]
[21:01:24:426] [4624:4625] [ERROR][com.freerdp.core.connection] - Error: protocol security negotiation or connection failure

I tried to build FreeRDP without my own developments - the connection is made without problems.
I suspect that combining my code and the FreeRDP code leads to some problems.
Perhaps I am not combining these projects correctly.

Is it possible to properly combine two CMake projects in order not to radically edit other people’s configs? I ask you to help me understand and suggest in this matter. Thank you in advance!

It certainly could be that your combination misses some detail (say an optional dependency?), but that is outside the scope of here. Maybe the FreeRDP developers would have a better inkling of where to start looking?

In general, no. Well-behaved projects are probably easier to do this with (e.g., those that namespace all variables and internal APIs).