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