I have a given project structure
.
├── CMakeLists.txt
├── lib
│ └── pixel_reader
│ ├── CMakeLists.txt
│ └── src
│ ├── pixel_reader.cpp
│ ├── pixel_reader.h
│ ├── lodepng.cpp
│ └── lodepng.h
├── main.cpp
With the following CMakeLists
./CMakeLists.txt
cmake_minimum_required(VERSION 3.17)
project(pov_system VERSION 1.0)
add_subdirectory(lib/pixel_reader)
add_executable(pov_system main.cpp)
target_link_libraries(pov_system PRIVATE pixel_reader)
./pixel_reader/CMakeLists.txt
add_library(
pixel_reader SHARED
src/pixel_reader.cpp
src/pixel_reader.h
src/lodepng.cpp
src/lodepng.h
)
target_include_directories(pixel_reader PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/src")
While building this CMake Project, I get the following error.
[build]
[build] pixel_reader.cpp
[build] pixel_reader.vcxproj -> C:\Programming\GitHub\pov_system\build\lib\pixel_reader\Debug\pixel_reader.dll
[build] main.cpp
[build] LINK : fatal error LNK1104: Datei "lib\pixel_reader\Debug\pixel_reader.lib" kann nicht geöffnet werden. [C:\Programming\GitHub\pov_system\build\pov_system.vcxproj]
[build] Der Build wurde mit dem Exitcode 1 abgeschlossen.
Question
Am I adding and linking the library correctly? What sources do I have to add as parameter to add_library? I have the feeling that this is my problem.
If you need additional informatons, please let me know.