3
所以我想包含一个全局头文件在不同的文件夹中。下面是CMakeList.txt的代码。在我的.cpp中,当我包含来自本地包含文件夹的某些内容时,它可以工作,但不包含位于不同文件夹中的内容。CMake - 包含项目以外的目录
cmake_minimum_required(VERSION 2.8)
#Project name
project(Server-Client)
#Add all cpp files as source files
file(GLOB_RECURSE SOURCES "src/*.cpp")
#Build executable 'Server' with all files in SOURCES
add_executable(Server ${SOURCES})
#Include all files in include directory
include_directories("include")
target_include_directories(Server PUBLIC "../../GlobalFiles/include")
find_package(Threads REQUIRED)
#Build executable 'localization' with all files in SOURCES
target_link_libraries(Server ${CMAKE_THREAD_LIBS_INIT})
谢谢我被困在这个几个小时,看到你的解决方案后,我意识到我引用了一个错误的文件夹。如果我在include_directories中为相同的文件夹使用相对路径,它将起作用。这被认为是不好的做法?为什么? – SomebodyOnEarth