diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2010-10-07 21:02:41 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2010-10-07 21:02:41 +0200 |
commit | 60f4725115653919e9179ad5f01359568e145047 (patch) | |
tree | c7633aa2ca8293f728b214ee8a847a293badf3a3 | |
parent | 1a935b2f9b2de1d4e49379ea3084e86a47fc409f (diff) | |
download | cmake-erlang-master.tar cmake-erlang-master.zip |
-rw-r--r-- | ErlangTarget.cmake | 83 |
1 files changed, 58 insertions, 25 deletions
diff --git a/ErlangTarget.cmake b/ErlangTarget.cmake index 5562d86..305ee2c 100644 --- a/ErlangTarget.cmake +++ b/ErlangTarget.cmake @@ -10,35 +10,68 @@ macro(erl_target name) list(APPEND headers "${CMAKE_CURRENT_SOURCE_DIR}/${header}") endforeach(header ${ARGS_HEADERS}) - set(before "") + set(deps "") + set(current "") + set(uses false) foreach(src ${ARGS_DEFAULT_ARGS}) - if(src STREQUAL "BEFORE") - set(before ${out_files}) - else(src STREQUAL "BEFORE") - 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} - "-pz" ${CMAKE_CURRENT_BINARY_DIR} - ${ARGS_OPTIONS} - ${in_file} - DEPENDS - ${in_file} - ${headers} - ${before} - ) - - list(APPEND out_files "${CMAKE_CURRENT_BINARY_DIR}/${src}") - endif(src STREQUAL "BEFORE") + if(src STREQUAL "USING") + set(uses true) + else(src STREQUAL "USING") + if(uses) + list(APPEND deps "${CMAKE_CURRENT_BINARY_DIR}/${src}.beam") + set(uses false) + else(uses) + if(current) + set(in_file "${CMAKE_CURRENT_SOURCE_DIR}/${current}") + string(REPLACE ".erl" ".beam" current ${current}) + set(out_file "${CMAKE_CURRENT_BINARY_DIR}/${current}") + + add_custom_command( + OUTPUT + ${out_file} + COMMAND + ${ERLC_EXECUTABLE} + "-o" ${CMAKE_CURRENT_BINARY_DIR} + "-pz" ${CMAKE_CURRENT_BINARY_DIR} + ${ARGS_OPTIONS} + ${in_file} + DEPENDS + ${in_file} + ${headers} + ${deps} + ) + + list(APPEND out_files "${CMAKE_CURRENT_BINARY_DIR}/${current}") + endif(current) + + set(current ${src}) + set(deps "") + endif(uses) + endif(src STREQUAL "USING") endforeach(src ${ARGS_DEFAULT_ARGS}) + set(in_file "${CMAKE_CURRENT_SOURCE_DIR}/${current}") + string(REPLACE ".erl" ".beam" current ${current}) + set(out_file "${CMAKE_CURRENT_BINARY_DIR}/${current}") + + add_custom_command( + OUTPUT + ${out_file} + COMMAND + ${ERLC_EXECUTABLE} + "-o" ${CMAKE_CURRENT_BINARY_DIR} + "-pz" ${CMAKE_CURRENT_BINARY_DIR} + ${ARGS_OPTIONS} + ${in_file} + DEPENDS + ${in_file} + ${headers} + ${deps} + ) + + list(APPEND out_files "${CMAKE_CURRENT_BINARY_DIR}/${current}") + add_custom_target( ${name} ALL DEPENDS ${out_files} ) |