zoukankan      html  css  js  c++  java
  • Cmake

    1. What is CMake

    2. How to use CMake command line

    3. A simple example to start (My system is Ubuntu 16.04 LTS;  g++ 5.4.0;  cmake 3.5.1)

    Two files are in the same director, one is main.cpp another one is CMakeLists.txt , (big case matters). Use the commands to build and generate the executable file.

    $ cmake .   

    dot means current directory. 

    a folder named CMakeFiles, and files like: CMakeCache.txt, cmake_insall.cmake, Makefile will be generated.

    $ make

    will generate a executable file.

    // main.cpp

    #include <iostream>

    int main(){

      std::cout << "Hello World." << std::endl;

      return 0;

    }

    //CMakeLists.txt

    cmake_minimum_required(VERSION 3.2)

    set(SRC_LIST main.cpp)

    project(main)

    add_executable(main main.cpp)

    4. More details

    (1)project ( <project_name> [cxx] [c] [java])

    two cmake variables are inplicitly defined here: <project_name>_BINARY_DIR    <project_name>_SOURCE_DIR

    (2)SET (VAR [VALUE] [VALUE2] ...)

    (3)ADD_EXECUTABLE(<ext_file_name> ${SRC_LIST})

  • 相关阅读:
    局部类
    内部类
    程序的异常
    四种修饰符
    接口之间的多继承
    多态
    继承父类并实现多个接口
    接口内容小结
    接口的静态方法和私有方法
    顺序栈与链式栈
  • 原文地址:https://www.cnblogs.com/sarah-zhang/p/12185516.html
Copyright © 2011-2022 走看看