aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2016-08-19 08:06:17 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2016-08-19 08:06:17 +0200
commite4444b71b96c896690817a02cf66199183b68a19 (patch)
tree37d1fc4a80487edc1baec87911ba8c4aabc5f5de
parenta870407b91ef5a38c76bfb975fcc84f7225dd6d2 (diff)
downloadkicad-utils-e4444b71b96c896690817a02cf66199183b68a19.tar.gz
kicad-utils-e4444b71b96c896690817a02cf66199183b68a19.tar.bz2
kicad-utils-e4444b71b96c896690817a02cf66199183b68a19.tar.xz
kicad-utils-e4444b71b96c896690817a02cf66199183b68a19.zip
o Adding complete documentation for the kicad_generate_header goal.
kicad_generate_header: Append the global variable `KICAD_GEN_TEMPLATE_LIBS` to the template search list. o Adding back the examples.
-rw-r--r--CMakeLists.txt2
-rw-r--r--README.md27
-rw-r--r--cmake/KicadUtilsConfig.cmake1
-rw-r--r--cmake/kicad_generate_header.cmake17
-rw-r--r--examples/CMakeLists.txt8
5 files changed, 47 insertions, 8 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 58d3aa4..bc4a12b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -10,4 +10,4 @@ add_subdirectory(python)
add_subdirectory(cli)
add_subdirectory(doc)
-#add_subdirectory(examples)
+add_subdirectory(examples)
diff --git a/README.md b/README.md
index b9a1bdf..d019c9e 100644
--- a/README.md
+++ b/README.md
@@ -34,6 +34,33 @@ Put this in your `CMakeLists.txt`:
and `schematic.h` will automatically be generated. CMake now knows that `schematic.h` is generated and depends on
`schematic/intel-quark-d2000.net`.
+### CMake function usage
+
+Usage:
+
+ kicad_generate_header(
+ NET <netlist> (Required)
+ OUTPUT <file name> (Required)
+ REF <netlist reference> (Required)
+ TEMPLATE <template name> (Required)
+ OUTPUT_DIR <output base directory>
+ TEMPLATE_LIB_LIST <template library search path>
+ TARGET <target name>
+ ALL
+ IN_SOURCE
+ )
+
+
+The `OUTPUT_DIR` defaults to `CMAKE_CURRENT_BINARY_DIR` unless `IN_SOURCE` is given. If so, it defaults to
+`CMAKE_CURRENT_SOURCE_DIR`.
+
+If `TARGET` is set a CMake target with the given name is created. If `ALL` is specified this target will be a part of
+the CMake `ALL` target. See the documentation for `add_custom_target`'s `ALL` option.
+
+`TEMPLATE_LIB_LIST` is a list of directories that will be searched for the template. The global variable
+`KICAD_GEN_TEMPLATE_LIBS` will be appended to the library list if set.
+
+
# Templates
The templates are simply Python files that map from the part's pin number to a platform-specific symbol. The
diff --git a/cmake/KicadUtilsConfig.cmake b/cmake/KicadUtilsConfig.cmake
index 1cb682d..a2e6419 100644
--- a/cmake/KicadUtilsConfig.cmake
+++ b/cmake/KicadUtilsConfig.cmake
@@ -1,3 +1,4 @@
+set(kicad_generate_header_cmd KicadUtils::generate-header)
include("${CMAKE_CURRENT_LIST_DIR}/kicad_generate_header.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/kicad_pcb_plot.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/KicadUtilsTargets.cmake")
diff --git a/cmake/kicad_generate_header.cmake b/cmake/kicad_generate_header.cmake
index 0514a34..bf7ad2e 100644
--- a/cmake/kicad_generate_header.cmake
+++ b/cmake/kicad_generate_header.cmake
@@ -41,19 +41,26 @@ function(kicad_generate_header)
set(template "${kicad_gen_TEMPLATE}")
endif ()
- set(lib "-l;${CMAKE_CURRENT_SOURCE_DIR}")
- foreach (l IN LISTS kicad_gen_TEMPLATE_LIB_LIST)
- list(APPEND lib -l "${l}")
- endforeach ()
+ if (kicad_gen_TEMPLATE_LIB_LIST)
+ foreach (l IN LISTS kicad_gen_TEMPLATE_LIB_LIST)
+ list(APPEND lib -l "${l}")
+ endforeach ()
+ endif ()
+ if (KICAD_GEN_TEMPLATE_LIBS)
+ foreach (l IN LISTS KICAD_GEN_TEMPLATE_LIBS)
+ list(APPEND lib -l "${l}")
+ endforeach ()
+ endif ()
set(output_file "${output_dir}/${output}")
file(RELATIVE_PATH output_file_rel "${output_rel_dir}" ${output_file})
# message("kicad_generate_header: output_file=${output_file}")
# message("kicad_generate_header: output_file_rel=${output_file_rel}")
+ message("kicad_generate_header: kicad_generate_header_cmd=${kicad_generate_header_cmd}")
add_custom_command(OUTPUT "${output_file}"
- COMMAND KicadUtils::generate-header -n ${NET} -r ${REF} -o ${output_file} ${t} ${template} ${lib}
+ COMMAND ${kicad_generate_header_cmd} -n ${NET} -r ${REF} -o ${output_file} ${t} ${template} ${lib}
MAIN_DEPENDENCY ${NET}
COMMENT "Generating ${output_file_rel}")
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index 2cb3286..daa2b4d 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -8,7 +8,11 @@ if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
if (NOT KicadUtils_FOUND)
message(FATAL_ERROR "The KicadUtils CMake package was not found. Did you pass the correct value for KicadUtils_DIR?\nIt should probably be something like KicadUtils_DIR=$HOME/opt/kicad-utils/lib/cmake/KicadUtils")
endif ()
+else ()
+ include(../cmake/kicad_generate_header.cmake)
+ list(APPEND KICAD_GEN_TEMPLATE_LIBS ${CMAKE_CURRENT_SOURCE_DIR}/../templates)
+ set(kicad_generate_header_cmd generate-header)
endif ()
-#add_subdirectory(arduino-led)
-#add_subdirectory(intel-quark-d2000)
+add_subdirectory(arduino-led)
+add_subdirectory(intel-quark-d2000)