mingw + cmake + vscode
.vscode
settings.json
{
"cmake.generator": "MinGW Makefiles"
}
cmake-kits.json
[
{
"name": "GCC for x86_64-w64-mingw32 12.2.0",
"compilers": {
"C": "D:\\green\\mingw64\\bin\\gcc.exe",
"CXX": "D:\\green\\mingw64\\bin\\g++.exe"
}
}
]
CMakeLists.txt
cmake_minimum_required(VERSION 2.8.12)
project(hello)
set(MUJS "E:/open_source/mujs")
include_directories(${MUJS})
# set(CMAKE_VERBOSE_MAKEFILE ON)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -std=gnu11 -fexec-charset=GBK")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=gnu++11 -fexec-charset=GBK")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -mwindows")
add_executable(${PROJECT_NAME}
...
)
if (${CMAKE_BUILD_TYPE} STREQUAL "MinSizeRel")
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND strip "$<TARGET_FILE:${PROJECT_NAME}>"
COMMENT "Strip debug symbols done on final binary."
)
endif()