aboutsummaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2016-08-01 08:20:23 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2016-08-01 08:20:23 +0200
commitbfeeac6e4889d1e9a1083b3c7efc59652981b168 (patch)
treea937d844a59da7c509685dcd1ddd9933772e526f /cmake
parentc307e9f234e544386fa3ae53083c7510668e1716 (diff)
downloadkicad-utils-bfeeac6e4889d1e9a1083b3c7efc59652981b168.tar.gz
kicad-utils-bfeeac6e4889d1e9a1083b3c7efc59652981b168.tar.bz2
kicad-utils-bfeeac6e4889d1e9a1083b3c7efc59652981b168.tar.xz
kicad-utils-bfeeac6e4889d1e9a1083b3c7efc59652981b168.zip
o Moving the generation logic to Python, embedding a Python interpreter with the help of pybind11.
o Adding install configuration to CMake to make it easier to reuse the project later on. o Splitting out the examples into its own project to make it easier to test the whole installation setup and python/template loading. o Trying to reorganize the code a bit, not very much better yet.
Diffstat (limited to 'cmake')
-rw-r--r--cmake/KicadUtilsConfig.cmake2
-rw-r--r--cmake/kicad_generate_header.cmake57
2 files changed, 59 insertions, 0 deletions
diff --git a/cmake/KicadUtilsConfig.cmake b/cmake/KicadUtilsConfig.cmake
new file mode 100644
index 0000000..2302fe2
--- /dev/null
+++ b/cmake/KicadUtilsConfig.cmake
@@ -0,0 +1,2 @@
+include("${CMAKE_CURRENT_LIST_DIR}/kicad_generate_header.cmake")
+include("${CMAKE_CURRENT_LIST_DIR}/KicadUtilsTargets.cmake")
diff --git a/cmake/kicad_generate_header.cmake b/cmake/kicad_generate_header.cmake
new file mode 100644
index 0000000..930c5ed
--- /dev/null
+++ b/cmake/kicad_generate_header.cmake
@@ -0,0 +1,57 @@
+function(kicad_generate_header)
+ set(options IN_SOURCE)
+ set(oneValueArgs OUTPUT NET REF OUTPUT_DIR TEMPLATE TEMPLATE_LIB_LIST)
+
+ 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}")
+ set(output_rel_dir "${output_dir}")
+ else ()
+ if (kicad_gen_IN_SOURCE)
+ set(output_dir "${CMAKE_CURRENT_SOURCE_DIR}")
+ set(output_rel_dir "${CMAKE_SOURCE_DIR}")
+ else ()
+ set(output_dir "${CMAKE_CURRENT_BINARY_DIR}")
+ set(output_rel_dir "${CMAKE_BINARY_DIR}")
+ endif ()
+ endif ()
+
+ if (kicad_gen_TEMPLATE)
+ set(t "-t")
+ 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)
+ list(APPEND lib "${l}")
+ endforeach ()
+
+ set(output_file "${output_dir}/${output}")
+ file(RELATIVE_PATH output_file_rel "${output_rel_dir}" ${output_file})
+
+ add_custom_command(OUTPUT "${output_file}"
+ COMMAND KicadUtils::generate-header -n ${NET} -r ${REF} -o ${output_file} ${t} ${template} ${lib}
+ MAIN_DEPENDENCY ${NET}
+ COMMENT "Generating ${output_file_rel}")
+endfunction()