File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -209,21 +209,32 @@ add_executable(cabextract)
209209target_sources (cabextract
210210 PRIVATE
211211 src/cabextract.c
212+ getopt.c getopt.h
213+ getopt1.c
212214 md5.h md5.c )
215+ if (NOT WIN32 )
216+ target_include_directories (cabextract PRIVATE ${PROJECT_SOURCE_DIR} )
217+ else ()
218+ target_include_directories (cabextract PRIVATE ${PROJECT_SOURCE_DIR} ${PROJECT_SOURCE_DIR} /win32 )
219+ target_sources (cabextract PRIVATE win32 /dirent.h )
220+ target_link_libraries (cabextract Shlwapi.lib )
221+ endif ()
213222target_include_directories (cabextract PRIVATE ${PROJECT_SOURCE_DIR} )
214223target_link_libraries (cabextract MSPack::mspack )
215224install (TARGETS cabextract DESTINATION ${CMAKE_INSTALL_BINDIR} )
216225
217- add_executable (cabinfo )
218- target_sources (cabinfo
219- PRIVATE
220- src/cabinfo.c )
221- target_include_directories (cabinfo PRIVATE ${PROJECT_SOURCE_DIR} )
222- target_link_libraries (cabinfo MSPack::mspack )
223-
224- enable_testing ()
225- add_custom_target (check COMMAND ${CMAKE_CTEST_COMMAND} )
226- add_subdirectory (test )
226+ if (NOT WIN32 )
227+ add_executable (cabinfo )
228+ target_sources (cabinfo
229+ PRIVATE
230+ src/cabinfo.c )
231+ target_include_directories (cabinfo PRIVATE ${PROJECT_SOURCE_DIR} )
232+ target_link_libraries (cabinfo MSPack::mspack )
233+
234+ enable_testing ()
235+ add_custom_target (check COMMAND ${CMAKE_CTEST_COMMAND} )
236+ add_subdirectory (test )
237+ endif ()
227238
228239#
229240# The Summary Info.
Original file line number Diff line number Diff line change @@ -160,3 +160,25 @@ cmake --build . --config Release
160160ctest -C Release -V
161161cmake --build . --config Release --target install
162162` ` `
163+
164+ # ### Windows=specific build instructions
165+
166+ A build using the bundled mspack files won' t work on Windows for a couple of reasons. Instead, you can build cabextract on Windows by first building libmspack and then build cabextract using the ENABLE_EXTERNAL_MSPACK option.
167+
168+ In the example below, we use build and link with the static libmspack library so we don' t have to copy mspack.dll into the cabextract.exe directory.
169+
170+ In the libmspack directory:
171+ ` ` ` ps1
172+ mkdir build ; if($? ) {cd build}
173+ cmake -DCMAKE_INSTALL_PREFIX:PATH=install .. -DENABLE_STATIC_LIB=ON
174+ cmake --build . --config Release --target install
175+ ` ` `
176+
177+ Then in the cabextract directory something like this* :
178+ ` ` ` ps1
179+ mkdir build ; if($? ) {cd build}
180+ cmake .. -DENABLE_EXTERNAL_MSPACK=ON -DMSPack_INCLUDE_DIR=" C:\Users\...\libmspack\build\install\include" -DMSPack_LIBRARY=" C:\Users\...\libmspack\install\lib\mspack_static.lib"
181+ cmake --build . --config Debug
182+ .\D ebug\c abextract.exe --help
183+
184+ * Important* : set the ` MSPack_INCLUDE_DIR` and ` MSPack_LIBRARY` variables to your mspack ` include` directory and ` mspack_static.lib` file
Original file line number Diff line number Diff line change 3131#include <ctype.h>
3232#include <dirent.h>
3333#include <errno.h>
34+ #ifndef _WIN32
3435#include <fnmatch.h>
36+ #else
37+ #include <shlwapi.h>
38+ #endif
3539#include <limits.h>
3640#include <locale.h>
3741#include <stdarg.h>
@@ -473,7 +477,11 @@ static int process_cabinet(char *basename) {
473477 int matched = 0 ;
474478 struct filter * f ;
475479 for (f = args .filters ; f ; f = f -> next ) {
480+ #ifndef _WIN32
476481 if (!fnmatch (f -> filter , & name [fname_offset ], FNM_CASEFOLD )) {
482+ #else
483+ if (TRUE == PathMatchSpecA (& name [fname_offset ], f -> filter )) {
484+ #endif
477485 matched = 1 ;
478486 break ;
479487 }
You can’t perform that action at this time.
0 commit comments