|---Engine |----CMakeList.txt |----Engine.cpp |----Engine.h |---Models |----CMakeList.txt |----Snake.cpp |----Snake.hpp |---Type |----CMakeList.txt |----Point.hpp |---CMakeList.txt |---main.cpp I just can't tell the main sheet that I want to add a directory with files to it ...
Each time, errors of the following type appear:
CMake Error at CMakeLists.txt: 12 (target_include_directories): Cannot specify include directories for target "Snake" which is not built by this project. CMake Error at CMakeLists.txt: 13 (target_link_directories): Cannot specify link directories for target "Snake" which is not built by this project. CMake Error at Engine / CMakeLists.txt: 8 (target_include_directories): Cannot specify include directories for target "Snake" which is not built by this project. CMake Error at CMakeLists.txt: 17 (target_link_libraries): Cannot specify link libraries for target "Snake" which is not built by this project. - Configuring incomplete, errors occurred! Which, for several hours of intensified attempts, are not corrected in any way. Can anyone help with this?
CMakeLists.txt from Engine folder:
set(HEADERS Engine.h) set(SOURCES Engine.cpp) add_library(Engine ${HEADERS} ${SOURCES}) target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_LIST_DIR}) Main CMakeList.txt:
cmake_minimum_required(VERSION 3.16.3) project(Snake) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) set(PROJECT_SOURCES main.cpp ) target_include_directories(${PROJECT_NAME} PUBLIC Engine) target_link_directories(${PROJECT_NAME} PUBLIC Engine) add_subdirectory(Engine) target_link_libraries(${PROJECT_NAME} Engine) add_executable(${PROJECT_NAME} ${PROJECT_SOURCES} ) find_package(SFML 2.5.1 COMPONENTS graphics audio REQUIRED) include_directories(${SFML_INCLUDE_DIR}) target_link_libraries(${PROJECT_NAME} sfml-graphics sfml-audio) set(SFML_STATIC_LIBRARIES FALSE)
${PROJECT_NAME}) before it's been declared.PROJECT_NAMErefers to the name of the current project, started withproject()command. It seems that you forgot to callproject()in theEngine/CMakeLists.txt.