I have a project and the file structure of it looks like this:
|-- CMakeLists.txt
|-- build
|-- include
|-- libs
| |-- glad
| | |-- include
| | | `-- glad
| | | `-- glad.h
| | `-- src
| | `-- glad.c
| `-- glfw
| `-- include
| `-- GLFW
| `-- glfw3.h
|-- sandbox
| |-- CMakeLists.txt
| |-- build
| `-- main.cpp
`-- src
and i want to link the project as a static library. the goal is, that at the end i can just say, in the CMakeLists.txt file of sandbox:
target_link_libraries(sandbox <path_to_library>/libsomething.a)
and with that, i also want glad and glfw to link/compile. my current CMakeLists.txt file of the root folder looks like this:
cmake_minimum_required(VERSION 3.10)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
project(luna)
find_package(glfw3 3.3 REQUIRED)
file(GLOB_RECURSE SRC_FILES src/*.cpp)
add_library(luna ${SRC_FILES} libs/glad/src/glad.c)
target_link_libraries(luna glfw)
target_include_directories(luna PUBLIC include libs/glad/include libs/glfw/include)
and the CMakeLists.txt in sandbox like this:
cmake_minimum_required(VERSION 3.10)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
project(sandbox)
find_package(glfw3 3.3 REQUIRED)
add_executable(sandbox main.cpp)
target_link_libraries(sandbox <absolut_path_to_library>)
im not expecting that the file structure is perfect at the moment, so tips on improving it would be very welcome.