CLion / CMake 多个包含目录问题
CLion / CMake Multiple include directories issue
我正在尝试使用一些共同的源构建多个可执行文件。
我的源代码树如下所示:
root
- CMakeLists.txt
- 00 - common
- CMakeLists.txt
- include
- Window.h
- sources
- Window.cpp
- 01 - sample
- CMakeLists.txt
- include
- sources
... and so on
在我的根 CMakeLists.txt 我做 add_subdirectory 包括公共和所有示例,公共部分构建为静态库。
编译在命令行和 CLion 上运行良好。问题是 CLion 不理解结构,当我在 "common" 文件夹的 Window.cpp 中包含 Window.h 时,CLion 不知道,但它提供使用“.. /include/Window.h" 使用自动补全。
我在 "common" 文件夹的 CMakeLists.txt 中:
add_library(common STATIC ${sources})
target_include_directories(common PUBLIC "include")
我也尝试使用标准方法 include_directories() 但没有成功。
我做错了什么?
好的,在尝试重现问题后,我发现文件夹名称接受 space 但不接受破折号
删除了文件夹名称中的破折号解决了问题
我正在尝试使用一些共同的源构建多个可执行文件。 我的源代码树如下所示:
root
- CMakeLists.txt
- 00 - common
- CMakeLists.txt
- include
- Window.h
- sources
- Window.cpp
- 01 - sample
- CMakeLists.txt
- include
- sources
... and so on
在我的根 CMakeLists.txt 我做 add_subdirectory 包括公共和所有示例,公共部分构建为静态库。
编译在命令行和 CLion 上运行良好。问题是 CLion 不理解结构,当我在 "common" 文件夹的 Window.cpp 中包含 Window.h 时,CLion 不知道,但它提供使用“.. /include/Window.h" 使用自动补全。
我在 "common" 文件夹的 CMakeLists.txt 中:
add_library(common STATIC ${sources})
target_include_directories(common PUBLIC "include")
我也尝试使用标准方法 include_directories() 但没有成功。
我做错了什么?
好的,在尝试重现问题后,我发现文件夹名称接受 space 但不接受破折号
删除了文件夹名称中的破折号解决了问题