Closed v-val closed 2 years ago
When trying to use clsocket without installing it (e.g. with FetchContent), include path is not set and compilation fails. With following dummy example: main.cpp:
clsocket
FetchContent
main.cpp
#include <PassiveSocket.h> int main() {}
CMakeLists.txt:
CMakeLists.txt
project(test_clsocket_cmake LANGUAGES CXX) set(CMAKE_CXX_STANDARD 17) include(FetchContent) FetchContent_Declare( clsocket GIT_REPOSITORY https://github.com/DFHack/clsocket.git ) option(CLSOCKET_SHARED Off) option(CLSOCKET_DEP_ONLY Off) FetchContent_MakeAvailable(clsocket) set(app_ ${PROJECT_NAME}) add_executable(${app_} main.cpp) target_link_libraries(${app_} clsocket)
Pre-build cmake stage passes fine, but the build fails:
cmake
[main] Building folder: clsocket-cmake [build] Starting build [proc] Executing command: /Users/me/brew/bin/cmake --build /Users/me/src/clsocket-cmake/build --config Debug --target all -- [build] [1/2 50% :: 0.057] Building CXX object CMakeFiles/test_clsocket_cmake.dir/main.o [build] FAILED: CMakeFiles/test_clsocket_cmake.dir/main.o [build] /usr/bin/clang++ -g -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk -std=gnu++17 -MD -MT CMakeFiles/test_clsocket_cmake.dir/main.o -MF CMakeFiles/test_clsocket_cmake.dir/main.o.d -o CMakeFiles/test_clsocket_cmake.dir/main.o -c /Users/me/src/clsocket-cmake/main.cpp [build] /Users/me/src/clsocket-cmake/main.cpp:1:10: fatal error: 'PassiveSocket.h' file not found [build] #include <PassiveSocket.h> [build] ^~~~~~~~~~~~~~~~~ [build] 1 error generated. [build] ninja: build stopped: subcommand failed. [proc] The command: /Users/me/brew/bin/cmake --build /Users/me/src/clsocket-cmake/build --config Debug --target all -- exited with code: 1 and signal: null [build] Build finished with exit code 1
When trying to use
clsocket
without installing it (e.g. withFetchContent
), include path is not set and compilation fails. With following dummy example:main.cpp
:CMakeLists.txt
:Pre-build
cmake
stage passes fine, but the build fails: