diff --git a/utils/kicad2step/CMakeLists.txt b/utils/kicad2step/CMakeLists.txt index bdfff33903..a60153f424 100644 --- a/utils/kicad2step/CMakeLists.txt +++ b/utils/kicad2step/CMakeLists.txt @@ -1,13 +1,14 @@ include_directories( BEFORE - pcb - ${CMAKE_CURRENT_SOURCE_DIR} + pcb + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_SOURCE_DIR}/include ) include_directories( SYSTEM ${OCE_INCLUDE_DIRS} ) -add_executable( kicad2step +set( K2S_FILES kicad2step.cpp pcb/3d_resolver.cpp pcb/base.cpp @@ -21,6 +22,12 @@ add_executable( kicad2step sexpr/sexpr_parser.cpp ) +if( MINGW ) + list( APPEND K2S_FILES ${CMAKE_SOURCE_DIR}/common/streamwrapper.cpp ) +endif( MINGW ) + +add_executable( kicad2step ${K2S_FILES} ) + target_link_libraries( kicad2step ${wxWidgets_LIBRARIES} ${LIBS_OCE} ) if( APPLE ) diff --git a/utils/kicad2step/pcb/kicadmodule.cpp b/utils/kicad2step/pcb/kicadmodule.cpp index 532b02c9c7..03ffff4157 100644 --- a/utils/kicad2step/pcb/kicadmodule.cpp +++ b/utils/kicad2step/pcb/kicadmodule.cpp @@ -360,7 +360,8 @@ bool KICADMODULE::ComposePCB( class PCBMODEL* aPCB, S3D_RESOLVER* resolver, for( auto i : m_models ) { - std::string fname( resolver->ResolvePath( i->m_modelname.c_str() ).ToUTF8() ); + std::string fname( resolver->ResolvePath( + wxString::FromUTF8Unchecked( i->m_modelname.c_str() ) ).ToUTF8() ); if( aPCB->AddComponent( fname, m_refdes, LAYER_BOTTOM == m_side ? true : false, newpos, m_rotation, i->m_offset, i->m_rotation ) ) diff --git a/utils/kicad2step/pcb/oce_utils.cpp b/utils/kicad2step/pcb/oce_utils.cpp index 8fa45cb040..cce6d1fd20 100644 --- a/utils/kicad2step/pcb/oce_utils.cpp +++ b/utils/kicad2step/pcb/oce_utils.cpp @@ -31,6 +31,7 @@ #include "oce_utils.h" #include "kicadpad.h" +#include "streamwrapper.h" #include #include @@ -153,7 +154,7 @@ enum FormatType FormatType fileType( const char* aFileName ) { - wxFileName lfile( aFileName ); + wxFileName lfile( wxString::FromUTF8Unchecked( aFileName ) ); if( !lfile.FileExists() ) { @@ -172,16 +173,15 @@ FormatType fileType( const char* aFileName ) else if( ext == "emn" || ext == "EMN" ) return FMT_EMN; // PCB assembly - std::ifstream ifile; - ifile.open( aFileName ); + OPEN_ISTREAM( ifile, aFileName ); - if( !ifile.is_open() ) + if( ifile.fail() ) return FMT_NONE; char iline[82]; memset( iline, 0, 82 ); ifile.getline( iline, 82 ); - ifile.close(); + CLOSE_STREAM( ifile ); iline[81] = 0; // ensure NULL termination when string is too long // check for STEP in Part 21 format