這裏沒有這樣的文件或目錄是C的文件夾層次++項目:使用cmake
1. FolderA
1. file1.h/cpp
2. CMakeLists.txt (CmakeA)
2. FolderB
1. file2.h/cpp
2. CMakeLists.txt (CmakeB)
3. main.cpp
4. CMakeLists.txt (CmakeAll)
CmakeA:
file(GLOB FolderA_FILES *.cpp *.h *.hpp)
# add component
add_library(FolderA ${FolderA_FILES})
include_directories(../FolderB)
target_link_libraries(FolderA FolderB)
CMakeB:
file(GLOB FolderB_FILES *.cpp *.h *.hpp)
# add component
add_library(FolderB ${FolderB_FILES})
CMakeAll:
cmake_minimum_required(VERSION 2.8)
#add smirk dependency
set(Smirk_DIR /usr/local CACHE PATH "Directory where Smirk has been installed (e.g. /usr/local).")
include(${Smirk_DIR}/cmake/smirk.cmake)
smirk_project(operatingTableProject)
file(GLOB smirk_operatingTableProject_FILES *.cpp *.h *.hpp)
add_executable(smirk_operatingTableProject ${smirk_operatingTableProject_FILES})
# install directives
install(
TARGETS smirk_operatingTableProject
RUNTIME DESTINATION bin
)
#add FolderB dependency
add_subdirectory(FolderB)
target_link_libraries(smirk_operatingTableProject FolderB)
#add FolderA dependency
add_subdirectory(FolderA)
target_link_libraries(smirk_operatingTableProject FolderA)
在file1.h
我包括file2.h
。問題是,無論我有在main.cpp
FolderA/file1.h
我有一個編譯問題:
file2.h: No such file or directory (in file1.h)
但是,如果我註釋掉包括在main.cpp
,它的工作原理。另外,如果我在file1.cpp
中包含file2.h
,那麼它的工作原理就是這樣,主要問題在於我將子目錄中的頭文件包含在來自其他子目錄的另一個頭文件中,並且其中一個包含在主文件中。
任何幫助,將不勝感激。
用雙引號「」 – Maystro