#set CMake minimum versionCmake_minimum_required (VERSION 2.8)#set the project nameSET (project_name image_test_01)#Build a projectPROJECT (${project_name})#Find OpenCV Libraryfind_package (OpenCV REQUIRED) include_directories (${opencv_include_dirs})#Print debugging InformationMESSAGE (STATUS"Project: ${project_name}") MESSAGE (STATUS"OpenCV Library Status:") MESSAGE (STATUS"version: ${opencv_version}") MESSAGE (STATUS"libraries: ${opencv_libs}") MESSAGE (STATUS"include path: ${opencv_include_dirs}")#get the code, in the project, put all the code in the SRC folderaux_source_directory (src dir_srcs) MESSAGE (STATUS"Src file: ${dir_srcs}")#compiling an executable programadd_executable (${project_name} ${dir_srcs})#Add a link libraryTarget_link_libraries (${project_name} ${opencv_libs})
Reference: http://blog.csdn.net/ryuuei_1984/article/details/52209331
Linux uses cmakelists to compile programs or generate library files