With the following steps, we will manage to cross-compile an OpenMP-parallelized Windows executable:
- Create a directory holding example.cpp and CMakeLists.txt, which we listed previously.
- We will use the same toolchain.cmake as in the previous recipe:
# the name of the target operating systemset(CMAKE_SYSTEM_NAME Windows)# which compilers to useset(CMAKE_CXX_COMPILER i686-w64-mingw32-g++)# adjust the default behaviour of the find commands:# search headers and libraries in the target environmentset(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)# search programs in the host environmentset(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
- Adjust the CMAKE_CXX_COMPILER to the corresponding compiler (path). ...