[cmake] move platform defines to common include

* Move platform specific settings to a common CMake include
This commit is contained in:
akallabeth 2024-03-19 09:51:11 +01:00 committed by akallabeth
parent 15cf6b26b1
commit f4b7c59915
10 changed files with 25 additions and 49 deletions

View File

@ -59,12 +59,6 @@ endif()
# Include our extra modules
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/)
if((CMAKE_SYSTEM_NAME MATCHES "WindowsStore") AND (CMAKE_SYSTEM_VERSION MATCHES "10.0"))
set(UWP 1)
add_definitions("-D_UWP")
set(CMAKE_WINDOWS_VERSION "WIN10")
endif()
# Check for cmake compatibility (enable/disable features)
include(CheckCmakeCompat)
@ -214,16 +208,6 @@ if(FREEBSD)
find_library(EPOLLSHIM_LIBS NAMES epoll-shim libepoll-shim HINTS /usr/local/lib)
endif()
# Enable 64bit file support on linux and FreeBSD.
if("${CMAKE_SYSTEM_NAME}" MATCHES "Linux" OR FREEBSD)
add_definitions("-D_FILE_OFFSET_BITS=64")
endif()
# Use Standard conforming getpwnam_r() on Solaris.
if("${CMAKE_SYSTEM_NAME}" MATCHES "SunOS")
add_definitions("-D_POSIX_PTHREAD_SEMANTICS")
endif()
# Compiler-specific flags
if(CMAKE_COMPILER_IS_GNUCC)
if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64" OR CMAKE_SYSTEM_PROCESSOR MATCHES "i686")

View File

@ -28,6 +28,7 @@ if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "project default")
endif()
include(PlatformDefaults)
include(PreventInSourceBuilds)
include(GNUInstallDirsWrapper)
include(MSVCRuntime)

View File

@ -0,0 +1,23 @@
# default defines or other required preferences per platform
if((CMAKE_SYSTEM_NAME MATCHES "WindowsStore") AND (CMAKE_SYSTEM_VERSION MATCHES "10.0"))
set(UWP 1 CACHE BOOL "platform default")
add_definitions("-D_UWP")
set(CMAKE_WINDOWS_VERSION "WIN10" CACHE STRING "platform default")
endif()
# Enable 64bit file support on linux and FreeBSD.
if("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
add_definitions("-D_FILE_OFFSET_BITS=64")
endif()
if("${CMAKE_SYSTEM_NAME}" MATCHES FREEBSD)
add_definitions("-D_FILE_OFFSET_BITS=64")
endif()
# Use Standard conforming getpwnam_r() on Solaris.
# Use Standard conforming getpwnam_r() on Solaris.
if("${CMAKE_SYSTEM_NAME}" MATCHES "SunOS")
add_definitions("-D_POSIX_PTHREAD_SEMANTICS")
list(APPEND CMAKE_STANDARD_LIBRARIES rt)
set(CMAKE_STANDARD_LIBRARIES ${CMAKE_STANDARD_LIBRARIES} CACHE STRING "platform default")
set(WITH_SUN true CACHE BOOL "platform default")
endif()

View File

@ -47,10 +47,6 @@ if(WIN32)
freerdp_library_add(cfgmgr32)
endif()
if(${CMAKE_SYSTEM_NAME} MATCHES SunOS)
freerdp_library_add(rt)
endif()
if(BUILD_TESTING)
add_subdirectory(test)
endif()

View File

@ -323,11 +323,6 @@ endif()
add_definitions(-DWINPR_EXPORTS)
# Enable 64bit file support on linux and FreeBSD.
if("${CMAKE_SYSTEM_NAME}" MATCHES "Linux" OR FREEBSD)
add_definitions("-D_FILE_OFFSET_BITS=64")
endif()
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/include)

View File

@ -36,14 +36,6 @@
#include <stdlib.h>
#if defined(__APPLE__)
#include <malloc/malloc.h>
#elif defined(__FreeBSD__) || defined(__OpenBSD__)
#include <stdlib.h>
#else
#include <malloc.h>
#endif
#include "../log.h"
#define TAG WINPR_TAG("crt")
@ -108,7 +100,7 @@ void* winpr_aligned_offset_malloc(size_t size, size_t alignment, size_t offset)
/* malloc size + alignment to make sure we can align afterwards */
#if defined(_ISOC11_SOURCE)
base = aligned_alloc(alignment, alignsize);
#elif _POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600
#elif defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 200112L) || (_XOPEN_SOURCE >= 600)
if (posix_memalign(&base, alignment, alignsize) != 0)
return NULL;
#else

View File

@ -18,6 +18,3 @@
winpr_module_add(handle.c handle.h nonehandle.c nonehandle.h)
if(${CMAKE_SYSTEM_NAME} MATCHES SunOS)
winpr_library_add_private(rt)
endif()

View File

@ -21,10 +21,6 @@ winpr_library_add_private(
${CMAKE_THREAD_LIBS_INIT}
${CMAKE_DL_LIBS})
if(${CMAKE_SYSTEM_NAME} MATCHES SunOS)
winpr_library_add_private(rt)
endif()
if(BUILD_TESTING)
add_subdirectory(test)
endif()

View File

@ -30,10 +30,6 @@ winpr_library_add_private(
${CMAKE_THREAD_LIBS_INIT}
${CMAKE_DL_LIBS})
if(${CMAKE_SYSTEM_NAME} MATCHES SunOS)
winpr_library_add_private(rt)
endif()
if(BUILD_TESTING)
add_subdirectory(test)
endif()

View File

@ -25,10 +25,6 @@ winpr_module_add(
thread.h
tls.c)
if(${CMAKE_SYSTEM_NAME} MATCHES SunOS)
winpr_library_add_private(rt)
endif()
if(BUILD_TESTING)
add_subdirectory(test)
endif()