correct load-path for cmake build

This commit is contained in:
nik gaffney 2022-08-19 13:14:17 +02:00
parent e97fd18d31
commit 875d328c18
Signed by: nik
GPG key ID: 989F5E6EDB478160

View file

@ -1,19 +1,30 @@
option(SC_EL_BYTECOMPILE "Build emacs-based IDE." ON)
mark_as_advanced(SC_EL_BYTECOMPILE)
set(PKG_DATA_DIR ${CMAKE_INSTALL_PREFIX}/share/SuperCollider)
file(GLOB scel_sources
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.el)
list(REMOVE_ITEM scel_sources ".dir-locals.el")
file(GLOB_RECURSE local-load-path
# if w3m in installed locally add to the load-path
file(GLOB local-load-path
LIST_DIRECTORIES true
"~/.emacs.d/site-lisp/*"
"~/.emacs.d/elpa/*")
"$ENV{HOME}/.emacs.d/site-lisp/w3m-*"
"$ENV{HOME}/.emacs.d/elpa/w3m-*")
set(all_scel_sources ${scel_sources} sclang-vars.el)
foreach (path ${local-load-path})
if(NOT IS_DIRECTORY ${path})
list(REMOVE_ITEM local-load-path ${path})
endif()
endforeach()
set(PKG_DATA_DIR ${CMAKE_INSTALL_PREFIX}/share/SuperCollider)
list(APPEND local-load-path ${CMAKE_CURRENT_BINARY_DIR})
# convert to string of form " dir1 -L dir2 -L dir3 ..." when more than one dir
string(JOIN " -L " load-path ${local-load-path})
# build the argument string
string(CONCAT EMACS_ARGS "-batch -L " ${load-path} " -f batch-byte-compile")
configure_file(sclang-vars.el.in
${CMAKE_CURRENT_BINARY_DIR}/sclang-vars.el)
@ -27,24 +38,17 @@ set(all_scel_sources ${scel_sources} sclang-vars.el)
install (FILES ${scel_sources} ${CMAKE_CURRENT_BINARY_DIR}/sclang-vars.el
DESTINATION share/emacs/site-lisp/SuperCollider)
# the emacs command needs to be evaled due to layers of (un)escaping required to add load-path
if (SC_EL_BYTECOMPILE)
find_program(EMACS_EXECUTABLE emacs)
if(EMACS_EXECUTABLE-NOTFOUND)
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()
find_program(W3M_EXECUTABLE w3m)
if(W3M_EXECUTABLE-NOTFOUND)
message(SEND_ERROR "Install w3m to build the help viewer.")
endif()
foreach (el ${all_scel_sources})
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${el}c
COMMAND ${EMACS_EXECUTABLE} -batch
-L ${CMAKE_CURRENT_BINARY_DIR}
-L ${local-load-path}
-f batch-byte-compile
${CMAKE_CURRENT_BINARY_DIR}/${el}
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")