I have some elisp files in a project that I want to byte compile and install with CMake. After compilation I want to have a target to install the .el
and .elc
files to a directory. What I have so far is
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)
When I configure with cmake
(or ccmake
) and then run make
, it doesn't compile the .el
files. It does however say that it finished building the target emacs_byte_compile
. So I assume I have some misunderstanding as to how the dependencies work.