aboutsummaryrefslogtreecommitdiff
path: root/kicad.cmake
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2016-07-29 00:39:45 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2016-07-29 00:39:45 +0200
commitc307e9f234e544386fa3ae53083c7510668e1716 (patch)
treebfca2e97330c05cc5d40e3193b2a138eb6c5a963 /kicad.cmake
parentf9c8c5da8de36b0f95bc92e37e15d299b434c03f (diff)
downloadkicad-utils-c307e9f234e544386fa3ae53083c7510668e1716.tar.gz
kicad-utils-c307e9f234e544386fa3ae53083c7510668e1716.tar.bz2
kicad-utils-c307e9f234e544386fa3ae53083c7510668e1716.tar.xz
kicad-utils-c307e9f234e544386fa3ae53083c7510668e1716.zip
o Renaming cmake function from kicad_gen to kicad_generate_header, more to the point.
o Renaming binary from kicad_gen to generate-header too. Should probably be kicad-utils-generate-header or somesuch later. o Moving the cmake code used by the examples into its own file, should be part of the installation target later on.
Diffstat (limited to 'kicad.cmake')
-rw-r--r--kicad.cmake43
1 files changed, 43 insertions, 0 deletions
diff --git a/kicad.cmake b/kicad.cmake
new file mode 100644
index 0000000..f18e6fe
--- /dev/null
+++ b/kicad.cmake
@@ -0,0 +1,43 @@
+function(kicad_generate_header)
+ set(options IN_SOURCE)
+ set(oneValueArgs OUTPUT NET REF OUTPUT_DIR)
+
+ cmake_parse_arguments(kicad_gen "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
+
+ if (NOT kicad_gen_OUTPUT)
+ message(FATAL_ERROR "OUTPUT is required")
+ endif ()
+ set(output "${kicad_gen_OUTPUT}")
+
+ if (NOT kicad_gen_NET)
+ message(FATAL_ERROR "NET is required")
+ endif ()
+ set(NET "${CMAKE_CURRENT_SOURCE_DIR}/${kicad_gen_NET}")
+
+ if (NOT kicad_gen_REF)
+ message(FATAL_ERROR "REF is required")
+ endif ()
+ set(REF "${kicad_gen_REF}")
+
+ if (kicad_gen_OUTPUT_DIR)
+ if (kicad_gen_IN_SOURCE)
+ message(FATAL_ERROR "IN_SOURCE can't be used if OUTPUT_DIR is used")
+ endif ()
+
+ set(output_dir "${kicad_gen_OUTPUT_DIR}")
+ else ()
+ if (kicad_gen_IN_SOURCE)
+ set(output_dir "${CMAKE_CURRENT_SOURCE_DIR}")
+ else ()
+ set(output_dir "${CMAKE_CURRENT_BINARY_DIR}")
+ endif ()
+ endif ()
+
+ set(output_file "${output_dir}/${output}")
+
+ add_custom_command(OUTPUT "${output_file}"
+ COMMAND generate-header -n ${NET} -r ${REF} -o ${output_file}
+ MAIN_DEPENDENCY ${NET}
+ DEPENDS kicad_utils
+ COMMENT "Generating ${output}")
+endfunction()