(Windows) Made es-pdf-convert build with MinGW

This commit is contained in:
Leon Styhre 2023-06-23 15:23:14 +02:00
parent f9780e58d8
commit 07f98f1737
2 changed files with 16 additions and 4 deletions

View file

@ -9,9 +9,14 @@
project(es-pdf-convert) project(es-pdf-convert)
if(WIN32) if(WIN32)
set(POPPLER_CPP_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../external/poppler-23.05.0/Library/include/poppler/cpp) set(POPPLER_CPP_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../external/poppler/Library/include/poppler/cpp)
set(POPPLER_CPP_LIBRARY ${CMAKE_CURRENT_SOURCE_DIR}/poppler-cpp.lib) if(CMAKE_CXX_COMPILER_ID MATCHES MSVC)
else() set(POPPLER_CPP_LIBRARY ${CMAKE_CURRENT_SOURCE_DIR}/poppler-cpp.lib)
else()
set(POPPLER_CPP_LIBRARY ${CMAKE_CURRENT_SOURCE_DIR}/libpoppler-cpp-0.dll)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -municode")
endif()
else()
find_package(Poppler REQUIRED COMPONENTS cpp) find_package(Poppler REQUIRED COMPONENTS cpp)
endif() endif()

View file

@ -25,8 +25,15 @@
#include <io.h> #include <io.h>
#include <windows.h> #include <windows.h>
#if defined(_MSC_VER) // MSVC compiler.
int wmain(int argc, wchar_t* argv[]) int wmain(int argc, wchar_t* argv[])
{ {
#else
int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow)
{
wchar_t** argv {__wargv};
int argc = __argc;
#endif
HANDLE stdoutHandle {GetStdHandle(STD_OUTPUT_HANDLE)}; HANDLE stdoutHandle {GetStdHandle(STD_OUTPUT_HANDLE)};
if (stdoutHandle == INVALID_HANDLE_VALUE) { if (stdoutHandle == INVALID_HANDLE_VALUE) {
@ -111,7 +118,7 @@ int main(int argc, char* argv[])
std::ifstream file; std::ifstream file;
file.open(path, std::ifstream::binary); file.open(path.c_str(), std::ifstream::binary);
if (file.fail()) { if (file.fail()) {
std::cerr << "Error: Couldn't open PDF file, permission problems?" << std::endl; std::cerr << "Error: Couldn't open PDF file, permission problems?" << std::endl;
exit(-1); exit(-1);