-
-
Notifications
You must be signed in to change notification settings - Fork 191
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Those toolchain files greatly simplify configuring a project to use the llvm-mingw toolchain.
- Loading branch information
Showing
4 changed files
with
115 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.20") | ||
set(_prefix "${CMAKE_CURRENT_LIST_DIR}/@RELPATH@/") | ||
cmake_path(ABSOLUTE_PATH _prefix NORMALIZE) | ||
else() | ||
get_filename_component(_prefix "${CMAKE_CURRENT_LIST_DIR}/@RELPATH@/" ABSOLUTE) | ||
endif() | ||
|
||
if(NOT CMAKE_SYSTEM_NAME) | ||
set(CMAKE_SYSTEM_NAME Windows) | ||
endif() | ||
if(NOT CMAKE_SYSTEM_PROCESSOR) | ||
set(CMAKE_SYSTEM_PROCESSOR ${CMAKE_HOST_SYSTEM_PROCESSOR}) | ||
endif() | ||
|
||
set(CMAKE_SYSROOT "${_prefix}${CMAKE_SYSTEM_PROCESSOR}-w64-mingw32") | ||
|
||
set(ENV{PKG_CONFIG_SYSROOT_DIR} "${CMAKE_SYSROOT}") | ||
if($ENV{PKG_CONFIG_LIBDIR}) | ||
set(ENV{PKG_CONFIG_LIBDIR} "${CMAKE_SYSROOT}/usr/lib/pkgconfig:${CMAKE_SYSROOT}/usr/share/pkgconfig:$ENV{PKG_CONFIG_LIBDIR}") | ||
else() | ||
set(ENV{PKG_CONFIG_LIBDIR} "${CMAKE_SYSROOT}/usr/lib/pkgconfig:${CMAKE_SYSROOT}/usr/share/pkgconfig") | ||
endif() | ||
|
||
# set these before find_program! | ||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) | ||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) | ||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) | ||
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) | ||
|
||
# search tools in prefix, then in system search paths | ||
# note that the toolchain will be sourced multiple times and stuff like | ||
# CMAKE_C_COMPILER might be cached - use temp variables with find_program | ||
set(_linker lld) | ||
find_program(_clang_exe clang HINTS "${_prefix}bin" NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CACHE ) | ||
find_program(_clangp_exe clang++ HINTS "${_prefix}bin" NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CACHE) | ||
find_program(_llvm_rc llvm-rc HINTS "${_prefix}bin" NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CACHE) | ||
find_program(_ld_linker ld.${_linker} HINTS "${_prefix}bin" NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CACHE) | ||
|
||
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.20") | ||
cmake_path(GET _clang_exe PARENT_PATH _clang_path) | ||
else() | ||
get_filename_component(_clang_path "${_clang_exe}" DIRECTORY) | ||
endif() | ||
|
||
# test if the system compiler is used | ||
if(_clang_path STREQUAL "${_prefix}bin") | ||
set(CMAKE_ASM_COMPILER "${_clang_exe}") | ||
set(CMAKE_C_COMPILER "${_clang_exe}") | ||
set(CMAKE_CXX_COMPILER "${_clangp_exe}") | ||
else() | ||
file(GLOB _respath "${_prefix}lib/clang/*") | ||
|
||
set(CMAKE_ASM_COMPILER "${_clang_exe}" "-resource-dir=${_respath}") | ||
set(CMAKE_C_COMPILER "${_clang_exe}" "-resource-dir=${_respath}") | ||
set(CMAKE_CXX_COMPILER "${_clangp_exe}" "-resource-dir=${_respath}") | ||
endif() | ||
|
||
set(CMAKE_RC_COMPILER "${_llvm_rc}") | ||
set(CMAKE_LINKER "${_ld_linker}") | ||
|
||
unset(_clang_path) | ||
unset(_prefix) | ||
unset(_clang_exe) | ||
unset(_clangp_exe) | ||
unset(_llvm_rc) | ||
unset(_ld_linker) | ||
|
||
set(CMAKE_C_COMPILER_TARGET ${CMAKE_SYSTEM_PROCESSOR}-w64-mingw32) | ||
set(CMAKE_CXX_COMPILER_TARGET ${CMAKE_C_COMPILER_TARGET}) | ||
set(CMAKE_ASM_COMPILER_TARGET ${CMAKE_C_COMPILER_TARGET}) | ||
|
||
set(CMAKE_CXX_FLAGS_INIT "-stdlib=libc++") | ||
|
||
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.29") | ||
string(TOUPPER ${_linker} CMAKE_LINKER_TYPE) | ||
set(_linker) | ||
else() | ||
set(_linker " -fuse-ld=${_linker}") | ||
endif() | ||
|
||
set(CMAKE_EXE_LINKER_FLAGS_INIT "--start-no-unused-arguments -stdlib=libc++ -rtlib=compiler-rt -unwindlib=libunwind --end-no-unused-arguments${_linker}") | ||
set(CMAKE_MODULE_LINKER_FLAGS_INIT "${CMAKE_EXE_LINKER_FLAGS_INIT}") | ||
set(CMAKE_SHARED_LINKER_FLAGS_INIT "${CMAKE_EXE_LINKER_FLAGS_INIT}") | ||
unset(_linker) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
set(CMAKE_SYSTEM_PROCESSOR @ARCH@) | ||
|
||
include("${CMAKE_CURRENT_LIST_DIR}/llvm-mingw_toolchainfile.cmake") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# WindowsStore an UWP app - doesn't seem to have any effect outside of Visual Studio generators | ||
# https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html#cross-compiling-for-windows-10-universal-applications | ||
set(CMAKE_SYSTEM_NAME WindowsStore) | ||
set(CMAKE_SYSTEM_VERSION 10) | ||
set(CMAKE_SYSTEM_PROCESSOR @ARCH@) | ||
|
||
include("${CMAKE_CURRENT_LIST_DIR}/llvm-mingw_toolchainfile.cmake") | ||
|
||
set(CMAKE_C_FLAGS_INIT "-D_WIN32_WINNT=0x0A00 -DWINVER=0x0A00 -DWINAPI_FAMILY=WINAPI_FAMILY_APP -DUNICODE -D_UCRT") | ||
set(CMAKE_CXX_FLAGS_INIT "${CMAKE_CXX_FLAGS_INIT} ${CMAKE_C_FLAGS_INIT}") | ||
set(CMAKE_ASM_FLAGS_INIT "${CMAKE_C_FLAGS_INIT}") | ||
|
||
# Cant extend the content written in CMake's Modules/Platform/Windows-GNU.cmake. Replace it | ||
set(CMAKE_C_STANDARD_LIBRARIES "-lwindowsapp -lucrtapp -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32" CACHE STRING "Libraries linked by default with all C applications" FORCE) | ||
set(CMAKE_CXX_STANDARD_LIBRARIES "-lwindowsapp -lucrtapp -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32" CACHE STRING "Libraries linked by default with all C++ applications" FORCE) |