openFrameworks icon indicating copy to clipboard operation
openFrameworks copied to clipboard

use of as a library in my cmake project

Open ggslayer opened this issue 2 years ago • 4 comments

Hi, the of project is compiled by make system, But in my case, my project is compiled by cmake, and I want to link of's .so/.a libraries into my project. I saw the makefile and compile command line:

g++ -c -g3 -DDEBUG -Wall -Werror=return-type -DGCC_HAS_REGEX -std=c++17 -DOF_USING_GTK -Wall -Werror=return-type -DGCC_HAS_REGEX -std=c++17 -pthread -D_REENTRANT -pthread -I/usr/include/gstreamer-1.0 -I/usr/include/orc-0.4 -I/usr/include/gstreamer-1.0 -I/usr/include/AL -I/usr/include/x86_64-linux-gnu -I/usr/include/rtaudio -I/usr/include/gtk-3.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-2.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/fribidi -I/usr/include/harfbuzz -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/../include/include -I/mnt/data/projects/jd-third-party/src/of-0.12/libs/fmod/include -I/mnt/data/projects/jd-third-party/src/of-0.12/libs/glm/include -I/mnt/data/projects/jd-third-party/src/of-0.12/libs/glm/include/glm -I/mnt/data/projects/jd-third-party/src/of-0.12/libs/glm/include/glm/detail -I/mnt/data/projects/jd-third-party/src/of-0.12/libs/glm/include/glm/ext -I/mnt/data/projects/jd-third-party/src/of-0.12/libs/glm/include/glm/simd -I/mnt/data/projects/jd-third-party/src/of-0.12/libs/glm/include/glm/gtc -I/mnt/data/projects/jd-third-party/src/of-0.12/libs/glm/include/glm/gtx -I/mnt/data/projects/jd-third-party/src/of-0.12/libs/json/include -I/mnt/data/projects/jd-third-party/src/of-0.12/libs/kiss/include -I/mnt/data/projects/jd-third-party/src/of-0.12/libs/pugixml/include -I/mnt/data/projects/jd-third-party/src/of-0.12/libs/tess2/include -I/mnt/data/projects/jd-third-party/src/of-0.12/libs/utf8/include -I/mnt/data/projects/jd-third-party/src/of-0.12/libs/utf8/include/utf8 -I/mnt/data/projects/jd-third-party/src/of-0.12/libs/openFrameworks -I/mnt/data/projects/jd-third-party/src/of-0.12/libs/openFrameworks/sound -I/mnt/data/projects/jd-third-party/src/of-0.12/libs/openFrameworks/communication -I/mnt/data/projects/jd-third-party/src/of-0.12/libs/openFrameworks/events -I/mnt/data/projects/jd-third-party/src/of-0.12/libs/openFrameworks/math -I/mnt/data/projects/jd-third-party/src/of-0.12/libs/openFrameworks/utils -I/mnt/data/projects/jd-third-party/src/of-0.12/libs/openFrameworks/3d -I/mnt/data/projects/jd-third-party/src/of-0.12/libs/openFrameworks/types -I/mnt/data/projects/jd-third-party/src/of-0.12/libs/openFrameworks/app -I/mnt/data/projects/jd-third-party/src/of-0.12/libs/openFrameworks/video -I/mnt/data/projects/jd-third-party/src/of-0.12/libs/openFrameworks/graphics -I/mnt/data/projects/jd-third-party/src/of-0.12/libs/openFrameworks/gl -pthread -D_REENTRANT -pthread -I/usr/include/gstreamer-1.0 -I/usr/include/orc-0.4 -I/usr/include/gstreamer-1.0 -I/usr/include/AL -I/usr/include/x86_64-linux-gnu -I/usr/include/rtaudio -I/usr/include/gtk-3.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-2.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/fribidi -I/usr/include/harfbuzz -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/../include/include -I/mnt/data/projects/jd-third-party/src/of-0.12/addons/ofxAssimpModelLoader/src -I/mnt/data/projects/jd-third-party/src/of-0.12/addons/ofxAssimpModelLoader/libs -I/mnt/data/projects/jd-third-party/src/of-0.12/addons/ofxAssimpModelLoader/libs/assimp -MMD -MP -MF /mnt/data/projects/jd-third-party/src/of-0.12/addons/obj/linux64/Debug/ofxAssimpModelLoader/src/ofxAssimpModelLoader.d -MT /mnt/data/projects/jd-third-party/src/of-0.12/addons/obj/linux64/Debug/ofxAssimpModelLoader/src/ofxAssimpModelLoader.o -o /mnt/data/projects/jd-third-party/src/of-0.12/addons/obj/linux64/Debug/ofxAssimpModelLoader/src/ofxAssimpModelLoader.o -c /mnt/data/projects/jd-third-party/src/of-0.12/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp

, so I want to link the commond line's libs by target_link_libraries / target_include_directories in cmake. Is there any problem in this way? and aother question: I saw when addons is used by of project, the addon source code is compiled with my code together, So, I must add the addon's to my cmake's add_executable ?

In general, I want to use of as a library, link to my program( which is not compiled by cmake), process ofAppNoWindow / ofRunMainLoop in my source code, can you give me some compile's advices? thankyou!

ggslayer avatar Oct 30 '23 08:10 ggslayer

There's recently been some effort to translate OF's build system to CMake, to make it easier to use as a lib in projects like yours. Check out this PR #7524 by @HerrNamenlos123 Not sure if it's fully functional yet, but it may help you..

Nejrup avatar Nov 08 '23 10:11 Nejrup

It is not exactly fully functional yet, but OF and all addons themselves compile fine. The only issue we are still having is that we still haven't decided how to handle dependencies. There are a gazillion ways to handle dependencies in C++ and unfortunately there is none that is THE BEST in all situations. When we finally decided on one way for the future of OF, it is not complicated to implement.

HerrNamenlos123 avatar Nov 08 '23 10:11 HerrNamenlos123

If you just need to build and link it in a single local project, without the need to make it reproducable, you could use an older commit of mine, where OF builds fine.

HerrNamenlos123 avatar Nov 08 '23 10:11 HerrNamenlos123

Ok, I see.. I will try it later, thank you.

ggslayer avatar Nov 08 '23 10:11 ggslayer