I'm creating a static library for my game engine which is constructed using the following CMake script:
cmake_minimum_required(VERSION 3.10)
project(FaceEngine)
#set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE)
#set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE)
#set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
include_directories("../Lib/glad/include")
include_directories("../Lib/glfw-3.3.2/include")
include_directories("include")
file(GLOB SOURCES "src/*.cpp")
file(GLOB SOURCES "src/glad.c")
#file(GLOB SOURCES "../Lib/glfw-3.3.2/src/*.c")
#file(GLOB SOURCES "../Lib/glad/src/glad.c")
#add_subdirectory("src/glfw")
add_library(FaceEngine STATIC ${SOURCES})
#target_link_libraries(FaceEngine glfw)
I compile GLFW from source 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)
set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
add_subdirectory("glfw")
link_directories("../FaceEngine")
include_directories("../Lib/glad/include")
include_directories("../Lib/glfw-3.3.2/include")
include_directories("../FaceEngine/include")
file(GLOB SOURCES "./*.cpp")
add_executable(FaceEngineTest ${SOURCES})
target_link_libraries(FaceEngineTest glfw)
target_link_libraries(FaceEngineTest libFaceEngine.a)
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?