./dir/
├── bot_example
│ ├── CMakeLists.txt
│ └── example0.cpp
├── CMakeLists.txt
├── README.md
└── sleepy_discord
├── attachment.cpp
├── attachment.h
├── channel.cpp
├── etc...
我正在将一个纯粹视觉工作室的项目重构为CMake,以使其成为跨平台的。我在CMake方面没有丰富的经验,但是这个结构在测试项目中工作到调试问题的最后阶段。它没有包括第一个头文件(attachment.h,我似乎无法识别它。我已经用相同的问题搜索了其他答案,但无济于事。任何和所有帮助非常感谢。
编辑:我应该在Windows下提及这项工作,这就是为什么我感到困惑并且接触到Stack Exchange。顶级CMakeLists.txt
# Project Initialization
CMAKE_MINIMUM_REQUIRED(VERSION 3.5)
Project("Sleepy-Discord")
# Component Initialization
add_subdirectory(sleepy_discord)
add_subdirectory(bot_example)
./ sleepy_discord /的CMakeLists.txt
# Initialize API
cmake_minimum_required(VERSION 3.5)
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
SET(BOOST_MIN_VERSION "1.58.0")
FIND_PACKAGE(Boost ${BOOST_MIN_VERSION} REQUIRED)
FIND_PACKAGE(CURL)
SET (sleepy_discord_SOURCES
./attachment.cpp
./attachment.h
./channel.cpp
./channel.h
./client.cpp
./client.h
./common.cpp
./common.h
./default_functions.cpp
./discord_object_interface.cpp
./discord_object_interface.h
./embed.cpp
./embed.h
./error.h
./experimental.cpp
./experimental.h
./json.c
./json.h
./json_wrapper.cpp
./message.cpp
./message.h
./sd_error.cpp
./server.cpp
./server.h
./sleepy_discord.h
./user.cpp
./user.h
)
if(Boost_FOUND)
add_library(sleepy_discord ${sleepy_discord_SOURCES})
target_include_directories(sleepy_discord INTERFACE
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>"
"$<BUILD_INTERFACE:${Boost_INCLUDE_DIRS}>"
"$<BUILD_INTERFACE:${CURL_INCLUDE_DIR}>"
"$<BUILD_INTERFACE:>${OPENSSL_INCLUDE_DIR}"
"$<BUILD_INTERFACE:>${CPR_INCLUDE_DIR}"
)
else()
message(STATUS "Boost library not found.")
endif()
./ bot_example /的CMakeLists.txt
# Initialize Bot
cmake_minimum_required(VERSION 3.5)
set(bot_example_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/example0.cpp
)
add_executable(bot_example ${bot_example_SOURCES})
target_link_libraries(bot_example sleepy_discord)
终端输出:
Scanning dependencies of target sleepy_discord
[ 5%] Building CXX object sleepy_discord/CMakeFiles/sleepy_discord.dir/attachment.cpp.o
/home/bleugamer/Development/bots/sleepy_discord/sleepy_discord/attachment.cpp:1:24: fatal error: Attachment.h: No such file or directory
compilation terminated.
sleepy_discord/CMakeFiles/sleepy_discord.dir/build.make:62: recipe for target 'sleepy_discord/CMakeFiles/sleepy_discord.dir/attachment.cpp.o' failed
make[2]: *** [sleepy_discord/CMakeFiles/sleepy_discord.dir/attachment.cpp.o] Error 1
CMakeFiles/Makefile2:85: recipe for target 'sleepy_discord/CMakeFiles/sleepy_discord.dir/all' failed
make[1]: *** [sleepy_discord/CMakeFiles/sleepy_discord.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
答案 0 :(得分:3)
在类Unix系统上(好吧,在EXT,UFS和其他“Unixy”文件系统上,准确地说)文件访问是区分大小写的。变化
#include "Attachment.h"
到
#include "attachment.h"