zoukankan      html  css  js  c++  java
  • CMake---基础练习2

    # t2/ CMakeLists.txt
    
    cmake_minimum_required(VERSION 2.8)
    
    #1
    #PROJECT (HELLO)
    #SET(SRC_LIST main.c)
    #MESSAGE(STATUS "This is BINARY dir" ${HELLO_BINARY_DIR})
    #MESSAGE(STATUS "This is SOURCE dir" ${HELLO_SOURCE_DIR})
    #ADD_EXECUTABLE(hello ${SRC_LIST})
    
    #2
    #PROJECT(HELLO)
    #ADD_EXECUTABLE(hello main.c)
    
    PROJECT(HELLO)
    ADD_SUBDIRECTORY(src bin)
    
    //main.c
    
    #include <stdio.h>
    int main()
    {
        printf("Hello World from t1 Main!
     ");
        
        return 0;
    }
    #  t2/src/CMakeLists.txt
    
    ADD_EXECUTABLE(hello main.c)
    u@u160406:~/learn_Cmake/cmake/t2$ ls
    build  CMakeLists.txt  src
    u@u160406:~/learn_Cmake/cmake/t2$ tree
    .
    ├── build
    ├── CMakeLists.txt
    └── src
        ├── CMakeLists.txt
        └── main.c
    
    2 directories, 3 files
    u@u160406:~/learn_Cmake/cmake/t2$ cd build
    u@u160406:~/learn_Cmake/cmake/t2/build$ cmake ..
    -- The C compiler identification is GNU 5.4.0
    -- The CXX compiler identification is GNU 5.4.0
    -- Check for working C compiler: /usr/bin/cc
    -- Check for working C compiler: /usr/bin/cc -- works
    -- Detecting C compiler ABI info
    -- Detecting C compiler ABI info - done
    -- Detecting C compile features
    -- Detecting C compile features - done
    -- Check for working CXX compiler: /usr/bin/c++
    -- Check for working CXX compiler: /usr/bin/c++ -- works
    -- Detecting CXX compiler ABI info
    -- Detecting CXX compiler ABI info - done
    -- Detecting CXX compile features
    -- Detecting CXX compile features - done
    -- Configuring done
    -- Generating done
    -- Build files have been written to: /home/u/learn_Cmake/cmake/t2/build
    u@u160406:~/learn_Cmake/cmake/t2/build$ make
    Scanning dependencies of target hello
    [ 50%] Building C object bin/CMakeFiles/hello.dir/main.c.o
    [100%] Linking C executable hello
    [100%] Built target hello
    u@u160406:~/learn_Cmake/cmake/t2/build$ cd bin
    u@u160406:~/learn_Cmake/cmake/t2/build/bin$ ./hello
    Hello World from t1 Main!
     u@u160406:~/learn_Cmake/cmake/t2/build/bin$ 

  • 相关阅读:
    使用South时候由于两个相同id的文件引起的问题
    Python os模块
    Ubuntu的关机重启命令知识
    [BUGFIX]__import_pywin32_system_module__
    Django生产环境的部署-Apache-mod_wsgi
    我是如何将linux用在开发环境中的
    php抽奖概率算法
    PHP接收IOS post过来的json数据无法解析的问题
    python apache下出现The _imaging C module is not installed
    php 打印
  • 原文地址:https://www.cnblogs.com/carle-09/p/11685332.html
Copyright © 2011-2022 走看看