Page 1 of 1

cmakelists.txt中的变量如何在程序中使用?

Posted: Fri Jun 02, 2023 1:47 am
by 13302657252
大家好,
我有个问题请教,cmakelists.txt中的变量如何在程序中使用?比如以下cmakelists.txt文件中的PROJECT_VER变量,我如何在c程序中使用?试了很多办法不知如何使用。


# The following lines of boilerplate have to be in your project's
# CMakeLists in this exact order for cmake to work correctly
cmake_minimum_required(VERSION 3.5)

set(PROJECT_VER "0.1.4.1")
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(hello-world)

Re: cmakelists.txt中的变量如何在程序中使用?

Posted: Tue Jun 06, 2023 11:21 am
by ESP_LiuH
请使用 add_compile_option ,具体使用方式见如下链接说明:https://cmake.org/cmake/help/latest/com ... ile_option