我在一个项目中有一些 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})
# 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
(or ccmake
) 配置然后运行make
时,它不会编译.el
文件。然而,它确实说它完成了目标的构建emacs_byte_compile
。所以我假设我对依赖项的工作方式有一些误解。