windows CMakeLists.txt

在windows下写好CMakeLists.txt,然后配合cmake-gui使用。

CMakeLists.txt写的不够好,后期优化,以下仅供参考:

 1 # set(OpenCV_DIR D:/Program Files/opencv3.4.6/opencv/build/include/)
 2 find_package(OpenCV 3.4.6 REQUIRED)
 3 
 4 # If the package has been found, several variables will
 5 # be set, you can find the full list with descriptions
 6 # in the OpenCVConfig.cmake file.
 7 # Print some message showing some of them
 8 message(STATUS "OpenCV library status:")
 9 message(STATUS "    version: ${OpenCV_VERSION}")
10 message(STATUS "    libraries: ${OpenCV_LIBS}")
11 message(STATUS "    include path: ${OpenCV_INCLUDE_DIRS}")
12 set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
13 set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
14 set(LINK_DIR D:/windows/x64/Release/)
15 # Add OpenCV headers location to your include paths
16 include_directories(${OpenCV_INCLUDE_DIRS})
17 
18 # Declare the executable target built from your sources
19 
20 aux_source_directory(. DIR_SRCS)
21 add_executable(main ${DIR_SRCS})
22 
23 # Link your application with OpenCV libraries
24 # link_libraries("D:/windows/x64/Release")
25 LINK_DIRECTORIES(${LINK_DIR}) #链接静态库目录
26 target_link_libraries(main ${OpenCV_LIBS} ${LINK_DIR}/idcard.lib)

 

由于依赖opencv静态库,opencv又没有设置为环境变量,cmake直接找依赖opencv时总是会找到Anaconda里面的opencv,此时需要把opencv路径指定到你编译opencv静态库的路径:

windows CMakeLists.txt

 

 

windows CMakeLists.txt

上一篇:C#在循环中使用Random时生成的随机数相同的解决办法


下一篇:P3647 [APIO2014]连珠线 树形DP+换根法