I've got 2 CMakeLists.txt files in my project.
CMakeLists.txt
cmake_minimum_required(VERSION 3.2)
project(Game)
set(CMAKE_CXX_STANDARD 14)
include_directories(core)
add_subdirectory(core)
add_executable(${PROJECT_NAME} game/main.cpp)
target_link_libraries(${PROJECT_NAME} Core)
core/CMakeLists.txt
project(Core)
set(SOURCE_FILES ecs/Component.hpp ecs/Destroyable.hpp ecs/Destroyable.cpp ecs/Entity.hpp ecs/Entity.cpp Game.cpp Game.hpp components/Sprite.hpp components/Sprite.cpp components/Transform.hpp components/Transform.cpp ecs/Serializable.hpp ecs/ComponentsCreator.cpp ecs/ComponentsCreator.hpp common/Utility.cpp common/Utility.hpp common/Logger.hpp common/Logger.cpp common/Vector2.hpp common/Vector2.cpp components/Camera.cpp components/Camera.hpp ecs/Component.cpp components/AnimationPlayer.cpp components/AnimationPlayer.hpp Animation.cpp Animation.hpp Frame.cpp Frame.hpp lib/termcolor.hpp lib/json.hpp)
add_library(${PROJECT_NAME} ${SOURCE_FILES})
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/")
find_package(SFML REQUIRED system window graphics network audio)
if (SFML_FOUND)
include_directories(${SFML_INCLUDE_DIR})
link_libraries(${PROJECT_NAME} ${SFML_LIBRARIES})
endif()
And I'm getting this error while compiling "core/ecs/Entity.hpp:3:29: fatal error: SFML/Graphics.hpp: No such file or directory". Could someone take a look and tell me what's wrong with this?
link_librariesit should betarget_link_libraries: you need to link target, marked with first argument, with libraries in other arguments. But the command you currently use links all futher targets (created after the command) with libraries-arguments.