2019-08-29 23:36:12 +08:00
|
|
|
if (WIN32)
|
|
|
|
set (CMAKE_SYSTEM_NAME Windows)
|
|
|
|
set (CMAKE_GENERATOR_PLATFORM "x86")
|
2019-08-30 02:18:35 +08:00
|
|
|
elseif(APPLE)
|
|
|
|
set (CMAKE_OSX_ARCHITECTURES "i386")
|
2019-09-05 22:45:25 +08:00
|
|
|
elseif(MINGW)
|
|
|
|
set (CMAKE_SYSTEM_NAME Windows)
|
2020-05-16 02:21:43 +08:00
|
|
|
set (TOOLCHAIN_PREFIX i686-w64-mingw32)
|
|
|
|
set (CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc)
|
|
|
|
set (CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++)
|
|
|
|
set (CMAKE_RC_COMPILER ${TOOLCHAIN_PREFIX}-windres)
|
|
|
|
set (CMAKE_Fortran_COMPILER ${TOOLCHAIN_PREFIX}-gfortran)
|
2019-09-05 22:45:25 +08:00
|
|
|
|
|
|
|
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32" CACHE STRING "c++ flags")
|
|
|
|
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32" CACHE STRING "c flags")
|
|
|
|
|
|
|
|
set (LIB32 /usr/lib) # Fedora
|
|
|
|
|
|
|
|
if (EXISTS "/usr/lib32")
|
|
|
|
set (LIB32 /usr/lib32) # Arch, Solus
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
set (CMAKE_SYSTEM_LIBRARY_PATH ${LIB32} CACHE STRING "system library search path" FORCE)
|
|
|
|
set (CMAKE_LIBRARY_PATH ${LIB32} CACHE STRING "library search path" FORCE)
|
|
|
|
|
|
|
|
# this is probably unlikely to be needed, but just in case
|
|
|
|
set (CMAKE_EXE_LINKER_FLAGS "-m32 -L${LIB32}" CACHE STRING "executable linker flags" FORCE)
|
|
|
|
set (CMAKE_SHARED_LINKER_FLAGS "-m32 -L${LIB32}" CACHE STRING "shared library linker flags" FORCE)
|
|
|
|
set (CMAKE_MODULE_LINKER_FLAGS "-m32 -L${LIB32}" CACHE STRING "module linker flags" FORCE)
|
|
|
|
|
|
|
|
# on Fedora and Arch and similar, point pkgconfig at 32 bit .pc files. We have
|
|
|
|
# to include the regular system .pc files as well (at the end), because some
|
|
|
|
# are not always present in the 32 bit directory
|
|
|
|
if (EXISTS "${LIB32}/pkgconfig")
|
|
|
|
set (ENV{PKG_CONFIG_LIBDIR} ${LIB32}/pkgconfig:/usr/share/pkgconfig:/usr/lib/pkgconfig:/usr/lib64/pkgconfig)
|
|
|
|
endif ()
|
|
|
|
|
2020-05-16 02:21:43 +08:00
|
|
|
set (CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX})
|
2019-09-05 22:45:25 +08:00
|
|
|
set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
|
|
|
set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
|
|
|
set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
2020-05-16 02:21:43 +08:00
|
|
|
set (CMAKE_CROSSCOMPILING_EMULATOR wine)
|
|
|
|
|
|
|
|
include_directories(/usr/${TOOLCHAIN_PREFIX}/include)
|
|
|
|
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS On CACHE BOOL "Export windows symbols")
|
2019-08-29 23:36:12 +08:00
|
|
|
else ()
|
|
|
|
set (CMAKE_SYSTEM_NAME Linux)
|
|
|
|
|
2019-08-30 02:18:35 +08:00
|
|
|
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32" CACHE STRING "c++ flags")
|
|
|
|
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32" CACHE STRING "c flags")
|
2019-08-29 23:36:12 +08:00
|
|
|
|
|
|
|
set (LIB32 /usr/lib) # Fedora
|
|
|
|
|
2019-08-30 03:43:35 +08:00
|
|
|
if (EXISTS "/usr/lib32")
|
2019-08-29 23:36:12 +08:00
|
|
|
set (LIB32 /usr/lib32) # Arch, Solus
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
set (CMAKE_SYSTEM_LIBRARY_PATH ${LIB32} CACHE STRING "system library search path" FORCE)
|
|
|
|
set (CMAKE_LIBRARY_PATH ${LIB32} CACHE STRING "library search path" FORCE)
|
|
|
|
|
|
|
|
# this is probably unlikely to be needed, but just in case
|
|
|
|
set (CMAKE_EXE_LINKER_FLAGS "-m32 -L${LIB32}" CACHE STRING "executable linker flags" FORCE)
|
|
|
|
set (CMAKE_SHARED_LINKER_FLAGS "-m32 -L${LIB32}" CACHE STRING "shared library linker flags" FORCE)
|
|
|
|
set (CMAKE_MODULE_LINKER_FLAGS "-m32 -L${LIB32}" CACHE STRING "module linker flags" FORCE)
|
|
|
|
|
|
|
|
# on Fedora and Arch and similar, point pkgconfig at 32 bit .pc files. We have
|
|
|
|
# to include the regular system .pc files as well (at the end), because some
|
|
|
|
# are not always present in the 32 bit directory
|
2019-08-30 03:43:35 +08:00
|
|
|
if (EXISTS "${LIB32}/pkgconfig")
|
2019-08-29 23:36:12 +08:00
|
|
|
set (ENV{PKG_CONFIG_LIBDIR} ${LIB32}/pkgconfig:/usr/share/pkgconfig:/usr/lib/pkgconfig:/usr/lib64/pkgconfig)
|
|
|
|
endif ()
|
|
|
|
# where is the target environment
|
|
|
|
set (CMAKE_FIND_ROOT_PATH ${LIB32})
|
|
|
|
# search for programs in the build host directories
|
|
|
|
set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
|
|
|
# for libraries and headers in the target directories
|
|
|
|
set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
|
|
|
set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
2020-04-21 07:12:00 +08:00
|
|
|
endif ()
|