From 22649f79e837d8834eab7bb623b7fe66ad888fc9 Mon Sep 17 00:00:00 2001 From: Marek Roszko Date: Mon, 8 Aug 2022 18:41:57 -0400 Subject: [PATCH] Fix some ngspice handling during build for MSVC --- cmake/Findngspice.cmake | 8 ++++++++ eeschema/CMakeLists.txt | 7 +++++++ qa/unittests/eeschema/CMakeLists.txt | 9 +++++++++ 3 files changed, 24 insertions(+) diff --git a/cmake/Findngspice.cmake b/cmake/Findngspice.cmake index 62a9a184eb..f552c48a1d 100644 --- a/cmake/Findngspice.cmake +++ b/cmake/Findngspice.cmake @@ -125,6 +125,14 @@ if( WIN32 AND MSYS ) else() message( STATUS ": libngspice shared lib found: ${NGSPICE_DLL}\n" ) endif() +elseif( WIN32 AND MSVC ) + find_file( NGSPICE_DLL NAMES ngspice.dll + PATHS + ${NGSPICE_ROOT_DIR} + PATH_SUFFIXES + bin + lib + ) else() set( NGSPICE_DLL "${NGSPICE_LIBRARY}" ) endif() diff --git a/eeschema/CMakeLists.txt b/eeschema/CMakeLists.txt index 58ab540186..f81ed1d542 100644 --- a/eeschema/CMakeLists.txt +++ b/eeschema/CMakeLists.txt @@ -474,6 +474,13 @@ if( KICAD_SPICE ) PRIVATE ${NGSPICE_LIBRARY} ) + + if( MSVC ) + # Allow for MSVC to debug ngspice from the build directory + add_custom_command( TARGET eeschema_kiface POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different "${NGSPICE_DLL}" "$" + ) + endif() endif() set_target_properties( eeschema_kiface PROPERTIES diff --git a/qa/unittests/eeschema/CMakeLists.txt b/qa/unittests/eeschema/CMakeLists.txt index 5dac0a87cd..52a1241142 100644 --- a/qa/unittests/eeschema/CMakeLists.txt +++ b/qa/unittests/eeschema/CMakeLists.txt @@ -99,6 +99,7 @@ add_executable( qa_eeschema ) target_link_libraries( qa_eeschema +PRIVATE eeschema_kiface_objects common pcbcommon @@ -110,6 +111,14 @@ target_link_libraries( qa_eeschema ${Boost_LIBRARIES} ) +if( KICAD_SPICE AND MSVC ) + # Allow for MSVC to run from the build directory + add_custom_command( TARGET qa_eeschema POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different "${NGSPICE_DLL}" "$" + ) +endif() + + # Eeschema tests, so pretend to be eeschema (for units, etc) target_compile_definitions( qa_eeschema PUBLIC EESCHEMA