forked from mstorsjo/llvm-mingw
-
Notifications
You must be signed in to change notification settings - Fork 0
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
3 changed files
with
97 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 AND NOT CMAKE_HOST_WIN32) | ||
set(CMAKE_SYSTEM_NAME Windows) | ||
endif() | ||
if(NOT CMAKE_SYSTEM_PROCESSOR) | ||
set(CMAKE_SYSTEM_PROCESSOR ${CMAKE_HOST_SYSTEM_PROCESSOR}) | ||
if(CMAKE_HOST_WIN32) | ||
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "ARM64") | ||
set(CMAKE_SYSTEM_PROCESSOR aarch64) | ||
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^ARM") | ||
set(CMAKE_SYSTEM_PROCESSOR armv7) | ||
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^[Xx]86$") | ||
set(CMAKE_SYSTEM_PROCESSOR i686) | ||
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "AMD64" OR CMAKE_SYSTEM_PROCESSOR MATCHES "^[Xx]64$") | ||
set(CMAKE_SYSTEM_PROCESSOR x86_64) | ||
endif() | ||
endif() | ||
endif() | ||
|
||
set(CMAKE_SYSROOT "${_prefix}${CMAKE_SYSTEM_PROCESSOR}-w64-mingw32") | ||
|
||
if(NOT "$ENV{PKG_CONFIG_LIBDIR}" STREQUAL "") | ||
set(_respath "${CMAKE_SYSROOT}/lib/pkgconfig:${CMAKE_SYSROOT}/share/pkgconfig:$ENV{PKG_CONFIG_LIBDIR}") | ||
else() | ||
set(_respath "${CMAKE_SYSROOT}/lib/pkgconfig:${CMAKE_SYSROOT}/share/pkgconfig") | ||
endif() | ||
|
||
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.20") | ||
cmake_path(CONVERT _respath TO_NATIVE_PATH_LIST _respath) | ||
set(ENV{PKG_CONFIG_LIBDIR} "${_respath}") | ||
cmake_path(NATIVE_PATH CMAKE_SYSROOT _respath) | ||
set(ENV{PKG_CONFIG_SYSROOT_DIR} "${_respath}") | ||
else() | ||
file(TO_NATIVE_PATH "${_respath}" _respath) | ||
set(ENV{PKG_CONFIG_LIBDIR} "${_respath}") | ||
file(TO_NATIVE_PATH "${CMAKE_SYSROOT}" _respath) | ||
set(ENV{PKG_CONFIG_SYSROOT_DIR} "${_respath}") | ||
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) | ||
|
||
set(_linker lld) | ||
set(_exesuff) | ||
if(CMAKE_HOST_WIN32) | ||
set(_exesuff .exe) | ||
endif() | ||
set(CMAKE_ASM_COMPILER "${_prefix}bin/clang${_exesuff}") | ||
set(CMAKE_C_COMPILER "${_prefix}bin/clang${_exesuff}") | ||
set(CMAKE_CXX_COMPILER "${_prefix}bin/clang++${_exesuff}") | ||
set(CMAKE_RC_COMPILER "${_prefix}bin/llvm-rc${_exesuff}") | ||
set(CMAKE_LINKER "${_prefix}bin/ld.${_linker}${_exesuff}") | ||
unset(_exesuff) | ||
|
||
unset(_prefix) | ||
unset(_respath) | ||
|
||
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() | ||
|
||
# CMAKE_CXX_FLAGS is automatically added now, but might be needed to add -stdlib=libc++ for really old CMake Versions | ||
set(CMAKE_EXE_LINKER_FLAGS_INIT "--start-no-unused-arguments -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,7 @@ | ||
if(NOT CMAKE_SYSTEM_NAME) | ||
set(CMAKE_SYSTEM_NAME Windows) | ||
endif() | ||
|
||
set(CMAKE_SYSTEM_PROCESSOR @ARCH@) | ||
|
||
include("${CMAKE_CURRENT_LIST_DIR}/llvm-mingw_toolchainfile.cmake") |