So, my purpose is trying to set up open cv in VS studio for Opencvtest project/folder through CMakeLists.txt, however in line 11 target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBS} has an error and I even try to put my folder/project name in targer_link_libraries() still did not know how to fix. I hope you guys can help me with this
Here is the code in CMakeLists.txt
cmake_minimum_required(VERSION 3.0.0)
project(Opencvtest VERSION 0.1.0)
include(CTest)
enable_testing()
find_package(OpenCV REQUIRED)
include_directories( ${OpenCV_INCLUDE_DIRS})
add_executable(Opencvtest main.cpp)
#add_executable(main ${PROJECT_SOURCE_DIR}/main.cpp)
target_link_libraries(Opencvtest ${OpenCV_LIBS})
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack)
Here is the output:
[main] Configuring folder: Opencvtest
CMake Error at CMakeLists.txt:10 (add_executable):
[cmake] Cannot find source file:
[cmake]
[cmake] main.cpp
[cmake]
[cmake] Tried extensions .c .C .c++ .cc .cpp .cxx .cu .mpp .m .M .mm .ixx .cppm .h
[cmake] .hh .h++ .hm .hpp .hxx .in .txx .f .F .for .f77 .f90 .f95 .f03 .hip .ispc
[cmake]
[cmake]
[cmake] CMake Error at CMakeLists.txt:10 (add_executable):
[cmake] No SOURCES given to target: Opencvtest
Please help me with this problem and thank you so much