I compile GLFW from source and link it according to its official guide. As you can see, I originally tried compiling GLFW and linking it inside of the static library.
This is the CMake script of the application I am trying to make use my static library:
cmake_minimum_required(VERSION 3.10)
project(FaceEngineTest)
When I attempt to use any feature of my engine it comes up with an undefined reference. The headers are properly referenced and VSCode recognises all the contents of my static library. However, I can still use all GLFW functions, and I can make a class that derives from a class from my engine: class MyGame : public FaceEngine::Game
Why can my program use GLFW functions fine but not my own library?
When asking compilation and link related questions it’s useful to mention the toolchain (clang, gcc or MS compiler etc.) and OS and also add the error lines from the compilation output. Without these it’s difficult to know the exact error.
In this case I think the problem is that you need to explicitly link FaceEngine to GLFW - you were doing this in the first script for FaceEngine but have commented it out.
Also you’re not using add_subdirectory("FaceEngine") to include the FaceEngine library cmake script. I would either use that approach or combine your two cmake scripts into one.
I’m using Ubuntu Desktop and GCC/G++. Since my post I’ve made my engine static library require GLFW, and then I make my application require my engine, which then compiles GLFW and then the static library, but I still get undefined references. These are my CMake scripts for the static library and application respectively:
cmake_minimum_required(VERSION 3.10)
project(FaceEngine)
It looks like your code for FaceEngine is not compiled/linked to all the required source / libraries.
So ${SOURCES} in project FaceEngine cmake file is probably missing the source which defines FaceEngine::Engine::running and FaceEngine::Engine::GamePtr.
Those are variables in a class in a header file. They are definitely defined. The source includes FaceEngine.cpp, which #include’s FaceEngine.h, which defines the classes with those members.