Hi,
This is the first project in which I use cmAKE AND c++.
In Eclipse CDT I have created a project which uses 2 shared objects, libBasexCpp and libBasexSocket:
root |-- libBasexTest - libBasexTest.cpp
|-- libBasexCpp
|-- libBasexSocket |-- BasexSocket.cpp
|-- BasexSocket.h
|-- StringUtils.cpp
|-- StringUtils.h
BasexSocket.cpp uses a function that is defined in StringUtils.h.
Basexsocket.h begins with:
#pragma once
#ifndef BASEXSOCKET_H_
#define BASEXSOCKET_H_
#include "StringUtils.h"
...
#endif
When building libBasexSocket, there are no errors and the .so-files are created.
But when building libBasexTest, I receive this error:
[ 57%] Built target libBasexSocket
In file included from <root>/C_CPP_Werkbank/libBasexCpp/src/BasexClient.h:13,
from <root>/C_CPP_Werkbank/libBasexCpp/src/BasexClient.cpp:8:
<root>/C_CPP_Werkbank/libBasexCpp/src/BasexSocket.h:45:10: fatale fout: StringUtils.h: Bestand of map bestaat niet
45 | #include "StringUtils.h"
| ^~~~~~~~~~~~~~~
This the CMakeLists.txt from the main project:
cmake_minimum_required (VERSION 3.25.1)
project (libBasexTest VERSION 1.0)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
file (GLOB_RECURSE SOURCES src/*.cpp)
add_executable(libBasexTest ${SOURCES})
target_include_directories(libBasexTest PUBLIC
"${PROJECT_BINARY_DIR}"
)
target_link_libraries(${PROJECT_NAME} PUBLIC libBasexCpp libBasexSocket) subproject/libBasexSocket")
add_subdirectory("<root>/C_CPP_Werkbank/libBasexCpp" subproject/libBasexCpp)
add_subdirectory("<root>/C_CPP_Werkbank/libBasexSocket" subproject/libBasexSocket)
add_library(BasexCpp SHARED IMPORTED)
add_library(BasexSocket SHARED IMPORTED)
target_include_directories(${PROJECT_NAME} PUBLIC ${PROJECT_BINARY_DIR}/../libBasexCpp/src)
target_include_directories(${PROJECT_NAME} PUBLIC ${PROJECT_BINARY_DIR}/../libBasexSocket/src)
Is this an error in my C++ -code or did I make an error in CMakeListst.txt