Code Monkey home page Code Monkey logo

Comments (5)

Neutree avatar Neutree commented on September 23, 2024 1
  1. menuconfig 生成的配置在 global_config.cmake 中,会在找到所有组件后被 include 进 compile.cmake,而且变量全部都会被加上 CONFIG_ 前缀,不太确定 toolchain.cmake 能不能稳定读取到,可以用 message() 打印试试
  2. 直接给 project.py 加对参数 -D 的支持,然后在调用 cmake命令的时候传进去我觉得是可行的,只是和 cmake 命令一样每次都要填参数
  3. 我最初加 config 命令的初衷是配置工具链使得 distclean 命令也不会清理掉 config 命令配置的参数,实际上将参数暂存在 .config.cmake 中,最后也是合并生成到 global_config.cmake 里面,和 1 类似,只是 distclean 命令不会删除 .config.cmake 文件。 当然,也可以考虑改一下将 config 的参数都在执行 cmake 命令的时候传进去。
  4. 还有一种方法是设置环境变量,在 toolchain.cmake 中通过 $ENV{VAR_NAME} 获取,不过用起来也不算很舒服

所以综上,

  • 如果方案1能行最好,不过据我的经验,貌似 toolchain.cmake 会被调用多次,不一定能稳定读取到 global_config.cmake 中的值;
  • 可以考虑改 build 和 config 命令均支持 -D 参数,在 cmake命令的时候直接传进可能比较好

from c_cpp_project_framework.

skb666 avatar skb666 commented on September 23, 2024

是否可以让 cmake -S. -Bbuild ... 这一步在 config 时就完成(即在 config 时 完成 Makefile 的生成)

menuconfig 这步配置的项 应该只作用于编译时程序中读取的吧

from c_cpp_project_framework.

skb666 avatar skb666 commented on September 23, 2024
cmake -S. -Bbuild -DVCPKG_HOST_TRIPLET=arm64-linux -DVCPKG_TARGET_TRIPLET=arm64-linux 

用于生成 Makefile;使用 python 时生成 Makefile 发生在这一步

./project.py build -DVCPKG_HOST_TRIPLET=arm64-linux -DVCPKG_TARGET_TRIPLET=arm64-linux

且修改文件后第二次构建时可以直接 ./project.py build

这个传递的不是全局变量,是 cmake 变量,键、值都外部指定;这么一看,build 支持传入参数已经挺 ok 了!!! :)

from c_cpp_project_framework.

Neutree avatar Neutree commented on September 23, 2024

确实,有道理,只需要在 build 时传入就好了,一旦生成了makefile就不需要传参了。
但是这样在调用 rebuild 时还是需要传入参数,可能需要小心容易忘记传入而出错

from c_cpp_project_framework.

skb666 avatar skb666 commented on September 23, 2024

测试了一下,./project.py rebuild 不额外传入参数也可以成功构建,./project.py clean./project.py build 不带参数也可以成功构建!
对于 vcpkg.cmake,传入参数是为了自动 install 依赖的包;./project.py clean./project.py rebuild 没有删除整个 ./build 文件夹;之前通过 vcpkg 自动下载的包仍然保留在 ./build 目录下,包依然存在所以不需要重新根据平台进行下载编译,也就不用传入额外参数!

from c_cpp_project_framework.

Related Issues (8)

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.