[CMake] How to Compile with -municode for MinGW-w64

R0b0t1 r030t1 at gmail.com
Tue May 29 22:33:36 EDT 2018


Hello,

I pass -municode in add_definitions but GCC still complains about the
wrong type on WinMain, citing it needs an LPSTR argument. With
-municode set it should require a LPWSTR and should be named wWinMain.
If I name the function wWinMain the linker complains about a missing
WinMain, which makes no sense. This works when I create a Makefile
myself.

CMakeLists.txt as follows.

cmake_minimum_required (VERSION 3.5)
project (mtktool)

list (
  APPEND
  CMAKE_MODULE_PATH
  "${CMAKE_CURRENT_LIST_DIR}/cmake"
)

set (mtktool_VERSION_MAJOR 0)
set (mtktool_VERSION_MINOR 0)
set (mtktool_VERSION_PATCH 0)

configure_file (
  "${PROJECT_SOURCE_DIR}/config.h.in"
  "${PROJECT_SOURCE_DIR}/config.h"
)

include_directories (
  "${CMAKE_CURRENT_SOURCE_DIR}"
)

add_definitions (
  -municode
  -mwindows
)

add_executable (
  mtktool
  mtktool.c
)

Cheers,
     R0b0t1


More information about the CMake mailing list