1d4afb5ceSopenharmony_ci# 2d4afb5ceSopenharmony_ci# CMake Toolchain file for crosscompiling on 32bit Windows platforms. 3d4afb5ceSopenharmony_ci# 4d4afb5ceSopenharmony_ci# This can be used when running cmake in the following way: 5d4afb5ceSopenharmony_ci# cd build/ 6d4afb5ceSopenharmony_ci# cmake .. -DCMAKE_TOOLCHAIN_FILE=../contrib/cross-w32.cmake -DLWS_WITH_SSL=0 7d4afb5ceSopenharmony_ci# 8d4afb5ceSopenharmony_ci 9d4afb5ceSopenharmony_ci# the outermost path to your cross toolchain 10d4afb5ceSopenharmony_ci#set(CROSS_PATH /opt/mingw32) 11d4afb5ceSopenharmony_ciset(CROSS_PATH /usr) 12d4afb5ceSopenharmony_ci# your cross root 13d4afb5ceSopenharmony_ciset(CROSS_ROOT ${CROSS_PATH}/i686-w64-mingw32/sys-root/) 14d4afb5ceSopenharmony_ci 15d4afb5ceSopenharmony_ci# Target operating system name. 16d4afb5ceSopenharmony_ciset(CMAKE_SYSTEM_NAME Windows) 17d4afb5ceSopenharmony_ci 18d4afb5ceSopenharmony_ci# Name of C compiler. 19d4afb5ceSopenharmony_ciset(CMAKE_C_COMPILER "${CROSS_PATH}/bin/i686-w64-mingw32-gcc") 20d4afb5ceSopenharmony_ciset(CMAKE_CXX_COMPILER "${CROSS_PATH}/bin/i686-w64-mingw32-g++") 21d4afb5ceSopenharmony_ciset(CMAKE_RC_COMPILER "${CROSS_PATH}/bin/i686-w64-mingw32-windres") 22d4afb5ceSopenharmony_ci 23d4afb5ceSopenharmony_ci# 24d4afb5ceSopenharmony_ci# Different build system distros set release optimization level to different 25d4afb5ceSopenharmony_ci# things according to their local policy, eg, Fedora is -O2 and Ubuntu is -O3 26d4afb5ceSopenharmony_ci# here. Actually the build system's local policy is completely unrelated to 27d4afb5ceSopenharmony_ci# our desire for cross-build release optimization policy for code built to run 28d4afb5ceSopenharmony_ci# on a completely different target than the build system itself. 29d4afb5ceSopenharmony_ci# 30d4afb5ceSopenharmony_ci# Since this goes last on the compiler commandline we have to override it to a 31d4afb5ceSopenharmony_ci# sane value for cross-build here. Notice some gcc versions enable broken 32d4afb5ceSopenharmony_ci# optimizations with -O3. 33d4afb5ceSopenharmony_ci# 34d4afb5ceSopenharmony_ciif (CMAKE_BUILD_TYPE MATCHES RELEASE OR CMAKE_BUILD_TYPE MATCHES Release OR CMAKE_BUILD_TYPE MATCHES release) 35d4afb5ceSopenharmony_ci set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O2") 36d4afb5ceSopenharmony_ci set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2") 37d4afb5ceSopenharmony_ciendif() 38d4afb5ceSopenharmony_ci 39d4afb5ceSopenharmony_ci# Where to look for the target environment. (More paths can be added here) 40d4afb5ceSopenharmony_ciset(CMAKE_FIND_ROOT_PATH "${CROSS_ROOT}/mingw") 41d4afb5ceSopenharmony_ciset(CMAKE_SYSROOT ${CROSS_ROOT}) 42d4afb5ceSopenharmony_ci 43d4afb5ceSopenharmony_ci# Adjust the default behavior of the FIND_XXX() commands: 44d4afb5ceSopenharmony_ci# search programs in the host environment only. 45d4afb5ceSopenharmony_ciset(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 46d4afb5ceSopenharmony_ci 47d4afb5ceSopenharmony_ci# Search headers and libraries in the target environment only. 48d4afb5ceSopenharmony_ciset(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 49d4afb5ceSopenharmony_ciset(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 50