用CMake编译elisp文件
我在一个项目中有一些elisp文件,我想用CMake进行字节编译和安装。编译后,我希望有一个目标,将用CMake编译elisp文件,cmake,elisp,Cmake,Elisp,我在一个项目中有一些elisp文件,我想用CMake进行字节编译和安装。编译后,我希望有一个目标,将.el和.elc文件安装到一个目录中。到目前为止,我得到的是 set(ELISP_SOURCES a.el.in b.el ) # Top level target to compile the elisp sources add_custom_target(emacs_byte_compile ALL) foreach(el ${ELISP_SOURCES}) # Conf
.el
和.elc
文件安装到一个目录中。到目前为止,我得到的是
set(ELISP_SOURCES
a.el.in
b.el
)
# Top level target to compile the elisp sources
add_custom_target(emacs_byte_compile ALL)
foreach(el ${ELISP_SOURCES})
# Configure and copy the files
get_filename_component(EL_NAME ${el} NAME_WE)
configure_file(${el} ${CMAKE_CURRENT_BINARY_DIR}/${EL_NAME}.el)
# Add command to compile the files
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${EL_NAME}.elc
COMMAND ${EMACS} ARGS -batch -f batch-byte-compile ${CMAKE_CURRENT_BINARY_DIR}/${EL_NAME}.el
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${EL_NAME}.el
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
# Create the dependencies
add_dependencies(emacs_byte_compile
${CMAKE_CURRENT_BINARY_DIR}/${EL_NAME}.el ${CMAKE_CURRENT_BINARY_DIR}/${EL_NAME}.elc
)
# Installation target
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${EL_NAME}.el ${CMAKE_CURRENT_BINARY_DIR}/${EL_NAME}.elc
RUNTIME DESTINATION ${ELISP_DIR}
)
endforeach(el)
当我配置
cmake
(或ccmake
)然后运行make
,它不会编译.el
文件。但是,它确实说它完成了目标的构建emacs\u byte\u compile
。因此,我假设我对依赖项的工作方式有一些误解。您需要创建一个顶级目标,它使用您创建的自定义命令的输出。你可以在这里找到一些想法:
add_dependencies命令仅在连接顶级cmake目标时有用,这样line就不会做任何事情
大概是这样的:
foreach(el ..)
# collect output files into a list
# create a custom command to run emacs to create the elc,
#input is .el output is .elc
endforeach()
add_custom_target(emacs_byte_compile DEPENDS ${ELC_LIST})