Reputation: 307
./dir/
├── bot_example
│ ├── CMakeLists.txt
│ └── example0.cpp
├── CMakeLists.txt
├── README.md
└── sleepy_discord
├── attachment.cpp
├── attachment.h
├── channel.cpp
├── etc...
I am refactoring a project that was purely visual studio into CMake in order to make it cross-platform. I am not extensively experienced in CMake, however this structure worked in a test project to the end of debugging the problem. It fails at including the first header file (attachment.h and I can't seem to get it to recognize it. I've searched around for other answers with the same problem but to no avail. Any and all help is appreciated.
EDIT: I should mention this works under windows, which is why I'm confused and reaching out to Stack Exchange.
Top Level 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)
Terminal output:
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
Upvotes: 0
Views: 2575
Reputation: 34411
On Unix-like systems (well, on EXT, UFS and other "Unixy" filesystems, to be precise) file accesses are case sensititive. Change
#include "Attachment.h"
to
#include "attachment.h"
Upvotes: 3