summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2010-10-07 06:07:03 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2010-10-07 06:07:03 +0200
commit1a935b2f9b2de1d4e49379ea3084e86a47fc409f (patch)
tree7b302eaa6effe920ee20bb28d8f74811fec9cb36
parentecc44209d33f59c7c653b1527253a5cfd7227cec (diff)
downloadcmake-erlang-1a935b2f9b2de1d4e49379ea3084e86a47fc409f.tar
cmake-erlang-1a935b2f9b2de1d4e49379ea3084e86a47fc409f.zip
Added support for dependencies between beam files (for behaviours)
-rw-r--r--ErlangTarget.cmake72
1 files changed, 40 insertions, 32 deletions
diff --git a/ErlangTarget.cmake b/ErlangTarget.cmake
index de5fd92..5562d86 100644
--- a/ErlangTarget.cmake
+++ b/ErlangTarget.cmake
@@ -1,37 +1,45 @@
find_package(Erlang REQUIRED)
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(
+ 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})
+
+ set(before "")
+
+ 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}
- ${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}
- )
+ ${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")
+ endforeach(src ${ARGS_DEFAULT_ARGS})
+
+ add_custom_target(
+ ${name} ALL DEPENDS ${out_files}
+ )
endmacro(erl_target)