What is cmake

CMake is a cross-platform, open source BuildSystem. CMake can generate platform-specific standard build files from the cmakelists.txt file, for example: Generate makefiles for Unix platforms (compiled using GCC), projects/ Workspaces (compiled using VS IDE), or makefiles (compiled using Nmake) for Windows MSVC. The key is to be cross-platform, and eventually generate a Makefile for compilation on Linux.

Two, common knowledge points

1, static library link target_link_libraries(dlib_demo liblib.a)

Target_link_libraries (dlib_demo dlib)

3, enable dynamic library to compile cmake.. -DBUILD_SHARED_LIBS=ON

cmake .. : The dot (.) after the command indicates the directory at the next level up in the directory.

Execute cmake.. After that, the system automatically generates files such as CMakeFiles, CMakeCache. TXT, and cmake_install.cmake, and generates makefiles. Don’t worry too much about the meaning of these files, the important thing is that it automatically generates makefiles.

Cmake set(SRC_CPP dlib_face_recognize.cpp)

CMAKE_CXX_FLAGS “${CMAKE_CXX_FLAGS} -g-std =c++11 -w”

$SRC CPP = ${SRC_CPP}”

Cmake select compilation

Run the cmake.. -dhisi =1 or -dhisi =ON to compile the Demo with the Heath compiler. The demo is as follows:

Cmake_minimum_required (VERSION 2.8.12) project (eignface_demo)set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -lstdc++ -lm")
set(OPENCV_LIB opencv_highgui opencv_objdetect opencv_core opencv_imgproc opencv_contrib)
set(SRC_CPP EigenFace.cpp)

if (HISI)
    set(TOOLCHAIN_DIR "/opt/hisi-linux-nptl/arm-hisiv100-linux/target")
    set(CMAKE_FIND_ROOT_PATH ${TOOLCHAIN_DIR})
    set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
    set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
    set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
    set(CMAKE_CXX_COMPILER ${TOOLCHAIN_DIR}/bin/arm-hisiv100nptl-linux-g++)
    set(CMAKE_C_COMPILER ${TOOLCHAIN_DIR}/bin/arm-hisiv100nptl-linux-gcc)
    include_directories(./hisi_opencv/include/)
    link_directories(./hisi_opencv/lib/)
    message("-- Use hisi compile demo")
    add_executable(eignface_hisi  ${SRC_CPP})
    target_link_libraries(eignface_hisi ${OPENCV_LIB})
else(a)set(CMAKE_C_COMPILER "/usr/bin/gcc")
    include_directories(./gcc_opencv/include/)
    link_directories(./gcc_opencv/lib/)
    message("-- Use gcc compile demo")
    add_executable(eignface_gcc  ${SRC_CPP})
    target_link_libraries(eignface_gcc ${OPENCV_LIB})
endif()
Copy the code

CMake- basic exercises 1 – WP’s bad writing – blog park www.cnblogs.com/carle-09/p/…

Cmake link static library (a) – blog.csdn.net/ox0080/arti ox0080 blog…

Cmake set cross-compilation environment _Linux _Linux commune – Linux system programming portal www.linuxidc.com/Linux/2014-…