# Combining two projects

**URL:** https://discourse.cmake.org/t/combining-two-projects/5988
**Category:** Usage
**Tags:** os:linux, comp:gcc
**Created:** [July 4, 2022, 7:07am UTC](https://discourse.cmake.org/t/combining-two-projects/5988 "2022-07-04T07:07:12Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![alexanderzhirov](https://discourse.cmake.org/user_avatar/discourse.cmake.org/alexanderzhirov/32/2566_2.png) [@alexanderzhirov](https://discourse.cmake.org/u/alexanderzhirov)
#### Post date: [July 4, 2022, 7:07am UTC](https://discourse.cmake.org/t/combining-two-projects/5988/1 "2022-07-04T07:07:12Z")

</div>

There are two projects: [`FreeRDP`](https://github.com/FreeRDP/FreeRDP) and [`cFLTK`](https://github.com/MoAlyousef/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.

```cmake
...

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.

 ![176949096-4196083f-a9ef-400e-a6cd-1ec5cd1b0212](https://discourse.cmake.org/uploads/default/original/2X/a/a4a88f7c1af2e73114a74663b50d4948e8ba68b4.png)

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

```nohighlight
[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!

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [July 9, 2022, 1:10pm UTC](https://discourse.cmake.org/t/combining-two-projects/5988/2 "2022-07-09T13:10:37Z")

</div>

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?

> [@alexanderzhirov](#):
>
> Is it possible to properly combine two `CMake` projects in order not to radically edit other people’s configs?

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