scel/el/CMakeLists.txt

65 lines
2.1 KiB
Text
Raw Normal View History

option(SC_EL_BYTECOMPILE "Build emacs-based IDE." ON)
mark_as_advanced(SC_EL_BYTECOMPILE)
2022-08-19 11:14:17 +00:00
set(PKG_DATA_DIR ${CMAKE_INSTALL_PREFIX}/share/SuperCollider)
2022-08-18 11:30:23 +00:00
2022-08-19 11:14:17 +00:00
file(GLOB scel_sources
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.el)
2022-08-19 11:31:57 +00:00
list(REMOVE_ITEM scel_sources ".dir-locals.el")
2022-08-19 11:14:17 +00:00
# if w3m in installed locally add to the load-path
file(GLOB local-load-path
LIST_DIRECTORIES true
"$ENV{HOME}/.emacs.d/site-lisp/w3m-*"
"$ENV{HOME}/.emacs.d/elpa/w3m-*")
foreach (path ${local-load-path})
if(NOT IS_DIRECTORY ${path})
list(REMOVE_ITEM local-load-path ${path})
endif()
endforeach()
2022-08-19 11:14:17 +00:00
list(APPEND local-load-path ${CMAKE_CURRENT_BINARY_DIR})
2022-08-17 07:19:50 +00:00
2022-08-19 11:14:17 +00:00
# convert to string of form " dir1 -L dir2 -L dir3 ..." when more than one dir
string(JOIN " -L " load-path ${local-load-path})
2022-08-17 07:19:50 +00:00
2022-08-19 11:14:17 +00:00
# build the argument string
string(CONCAT EMACS_ARGS "-batch -L " ${load-path} " -f batch-byte-compile")
configure_file(sclang-vars.el.in
2022-08-19 11:14:17 +00:00
${CMAKE_CURRENT_BINARY_DIR}/sclang-vars.el)
foreach (el ${scel_sources})
2022-08-19 11:14:17 +00:00
configure_file(${el} ${CMAKE_CURRENT_BINARY_DIR}/${el})
endforeach()
set(all_scel_sources ${scel_sources} sclang-vars.el)
install (FILES ${scel_sources} ${CMAKE_CURRENT_BINARY_DIR}/sclang-vars.el
2022-08-19 11:14:17 +00:00
DESTINATION share/emacs/site-lisp/SuperCollider)
2022-08-18 11:30:23 +00:00
2022-08-19 11:14:17 +00:00
# the emacs command needs to be evaled due to layers of (un)escaping required to add load-path
if (SC_EL_BYTECOMPILE)
2022-08-19 11:14:17 +00:00
find_program(EMACS_EXECUTABLE emacs)
if(NOT EMACS_EXECUTABLE)
message(SEND_ERROR "Emacs could not be found.\n (If emacs interface is not required, then set SC_EL=no)")
endif()
foreach (el ${all_scel_sources})
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${el}c
VERBATIM
COMMAND eval "${EMACS_EXECUTABLE} ${EMACS_ARGS} ${CMAKE_CURRENT_BINARY_DIR}/${el}"
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${el}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Creating byte-compiled Emacs lisp ${CMAKE_CURRENT_BINARY_DIR}/${el}c")
add_custom_target(compile_${el}c ALL
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${el}c)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${el}c
DESTINATION share/emacs/site-lisp/SuperCollider)
endforeach()
endif()