Skip to content

Commit

Permalink
CMake: Cleanup MinGW toolchain file
Browse files Browse the repository at this point in the history
  • Loading branch information
bylaws committed Jul 23, 2023
1 parent 56967ae commit 365a696
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions toolchain_mingw.cmake
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
set(MINGW_PATH "" CACHE STRING "Path to an extracted llvm-mingw installation")
set(MINGW_PREFIX "" CACHE STRING "MINGW compiler architecture prefix")
set(MINGW_TRIPLE "" CACHE STRING "MinGW compiler target architecture triple")

set(CMAKE_RC_COMPILER ${MINGW_PATH}/bin/${MINGW_PREFIX}-windres)
set(CMAKE_C_COMPILER ${MINGW_PATH}/bin/${MINGW_PREFIX}-clang)
set(CMAKE_CXX_COMPILER ${MINGW_PATH}/bin/${MINGW_PREFIX}-clang++)
set(CMAKE_SHARED_LINKER_FLAGS "-static -static-libgcc -static-libstdc++ -Wl,--file-alignment=4096,/mllvm:-align-loops=1")
set(CMAKE_EXE_LINKER_FLAGS "-static -static-libgcc -static-libstdc++ -Wl,--file-alignment=4096,/mllvm:-align-loops=1")
set(CMAKE_RC_COMPILER ${MINGW_TRIPLE}-windres)
set(CMAKE_C_COMPILER ${MINGW_TRIPLE}-clang)
set(CMAKE_CXX_COMPILER ${MINGW_TRIPLE}-clang++)

set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_SYSTEM_PROCESSOR ${MINGW_PREFIX})

set(CMAKE_FIND_ROOT_PATH ${MINGW_PATH}/${MINGW_PREFIX})
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
# Compile everything as static to avoid requiring the MinGW runtime libraries, force page aligned sections so that
# debug symbols work correctly, and disable loop alignment to workaround an LLVM bug
# (https://github.com/llvm/llvm-project/issues/47432)
set(CMAKE_SHARED_LINKER_FLAGS_INIT "-static -static-libgcc -static-libstdc++ -Wl,--file-alignment=4096,/mllvm:-align-loops=1")
set(CMAKE_EXE_LINKER_FLAGS_INIT "-static -static-libgcc -static-libstdc++ -Wl,--file-alignment=4096,/mllvm:-align-loops=1")

set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_SYSTEM_PROCESSOR ${MINGW_TRIPLE})

0 comments on commit 365a696

Please sign in to comment.