From 60f4725115653919e9179ad5f01359568e145047 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Thu, 7 Oct 2010 21:02:41 +0200 Subject: Nice dependencies for behaviours --- ErlangTarget.cmake | 83 ++++++++++++++++++++++++++++++++++++++---------------- 1 file 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} ) -- cgit v1.2.3