在cmake中生成asm文件后调用shell命令 [英] Call shell command after asm file generation in cmake
问题描述
在android mk文件中,可以使用LOCAL_FILTER_ASM生成程序集文件后立即调用shell命令.
In android mk files it is possible to call a shell command right after generating assembly files with LOCAL_FILTER_ASM.
我想知道在cmake中是否有任何类似的解决方法?
I was wondering is there any workaround to have something similar in cmake?
推荐答案
I admit I had lookup what LOCAL_FILTER_ASM
does.
因此,以下是我的代码(与CMake相同的功能):
So the following is my piece of code (same functionality just in CMake):
cmake_minimum_required(VERSION 3.0)
project(LocalFilterASM C ASM)
set(LOCAL_FILTER_ASM "cp")
string(
REPLACE
"<ASSEMBLY_SOURCE>" "<OBJECT>.S.original"
MY_CREATE_ASSEMBLY "${CMAKE_C_CREATE_ASSEMBLY_SOURCE}"
)
string(
REPLACE
"<SOURCE>" "<OBJECT>.S"
MY_COMPILE_OBJECT "${CMAKE_ASM_COMPILE_OBJECT}"
)
set(
CMAKE_C_COMPILE_OBJECT
"${MY_CREATE_ASSEMBLY}"
"${LOCAL_FILTER_ASM} <OBJECT>.S.original <OBJECT>.S"
"${MY_COMPILE_OBJECT}"
)
file(WRITE main.c "int main(void) { return 0; }")
add_executable(${PROJECT_NAME} main.c)
这只是采用了一些现有的CMake编译器规则,并将其组合为 CMAKE_C_COMPILE_OBJECT
.请注意,这仅适用于CMake的makefile生成器.
This just takes some of the existing CMake compiler rules and combines it into a new multi-line rule for CMAKE_C_COMPILE_OBJECT
. Please note that this will only work with CMake's makefile generators.
这篇关于在cmake中生成asm文件后调用shell命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!