Skip to content

Commit 39b3e8e

Browse files
BerrysoftGit for Windows Build Agent
authored and
Git for Windows Build Agent
committed
cmake: Use correct link option for gcc ld in MinGW.
While MSVC needs to specify entry as `wWinMainCRTStartup`, MinGW needs `-municode`. MinGW used to not support `wWinMain`, but recently it finally adds support for that. The support for clang is more complicated. This code was tested on MinGW clang, provided by MSYS2 clang64, and it worked successfully. Further investigation may be needed. Signed-off-by: Yuyi Wang <[email protected]>
1 parent 64862b0 commit 39b3e8e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

contrib/buildsystems/CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,13 @@ if(WIN32)
733733
endif()
734734

735735
add_executable(headless-git ${CMAKE_SOURCE_DIR}/compat/win32/headless.c)
736-
target_link_options(headless-git PUBLIC /NOLOGO /ENTRY:wWinMainCRTStartup /SUBSYSTEM:WINDOWS)
736+
if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
737+
target_link_options(headless-git PUBLIC -municode -Wl,-subsystem,windows)
738+
elseif(CMAKE_C_COMPILER_ID STREQUAL "MSVC")
739+
target_link_options(headless-git PUBLIC /NOLOGO /ENTRY:wWinMainCRTStartup /SUBSYSTEM:WINDOWS)
740+
else()
741+
message(FATAL_ERROR "Unhandled compiler: ${CMAKE_C_COMPILER_ID}")
742+
endif()
737743
elseif(UNIX)
738744
target_link_libraries(common-main pthread rt)
739745
endif()

0 commit comments

Comments
 (0)