栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > C/C++/C#

CMAKE

C/C++/C# 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

CMAKE

可以带这些用法的有如下函数:

  • target_compile_definitions()

  • target_compile_options()

  • target_include_directories()

  • target_link_libraries()

以target_include_directories()的INTERFACE用法为例,

将上一文章中的MathFunctions库为例,

MathFunctions文件夹中的CMakeLists.txt与文件夹外的CMakeLists.txt变化如下,

  • 文件夹内CMakeLists.txt

add_library(MathFunctions mysqrt.cxx)

target_include_directories(MathFunctions
          INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}
          )

  • 文件夹外CMakeLists.txt

cmake_minimum_required(VERSION 3.10)

#set the project name and version
project(Tutorial VERSION 1.0)

#specify the C++ standard
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)

option(USE_MYMATH "Use tutorial provided math implementation" ON)

configure_file(TutorialConfig.h.in TutorialConfig.h)

if(USE_MYMATH)
    #add the MathFunctions Library
    add_subdirectory(MathFunctions)

    list(APPEND EXTRA_LIBS MathFunctions)
endif()

#add the executable
add_executable(Tutorial tutorial.cxx)

target_link_libraries(Tutorial PUBLIC ${EXTRA_LIBS}) 

target_include_directories(Tutorial PUBLIC
                           "${PROJECT_BINARY_DIR}"
                           )

 

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/857101.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号