1# Copyright (c) 2021-2022 Huawei Device Co., Ltd. 2# Licensed under the Apache License, Version 2.0 (the "License"); 3# you may not use this file except in compliance with the License. 4# You may obtain a copy of the License at 5# 6# http://www.apache.org/licenses/LICENSE-2.0 7# 8# Unless required by applicable law or agreed to in writing, software 9# distributed under the License is distributed on an "AS IS" BASIS, 10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11# See the License for the specific language governing permissions and 12# limitations under the License. 13 14set(PANDA_TRIPLET x86_64-w64-mingw32) 15set(PANDA_SYSROOT /usr/${PANDA_TRIPLET}) 16 17set(CMAKE_SYSTEM_NAME Windows) 18set(CMAKE_SYSTEM_PROCESSOR x86_64) 19set(CMAKE_PREFIX_PATH ${PANDA_SYSROOT}) 20set(CMAKE_C_COMPILER_TARGET ${PANDA_TRIPLET}) 21set(CMAKE_CXX_COMPILER_TARGET ${PANDA_TRIPLET}) 22 23# NB! Do not use "win32" threading model, it does not provide 24# std::thread and std::mutex. Use "posix" instead. 25set(MINGW_THREADING_MODEL posix) 26set(MINGW_CXX_BIN_NAME ${PANDA_TRIPLET}-g++-${MINGW_THREADING_MODEL}) 27 28find_program(MINGW_CXX_BIN ${MINGW_CXX_BIN_NAME}) 29if("${MINGW_CXX_BIN}" STREQUAL "MINGW_CXX_BIN-NOTFOUND") 30 message(FATAL_ERROR "Unable to find MinGW ${MINGW_CXX_BIN_NAME}") 31endif() 32 33execute_process(COMMAND ${MINGW_CXX_BIN} -dumpversion 34 OUTPUT_VARIABLE MINGW_VERSION 35 OUTPUT_STRIP_TRAILING_WHITESPACE) 36 37set(MINGW_CXX_INC /usr/lib/gcc/${PANDA_TRIPLET}/${MINGW_VERSION}/include/c++) 38 39add_compile_options( 40 -isystem ${MINGW_CXX_INC} 41 -I ${MINGW_CXX_INC}/${PANDA_TRIPLET} # For #include <bits/...> 42 --sysroot=${PANDA_SYSROOT} 43 --target=${PANDA_TRIPLET} 44) 45 46# NB! For Windows we link everything statically (incl. standard library, pthread, etc.): 47set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L/usr/lib/gcc/${PANDA_TRIPLET}/${MINGW_VERSION} -static-libstdc++ -static-libgcc -Wl,-Bstatic") 48 49include(${CMAKE_CURRENT_LIST_DIR}/common.cmake) 50set_c_compiler(clang-9) 51set_cxx_compiler(clang++-9) 52