Created
March 21, 2020 18:45
-
-
Save HiImJulien/3eb47d7d874fe5483810bd77940e74c0 to your computer and use it in GitHub Desktop.
Toolchain file to cross-compile from clang (WSL-Ubuntu) to Windows.
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
# Cross toolchain configuration for using clang-cl. | |
set(CMAKE_SYSTEM_NAME Windows) | |
set(CMAKE_SYSTEM_VERSION 10.0) | |
set(CMAKE_SYSTEM_PROCESSOR AMD64) | |
set(CMAKE_C_COMPILER "/usr/bin/clang-cl-9") | |
set(CMAKE_CXX_COMPILER "/usr/bin/clang-cl-9") | |
set(CMAKE_LINKER "/usr/bin/lld-link-9") | |
set(MSVC_BASE "/mnt/c/Program\ Files\ \(x86\)/Microsoft\ Visual\ Studio/2019/Community/VC/Tools/MSVC/14.23.28105") | |
set(MSVC_INCLUDE "${MSVC_BASE}/include") | |
set(MSVC_LIB "${MSVC_BASE}/lib") | |
set(WINSDK_BASE "/mnt/c/Program\ Files\ \(x86\)/Windows\ Kits/10") | |
set(WINSDK_VER "10.0.18362.0") | |
set(WINSDK_INCLUDE "${WINSDK_BASE}/Include/${WINSDK_VER}") | |
set(WINSDK_LIB "${WINSDK_BASE}/lib/${WINSDK_VER}") | |
set(COMPILE_FLAGS | |
-D_CRT_SECURE_NO_WARNINGS | |
-imsvc "'${MSVC_INCLUDE}'" | |
-imsvc "'${WINSDK_INCLUDE}/ucrt'" | |
-imsvc "'${WINSDK_INCLUDE}/shared'" | |
-imsvc "'${WINSDK_INCLUDE}/um'" | |
-imsvc "'${WINSDK_INCLUDE}/winrt'" | |
) | |
string(REPLACE ";" " " COMPILE_FLAGS "${COMPILE_FLAGS}") | |
set(_CMAKE_C_FLAGS_INITIAL "${CMAKE_C_FLAGS}" CACHE STRING "") | |
set(CMAKE_C_FLAGS "${_CMAKE_C_FLAGS_INITIAL} ${COMPILE_FLAGS}" CACHE STRING "" FORCE) | |
set(_CMAKE_CXX_FLAGS_INITIAL "${CMAKE_C_FLAGS}" CACHE STRING "") | |
set(CMAKE_CXX_FLAGS "${_CMAKE_CXX_FLAGS_INITIAL} ${COMPILE_FLAGS}" CACHE STRING "" FORCE) | |
set(LINK_FLAGS | |
/manifest:no | |
-libpath:"${MSVC_LIB}/x64" | |
-libpath:"${WINSDK_LIB}/ucrt/x64" | |
-libpath:"${WINSDK_LIB}/um/x64" | |
) | |
string(REPLACE ";" " " LINK_FLAGS "${LINK_FLAGS}") | |
set(_CMAKE_EXE_LINKER_FLAGS_INITIAL "${CMAKE_EXE_LINKER_FLAGS}" CACHE STRING "") | |
set(CMAKE_EXE_LINKER_FLAGS "${_CMAKE_EXE_LINKER_FLAGS_INITIAL} ${LINK_FLAGS}" CACHE STRING "" FORCE) | |
set(_CMAKE_MODULE_LINKER_FLAGS_INITIAL "${CMAKE_MODULE_LINKER_FLAGS}" CACHE STRING "") | |
set(CMAKE_MODULE_LINKER_FLAGS "${_CMAKE_MODULE_LINKER_FLAGS_INITIAL} ${LINK_FLAGS}" CACHE STRING "" FORCE) | |
set(_CMAKE_SHARED_LINKER_FLAGS_INITIAL "${CMAKE_SHARED_LINKER_FLAGS}" CACHE STRING "") | |
set(CMAKE_SHARED_LINKER_FLAGS "${_CMAKE_SHARED_LINKER_FLAGS_INITIAL} ${LINK_FLAGS}" CACHE STRING "" FORCE) | |
set(CMAKE_C_STANDARD_LIBRARIES "" CACHE STRING "" FORCE) | |
set(CMAKE_CXX_STANDARD_LIBRARIES "" CACHE STRING "" FORCE) | |
set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS ON) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Maybe it should be
set(_CMAKE_CXX_FLAGS_INITIAL "${CMAKE_CXX_FLAGS}" CACHE STRING "")
?