Own CMAKE library
Hey, I am relatively new to cpp.
I programmed some classes I want to be able to build to a separate library I can use from another cpp project.
This my directory structure:
1 2 3 4 5 6 7 8 9 10
|
Root
- Game/
- CMakeLists.txt
- main.cpp
- Engine/
- CMakeLists.txt
- src/
- Engine.h
- ....
- CMakeLists.txt
|
Now I want to be able to run a function from Engine.h in main.cpp but I get the error "Velium.h: No such file or directory"
These are my CMakeLists:
Root CMakeLists.txt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
cmake_minimum_required(VERSION 3.21)
project(Root)
set(CMAKE_CXX_STANDARD 23)
set(VELIUM_INCLUDE_DIR
${CMAKE_CURRENT_SOURCE_DIR}/Engine)
add_subdirectory(Engine)
include_directories(${Engine_INCLUDE_DIR})
add_subdirectory(Game)
ADD_DEPENDENCIES(Game Engine)
|
Engine CMakeLists.txt
1 2 3 4 5 6 7 8 9 10 11 12
|
cmake_minimum_required(VERSION 3.21)
project(Engine)
set(CMAKE_CXX_STANDARD 23)
add_library(Engine STATIC
src/Engine.h)
target_include_directories(Engine PUBLIC lib/imgui/)
target_link_libraries(Engine -lGL -lsfml-network -lsfml-graphics -lsfml-window -lsfml-system -lsfml-audio -lX11)
|
Game CMakeLists.txt
1 2 3 4 5 6 7 8 9 10
|
cmake_minimum_required(VERSION 3.21)
project(Game)
set(CMAKE_CXX_STANDARD 23)
add_executable(Game
main.cpp)
target_link_libraries(Game Engine)
|
Last edited on
Topic archived. No new replies allowed.