Link eeschema with ngspice DLL
Adds a link-time dependency for libngspice, so that other tools may detect ngspice as a KiCad dependency. The library is still loaded with dlopen() as it gives a way to reload it in case of problems. The DLL name is recognized during CMake configuration and used to load the library at runtime.
This commit is contained in:
parent
dba32717b1
commit
dd39599903
|
@ -12,6 +12,15 @@ find_library( NGSPICE_LIBRARY ngspice
|
|||
PATH_SUFFIXES src/.libs lib
|
||||
)
|
||||
|
||||
if( WIN32 AND MSYS )
|
||||
# NGSPICE_LIBRARY points to libngspice.dll.a on Windows,
|
||||
# but the goal is to find out the DLL name.
|
||||
find_library( NGSPICE_DLL NAMES libngspice-0.dll libngspice-1.dll )
|
||||
else()
|
||||
set( NGSPICE_DLL "${NGSPICE_LIBRARY}" )
|
||||
endif()
|
||||
|
||||
|
||||
include( FindPackageHandleStandardArgs )
|
||||
|
||||
if( ${NGSPICE_INCLUDE_DIR} STREQUAL "NGSPICE_INCLUDE_DIR-NOTFOUND" OR ${NGSPICE_LIBRARY} STREQUAL "NGSPICE_LIBRARY-NOTFOUND" )
|
||||
|
@ -28,12 +37,10 @@ if( ${NGSPICE_INCLUDE_DIR} STREQUAL "NGSPICE_INCLUDE_DIR-NOTFOUND" OR ${NGSPICE_
|
|||
endif()
|
||||
|
||||
find_package_handle_standard_args( ngspice
|
||||
REQUIRED_VARS
|
||||
NGSPICE_INCLUDE_DIR
|
||||
NGSPICE_LIBRARY
|
||||
)
|
||||
REQUIRED_VARS NGSPICE_INCLUDE_DIR NGSPICE_LIBRARY NGSPICE_DLL )
|
||||
|
||||
mark_as_advanced(
|
||||
NGSPICE_INCLUDE_DIR
|
||||
NGSPICE_LIBRARY
|
||||
NGSPICE_DLL
|
||||
)
|
||||
|
|
|
@ -7,6 +7,15 @@ add_definitions( -DEESCHEMA )
|
|||
|
||||
if( KICAD_SPICE )
|
||||
set( INC_AFTER ${INC_AFTER} ${NGSPICE_INCLUDE_DIR} )
|
||||
|
||||
# Find out the exact libngspice file name
|
||||
get_filename_component( NGSPICE_DLL_REALPATH "${NGSPICE_DLL}" REALPATH )
|
||||
get_filename_component( NGSPICE_DLL_FILE "${NGSPICE_DLL_REALPATH}" NAME )
|
||||
|
||||
set_property( SOURCE sim/ngspice.cpp
|
||||
APPEND PROPERTY COMPILE_DEFINITIONS
|
||||
NGSPICE_DLL_FILE="${NGSPICE_DLL_FILE}"
|
||||
)
|
||||
endif()
|
||||
|
||||
include_directories( BEFORE ${INC_BEFORE} )
|
||||
|
@ -315,6 +324,13 @@ target_link_libraries( eeschema_kiface
|
|||
${wxWidgets_LIBRARIES}
|
||||
${GDI_PLUS_LIBRARIES}
|
||||
)
|
||||
|
||||
if( KICAD_SPICE )
|
||||
target_link_libraries( eeschema_kiface
|
||||
${NGSPICE_LIBRARY}
|
||||
)
|
||||
endif()
|
||||
|
||||
set_target_properties( eeschema_kiface PROPERTIES
|
||||
# Decorate OUTPUT_NAME with PREFIX and SUFFIX, creating something like
|
||||
# _eeschema.so, _eeschema.dll, or _eeschema.kiface
|
||||
|
|
|
@ -289,11 +289,11 @@ void NGSPICE::init_dll()
|
|||
// Extra effort to find libngspice
|
||||
#if defined(__WINDOWS__) || (__WXMAC__)
|
||||
#ifdef __WINDOWS__
|
||||
wxFileName dllFile( "", "libngspice-0.dll" );
|
||||
wxFileName dllFile( "", NGSPICE_DLL_FILE );
|
||||
const vector<string> dllPaths = { "", "/mingw64/bin", "/mingw32/bin" };
|
||||
#endif /* __WINDOWS__ */
|
||||
#ifdef __WXMAC__
|
||||
wxFileName dllFile( "", "libngspice.0.dylib" );
|
||||
wxFileName dllFile( "", NGSPICE_DLL_FILE );
|
||||
const vector<string> dllPaths = {
|
||||
GetOSXKicadUserDataDir() + "/PlugIns/ngspice",
|
||||
GetOSXKicadMachineDataDir() + "/PlugIns/ngspice",
|
||||
|
@ -320,7 +320,7 @@ void NGSPICE::init_dll()
|
|||
if( !m_dll.IsLoaded() ) // try also the system libraries
|
||||
m_dll.Load( wxDynamicLibrary::CanonicalizeName( "ngspice" ) );
|
||||
#else
|
||||
m_dll.Load("libngspice.so.0");
|
||||
m_dll.Load( NGSPICE_DLL_FILE );
|
||||
#endif /* __WINDOWS || __WXMAC__ */
|
||||
|
||||
if( !m_dll.IsLoaded() )
|
||||
|
|
Loading…
Reference in New Issue