mirror of
https://github.com/ceph/ceph
synced 2024-12-28 22:43:29 +00:00
d15481f1a5
We'll update the cmake files in order to be able to build ceph components for Windows targets. Cross compiling using MINGW is the easiest approach for now. Subsequently, we'll add support for Clang and MSVC. This patch provides the following changes: * include winsock2.h, which provides ntohl on Windows * avoid unsupported compiler flags when using msvc * add a custom toolchain file for mingw * update install command for ceph-common in order to work with mingw * avoid running test sample when cross compiling * link against the ws_32 lib * set argeted Windows version * skip yasm checks when targeting Windows * allow multiple redefinitions when using mingw, picking the first one. this is a workaround for a mingw TLS bug: https://sourceforge.net/p/mingw-w64/bugs/816/ Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com> Signed-off-by: Lucian Petrut <lpetrut@cloudbasesolutions.com>
25 lines
977 B
CMake
25 lines
977 B
CMake
set(CMAKE_SYSTEM_NAME Windows)
|
|
set(TOOLCHAIN_PREFIX x86_64-w64-mingw32)
|
|
set(CMAKE_SYSTEM_PROCESSOR x86_64)
|
|
|
|
# We'll need to use posix threads in order to use
|
|
# C++11 features, such as std::thread.
|
|
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc-posix)
|
|
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++-posix)
|
|
set(CMAKE_RC_COMPILER ${TOOLCHAIN_PREFIX}-windres)
|
|
|
|
set(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX} /usr/lib/gcc/${TOOLCHAIN_PREFIX}/7.3-posix)
|
|
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
|
# TODO: consider switching this to "ONLY". The issue with
|
|
# that is that all our libs should then be under
|
|
# CMAKE_FIND_ROOT_PATH and CMAKE_PREFIX_PATH would be ignored.
|
|
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH)
|
|
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH)
|
|
|
|
# Some functions (e.g. localtime_r) will not be available unless we set
|
|
# the following flag.
|
|
add_definitions(-D_POSIX=1)
|
|
add_definitions(-D_POSIX_C_SOURCE=1)
|
|
add_definitions(-D_POSIX_=1)
|
|
add_definitions(-D_POSIX_THREADS=1)
|