diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2010-10-05 15:11:17 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2010-10-05 15:11:17 +0200 |
commit | b54ff0ce652de2864d8ffd863aada8cebbbc621b (patch) | |
tree | 76daaddd3a8746ebaaafd4730c042b031f7544ba | |
download | cmake-erlang-b54ff0ce652de2864d8ffd863aada8cebbbc621b.tar cmake-erlang-b54ff0ce652de2864d8ffd863aada8cebbbc621b.zip |
Initial commit
-rw-r--r-- | ErlangTarget.cmake | 35 | ||||
-rw-r--r-- | FindErlang.cmake | 6 |
2 files changed, 41 insertions, 0 deletions
diff --git a/ErlangTarget.cmake b/ErlangTarget.cmake new file mode 100644 index 0000000..2afbc7a --- /dev/null +++ b/ErlangTarget.cmake @@ -0,0 +1,35 @@ +macro(erl_target name) + parse_arguments(ARGS "HEADERS;OPTIONS" "" ${ARGN}) + + set(headers "") + set(out_files "") + + foreach(header ${ARGS_HEADERS}) + list(APPEND headers "${CMAKE_CURRENT_SOURCE_DIR}/${header}") + endforeach(header ${ARGS_HEADERS}) + + foreach(src ${ARGS_DEFAULT_ARGS}) + set(in_file "${CMAKE_CURRENT_SOURCE_DIR}/${src}") + string(REPLACE ".erl" ".beam" src ${src}) + set(out_file "${CMAKE_CURRENT_BINARY_DIR}/${src}") + + add_custom_command( + OUTPUT + ${out_file} + COMMAND + ${ERLC_EXECUTABLE} + "-o" ${CMAKE_CURRENT_BINARY_DIR} + ${ARGS_OPTIONS} + ${in_file} + DEPENDS + ${in_file} + ${headers} + ) + + list(APPEND out_files "${CMAKE_CURRENT_BINARY_DIR}/${src}") + endforeach(src ${ARGS_DEFAULT_ARGS}) + + add_custom_target( + ${name} ALL DEPENDS ${out_files} + ) +endmacro(erl_target) diff --git a/FindErlang.cmake b/FindErlang.cmake new file mode 100644 index 0000000..e7cb60f --- /dev/null +++ b/FindErlang.cmake @@ -0,0 +1,6 @@ +find_program(ERLC_EXECUTABLE NAMES erlc) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Erlang DEFAULT_MSG ERLC_EXECUTABLE) +mark_as_advanced(ERLC_EXECUTABLE) + |