[CMake] byte-compiling emacs lisp sources

2010-02-13 Thread Tim Blechmann
hi all,

i've got some troubles to byte-compile emacs lisp files with cmake.

basically, i need to do the following
- copy source file to the build directory
- compile the elc file with: emacs -batch -f batch-byte-compile 
/path/to/source.el
- add an install rule to install the generated elc file to 
share/emacs/site-lisp



currently, i am using this snippet:
configure_file(${el}
   ${CMAKE_CURRENT_BINARY_DIR}/${el})

add_custom_command(TARGET ${el}c
  COMMAND emacs -batch -f batch-byte-compile 
${CMAKE_CURRENT_BINARY_DIR}/${el}
  DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${el})

install(TARGETS ${el}c
DESTINATION share/emacs/site-lisp)

however, neither the byte-code target is generated, nor the does the install 
statement want to install the target (since it is not an executable, library 
or module)

what am i doing wrong? or is there a module for building emacs byte-code 
files?

thanks in advance, tim

-- 
t...@klingt.org
http://tim.klingt.org

Which is more musical, a truck passing by a factory or a truck passing
by a music school?
  John Cage


___
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] byte-compiling emacs lisp sources

2010-02-13 Thread Michael Wild

On 13. Feb, 2010, at 13:05 , Tim Blechmann wrote:

 hi all,
 
 i've got some troubles to byte-compile emacs lisp files with cmake.
 
 basically, i need to do the following
 - copy source file to the build directory
 - compile the elc file with: emacs -batch -f batch-byte-compile 
 /path/to/source.el
 - add an install rule to install the generated elc file to 
 share/emacs/site-lisp
 
 
 
 currently, i am using this snippet:
 configure_file(${el}
   ${CMAKE_CURRENT_BINARY_DIR}/${el})
 
 add_custom_command(TARGET ${el}c
  COMMAND emacs -batch -f batch-byte-compile 
 ${CMAKE_CURRENT_BINARY_DIR}/${el}
  DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${el})
 
 install(TARGETS ${el}c
DESTINATION share/emacs/site-lisp)
 
 however, neither the byte-code target is generated, nor the does the install 
 statement want to install the target (since it is not an executable, library 
 or module)
 
 what am i doing wrong? or is there a module for building emacs byte-code 
 files?
 
 thanks in advance, tim

You should use

# find emacs and complain if not found
find_program(EMACS_EXECUTABLE emacs)
if(NOT EMACS_EXECUTABLE)
  message(SEND_ERROR Emacs could not be found)
endif()

# copy source to binary tree
configure_file(${el} ${CMAKE_CURRENT_BINARY_DIR}/${el})
# add rule (i.e. command) how to generate the byte-compiled file
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${el}c
  COMMAND ${EMACS_EXECUTABLE} -batch -f batch-byte-compile
${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 a top-level target to byte-compile all emacs-lisp sources
add_custom_target(emacs_byte_compile ALL
  DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${el}c)

# install the byte-compiled emacs-lisp sources
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${el}c
  DESTINATION share/emacs/site-lisp)


HTH

Michael
___
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] byte-compiling emacs lisp sources

2010-02-13 Thread Tim Blechmann
hello michael,

thanks a lot ... i needed to adapt it a bit for my applications, but it 
works like charm now ...

thanks, tim

-- 
t...@klingt.org
http://tim.klingt.org

Happiness is a byproduct of function, purpose, and conflict; those who
seek happiness for itself seek victory without war.
  William S. Burroughs


___
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake