Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Makefile中实现CMake configure_file命令?_Makefile_Cmake - Fatal编程技术网

如何在Makefile中实现CMake configure_file命令?

如何在Makefile中实现CMake configure_file命令?,makefile,cmake,Makefile,Cmake,我想大家都知道优秀的CMake命令: configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/version.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/version.h ) 但我必须在Makefile中实现它。你能帮帮我吗?怎么做 配置文件(version.h)非常简单: #ifndef _VERSION_H_ #define _VERSION_H_ #define VERSION_MAJOR @VE

我想大家都知道优秀的CMake命令:

configure_file( 
    ${CMAKE_CURRENT_SOURCE_DIR}/version.h.cmake 
    ${CMAKE_CURRENT_BINARY_DIR}/version.h 
) 
但我必须在Makefile中实现它。你能帮帮我吗?怎么做

配置文件(version.h)非常简单:

#ifndef _VERSION_H_ 
#define _VERSION_H_ 

#define VERSION_MAJOR @VERSION_MAJOR@ 
#define VERSION_MINOR @VERSION_MINOR@ 
#define VERSION_BUILD @VERSION_BUILD@ 
#define VERSION_REVISION @VERSION_REVISION@ 

#endif // _VERSION_H_

这行不通。也许是这样,但这会很麻烦。这些config.h文件用于将配置工具(从Autotools、CMake等配置)的结果传递给编译器


使用Makefiles时,只需将必要的标志或变量附加到C(++)编译器调用(使用
-D
)。没有必要增加config.h的复杂性。

这不起作用。也许是这样,但这会很麻烦。这些config.h文件用于将配置工具(从Autotools、CMake等配置)的结果传递给编译器


使用Makefiles时,只需将必要的标志或变量附加到C(++)编译器调用(使用
-D
)。没有必要增加config.h的复杂性。

如果您想使用cmake的
configure\u文件
,为什么不直接使用它,而不是重新实现控制盘?无论如何,看看@wasthis是否有帮助,因为我们必须从cmake移动到makefile。重新考虑你的原因:)XY问题如果你想从cmake使用
configure\u file
,为什么不直接使用它,而不是重新实现控制盘?无论如何,看看@WastThis是否有帮助,因为我们必须从cmake转移到makefile。重新考虑您的原因:)XY问题