Git Product home page Git Product logo

junxnone / cmake Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kitware/cmake

0.0 0.0 0.0 120.94 MB

Mirror of CMake upstream repository

Home Page: https://gitlab.kitware.com/cmake/cmake

License: Other

Shell 0.47% CMake 25.16% Emacs Lisp 0.05% C 43.90% C++ 29.90% Fortran 0.03% HTML 0.01% Python 0.37% Perl 0.02% Assembly 0.04% Java 0.02% TeX 0.01% Pascal 0.01% MATLAB 0.01% Lua 0.01% JavaScript 0.01% M 0.01% Objective-C++ 0.01% PHP 0.01% Pike 0.01%

cmake's Introduction

Hi there 👋



cmake's People

Contributors

berkgeveci avatar billhoffman avatar bradking avatar christx avatar craigscott-crascit avatar cristianadam avatar derdakon avatar dlrdave avatar do-m-en avatar drdanz avatar gjasny avatar jwuttke avatar kwrobot avatar kylefromkitware avatar malaterre avatar markapola avatar mathstuf avatar neundorf avatar ngladitz avatar pdl3 avatar purplekarrot avatar sebastienbarre avatar steveire avatar syntheticpp avatar tambry avatar theerk avatar wahikihiki avatar zachmullen avatar zackgalbreath avatar zaufi avatar

Watchers

 avatar

cmake's Issues

cmake tutorial Selecting Static or Shared Libraries

enable_testing() 

cmake tutorial 子项目头文件声明

  • 子项目中的头文件如果声明为 INTERFACE, 则不需要在父项目中被包含

cmake tutorial 安装&测试

安装配置

添加 TestCase

$ make test
Running tests...
Test project /home/xxx/CMake/Help/guide/tutorial/Step5/build
    Start 1: Runs
1/9 Test #1: Runs .............................   Passed    0.00 sec
    Start 2: Usage
2/9 Test #2: Usage ............................   Passed    0.00 sec
    Start 3: Comp4
3/9 Test #3: Comp4 ............................   Passed    0.00 sec
    Start 4: Comp9
4/9 Test #4: Comp9 ............................   Passed    0.00 sec
    Start 5: Comp5
5/9 Test #5: Comp5 ............................   Passed    0.00 sec
    Start 6: Comp7
6/9 Test #6: Comp7 ............................   Passed    0.00 sec
    Start 7: Comp25
7/9 Test #7: Comp25 ...........................   Passed    0.00 sec
    Start 8: Comp-25
8/9 Test #8: Comp-25 ..........................   Passed    0.00 sec
    Start 9: Comp0.0001
9/9 Test #9: Comp0.0001 .......................   Passed    0.00 sec

100% tests passed, 0 tests failed out of 9

Total Test time (real) =   0.03 sec
  • 跑某个测试案例
$ctest -R Usage
  • 显示 测试案例的详细信息
$ctest -V -R Usage

cmake tutorial cpack 打包

  • 添加 cpack

    • 设置 License
    • 设置版本号
    • 设置打包格式

    # setup installer
    include(InstallRequiredSystemLibraries)
    set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/License.txt")
    set(CPACK_PACKAGE_VERSION_MAJOR "${Tutorial_VERSION_MAJOR}")
    set(CPACK_PACKAGE_VERSION_MINOR "${Tutorial_VERSION_MINOR}")
    set(CPACK_SOURCE_GENERATOR "TGZ")
    include(CPack)

  • 生成三种打包文件

    • Tutorial-1.0-Linux.tar.gz
    • Tutorial-1.0-Linux.tar.Z
    • Tutorial-1.0-Linux.sh 可执行文件(安装包)
  • 中间文件夹 _CPack_Packages

_CPack_Packages
└── Linux
    ├── STGZ
    │   ├── Tutorial-1.0-Linux
    │   │   ├── bin
    │   │   │   └── Tutorial
    │   │   ├── include
    │   │   │   ├── MathFunctions.h
    │   │   │   └── TutorialConfig.h
    │   │   └── lib
    │   │       └── libMathFunctions.a
    │   └── Tutorial-1.0-Linux.sh
    ├── TGZ
    │   ├── Tutorial-1.0-Linux
    │   │   ├── bin
    │   │   │   └── Tutorial
    │   │   ├── include
    │   │   │   ├── MathFunctions.h
    │   │   │   └── TutorialConfig.h
    │   │   └── lib
    │   │       └── libMathFunctions.a
    │   └── Tutorial-1.0-Linux.tar.gz
    └── TZ
        ├── Tutorial-1.0-Linux
        │   ├── bin
        │   │   └── Tutorial
        │   ├── include
        │   │   ├── MathFunctions.h
        │   │   └── TutorialConfig.h
        │   └── lib
        │       └── libMathFunctions.a
        └── Tutorial-1.0-Linux.tar.Z

ctest to cdash ??

cmake tutorial Packaging Debug and Release

cmake tutorial 检查是否存在symbol(Function/Macro/Variable)

Reference

Analysis

  • 检查是否存在 log & exp 函数

  • 如果没有添加 m library, 再检查一次,并把 m library 添加到 target link library

    include(CheckSymbolExists)
    check_symbol_exists(log "math.h" HAVE_LOG)
    check_symbol_exists(exp "math.h" HAVE_EXP)
    if(NOT (HAVE_LOG AND HAVE_EXP))
    unset(HAVE_LOG CACHE)
    unset(HAVE_EXP CACHE)
    set(CMAKE_REQUIRED_LIBRARIES "m")
    check_symbol_exists(log "math.h" HAVE_LOG)
    check_symbol_exists(exp "math.h" HAVE_EXP)
    if(HAVE_LOG AND HAVE_EXP)
    target_link_libraries(MathFunctions PRIVATE m)
    endif()
    endif()

  • 添加 编译器定义

    if(HAVE_LOG AND HAVE_EXP)
    target_compile_definitions(MathFunctions
    PRIVATE "HAVE_LOG" "HAVE_EXP")
    endif()

### flags.make
CXX_DEFINES = -DHAVE_EXP -DHAVE_LOG
### CMakeCache.txt
//Have symbol exp
HAVE_EXP:INTERNAL=1
//Have symbol log
HAVE_LOG:INTERNAL=1

cmake tutorial base

#define Tutorial_VERSION_MAJOR 1
#define Tutorial_VERSION_MINOR 0
  • 生成可执行文件

    add_executable(Tutorial tutorial.cxx)

  • 添加头文件搜索路径

    • PROJECT_BINARY_DIR build 路径
    • target_include_directories(): 添加路径到 target 包含头文件路径 (指定目标文件依赖项的使用范围 PRIVATE/INTERFACE/PUBLIC)
      • PRIVATE: 私有头文件, 不会被外部包含调用
      • INTERFACE: 接口类型头文件, 会被包含调用
      • PUBLIC: = PRIVATE + INTERFACE

    target_include_directories(Tutorial PUBLIC
    "${PROJECT_BINARY_DIR}"
    )

cmake tutorial Adding Generator Expressions

cmake tutorial 编译选项

#define USE_MYMATH
/* #undef USE_MYMATH */

cmake tutorial 生成查找表

### MathFunctions/Table.h
double sqrtTable[] = {
0,
1,
1.41421,
1.73205,
2,
2.23607,
2.44949,
2.64575,
2.82843,
3,
0};

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.