Android Studio,CMake。如何在编译时打印调试消息?

时间:2022-06-05 01:44:53

I'm using Android Studio 2.3 beta 3. I put message(AUTHOR_WARNING "Hello CMake, hello Android") In my CMakeLists.txt

我正在使用Android Studio 2.3 beta 3.我在我的CMakeLists.txt中输入了消息(AUTHOR_WARNING“Hello CMake,hello Android”)

But I saw this message only few times when rebuilding project in Android Studio. In most cases there's no "Hello CMake, hello Android" string in Gradle Console after build finishes. I've tried resync gradle and clean/rebuild project, still no expected output.

但是在Android Studio中重建项目时,我只看到过几次此消息。在大多数情况下,在构建完成后,Gradle Console中没有“Hello CMake,hello Android”字符串。我已经尝试过resync gradle和clean / rebuild项目,仍然没有预期的输出。

I have some problems with my build (I think it's incorrect paths) so my goal - to print CMake variables in compile time to better understand what is actually going on.

我的构建存在一些问题(我认为这是不正确的路径)所以我的目标 - 在编译时打印CMake变量以更好地理解实际发生的事情。

2 个解决方案

#1


2  

CMake messages are only at generation time (when CMake is used to generate your project / Makefile).

CMake消息仅在生成时(使用CMake生成项目/ Makefile时)。

One way to get CMake to generate is to go to the build folder in a cmd / shell window and type

让CMake生成的一种方法是转到cmd / shell窗口中的build文件夹并输入

cmake .

Note: The build folder should have a CMakeCache.txt file. The above will not work unless it does.

注意:build文件夹应该有一个CMakeCache.txt文件。除非确实如此,否则上述操作无效。

#2


13  

Inside the project tree, you can find the log with all the cmake output inside the folder of each generated architecture. The relative path to the file should be something like:

在项目树中,您可以在每个生成的体系结构的文件夹中找到包含所有cmake输出的日志。文件的相对路径应该是这样的:

[project folder]/app/.externalNativeBuild/cmake/debug/arm64-v8a/cmake_build_output.txt

Here you can see all the MESSAGE calls of the cmake scripts.

在这里,您可以看到cmake脚本的所有MESSAGE调用。

#1


2  

CMake messages are only at generation time (when CMake is used to generate your project / Makefile).

CMake消息仅在生成时(使用CMake生成项目/ Makefile时)。

One way to get CMake to generate is to go to the build folder in a cmd / shell window and type

让CMake生成的一种方法是转到cmd / shell窗口中的build文件夹并输入

cmake .

Note: The build folder should have a CMakeCache.txt file. The above will not work unless it does.

注意:build文件夹应该有一个CMakeCache.txt文件。除非确实如此,否则上述操作无效。

#2


13  

Inside the project tree, you can find the log with all the cmake output inside the folder of each generated architecture. The relative path to the file should be something like:

在项目树中,您可以在每个生成的体系结构的文件夹中找到包含所有cmake输出的日志。文件的相对路径应该是这样的:

[project folder]/app/.externalNativeBuild/cmake/debug/arm64-v8a/cmake_build_output.txt

Here you can see all the MESSAGE calls of the cmake scripts.

在这里,您可以看到cmake脚本的所有MESSAGE调用。