2012-05-06 06:09:08 +04:00
|
|
|
# WinPR: Windows Portable Runtime
|
2012-05-21 04:54:22 +04:00
|
|
|
# winpr cmake build script
|
2012-05-06 06:09:08 +04:00
|
|
|
#
|
2012-08-14 23:49:39 +04:00
|
|
|
# Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
2012-05-06 06:09:08 +04:00
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
|
2023-11-16 19:03:48 +03:00
|
|
|
# Include our extra modules
|
|
|
|
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../cmake/)
|
|
|
|
|
2021-06-10 10:54:35 +03:00
|
|
|
if (NOT FREERDP_UNIFIED_BUILD)
|
2023-02-25 11:12:22 +03:00
|
|
|
cmake_minimum_required(VERSION 3.13)
|
2023-12-22 17:09:54 +03:00
|
|
|
|
2024-02-13 17:48:33 +03:00
|
|
|
if(POLICY CMP0091)
|
|
|
|
cmake_policy(SET CMP0091 NEW)
|
|
|
|
endif()
|
|
|
|
project(WinPR LANGUAGES C)
|
2021-06-10 10:54:35 +03:00
|
|
|
|
2022-05-25 16:14:36 +03:00
|
|
|
set(CMAKE_C_STANDARD 11)
|
2022-02-24 14:19:10 +03:00
|
|
|
set(CMAKE_C_STANDARD_REQUIRED ON)
|
|
|
|
set(CMAKE_C_EXTENSIONS ON)
|
|
|
|
|
2023-12-21 11:27:19 +03:00
|
|
|
include(CommonConfigOptions)
|
|
|
|
include(ConfigOptions)
|
2021-06-10 10:54:35 +03:00
|
|
|
|
|
|
|
# Default to build shared libs
|
2022-04-29 11:36:37 +03:00
|
|
|
option(EXPORT_ALL_SYMBOLS "Export all symbols form library" OFF)
|
2022-09-26 12:22:02 +03:00
|
|
|
|
|
|
|
if (EXPORT_ALL_SYMBOLS)
|
|
|
|
# set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
|
|
|
|
add_definitions(-DEXPORT_ALL_SYMBOLS)
|
|
|
|
endif()
|
|
|
|
|
2022-04-29 11:36:37 +03:00
|
|
|
if(CMAKE_COMPILER_IS_GNUCC)
|
|
|
|
if(NOT EXPORT_ALL_SYMBOLS)
|
|
|
|
message(STATUS "GCC default symbol visibility: hidden")
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden")
|
|
|
|
endif()
|
|
|
|
endif()
|
2024-02-13 18:52:51 +03:00
|
|
|
if(WITH_DEBUG_ALL)
|
|
|
|
message(WARNING "WITH_DEBUG_ALL=ON, the build will be slow and might leak sensitive information, do not use with release builds!")
|
|
|
|
set(DEFAULT_DEBUG_OPTION "ON" CACHE INTERNAL "debug default")
|
|
|
|
else()
|
|
|
|
set(DEFAULT_DEBUG_OPTION "OFF" CACHE INTERNAL "debug default")
|
|
|
|
endif()
|
2021-06-10 10:54:35 +03:00
|
|
|
endif()
|
2012-09-21 06:11:56 +04:00
|
|
|
|
2021-07-01 17:19:12 +03:00
|
|
|
if (WIN32 AND NOT UWP)
|
|
|
|
set(NATIVE_SSPI ON)
|
|
|
|
endif()
|
2023-10-18 18:56:05 +03:00
|
|
|
|
2023-12-15 23:59:36 +03:00
|
|
|
if((NOT ANDROID AND NOT IOS AND NOT UWP) AND NOT WITH_MBEDTLS)
|
2023-10-18 18:56:05 +03:00
|
|
|
set(TOOLS_DEFAULT ON)
|
|
|
|
else()
|
|
|
|
set(TOOLS_DEFAULT OFF)
|
|
|
|
endif()
|
|
|
|
|
2023-12-15 23:59:36 +03:00
|
|
|
if(WITH_MBEDTLS)
|
|
|
|
set(WITH_INTERNAL_RC4_DEFAULT ON)
|
|
|
|
set(WITH_INTERNAL_MD4_DEFAULT ON)
|
|
|
|
set(WITH_INTERNAL_MD5_DEFAULT OFF)
|
|
|
|
else()
|
|
|
|
set(WITH_INTERNAL_RC4_DEFAULT OFF)
|
|
|
|
set(WITH_INTERNAL_MD4_DEFAULT OFF)
|
|
|
|
set(WITH_INTERNAL_MD5_DEFAULT OFF)
|
|
|
|
endif()
|
|
|
|
|
2021-06-10 09:57:40 +03:00
|
|
|
option(WITH_VERBOSE_WINPR_ASSERT "Compile with verbose WINPR_ASSERT." ON)
|
2023-10-18 18:56:05 +03:00
|
|
|
option(WITH_WINPR_TOOLS "Build WinPR helper binaries" ${TOOLS_DEFAULT})
|
2021-06-22 15:39:10 +03:00
|
|
|
option(WITH_WINPR_DEPRECATED "Build WinPR deprecated symbols" OFF)
|
2021-07-01 17:19:12 +03:00
|
|
|
option(WITH_DEBUG_THREADS "Print thread debug messages, enables handle dump" ${DEFAULT_DEBUG_OPTION})
|
2021-09-20 09:08:02 +03:00
|
|
|
option(WITH_DEBUG_EVENTS "Print event debug messages, enables handle dump" ${DEFAULT_DEBUG_OPTION})
|
2021-07-01 17:19:12 +03:00
|
|
|
option(WITH_DEBUG_SYMBOLS "Pack debug symbols to installer" OFF)
|
|
|
|
option(WITH_NATIVE_SSPI "Use native SSPI modules" ${NATIVE_SSPI})
|
|
|
|
option(WITH_SMARTCARD_INSPECT "Enable SmartCard API Inspector" OFF)
|
|
|
|
option(WITH_DEBUG_MUTEX "Print mutex debug messages" ${DEFAULT_DEBUG_OPTION})
|
2023-12-15 23:59:36 +03:00
|
|
|
option(WITH_INTERNAL_RC4 "Use compiled in rc4 functions instead of OpenSSL/MBedTLS" ${WITH_INTERNAL_RC4_DEFAULT})
|
|
|
|
option(WITH_INTERNAL_MD4 "Use compiled in md4 hash functions instead of OpenSSL/MBedTLS" ${WITH_INTERNAL_MD4_DEFAULT})
|
|
|
|
option(WITH_INTERNAL_MD5 "Use compiled in md5 hash functions instead of OpenSSL/MBedTLS" ${WITH_INTERNAL_MD5_DEFAULT})
|
2023-04-18 16:54:08 +03:00
|
|
|
option(WITH_UNICODE_BUILTIN "Use built-in Unicode conversion (don't use system-provided libraries)" OFF)
|
2022-12-07 17:13:17 +03:00
|
|
|
|
2022-05-26 18:42:28 +03:00
|
|
|
# This option MUST be off to avoid symbol conflicts when loading an external SSPI module library
|
|
|
|
option(SSPI_DLL "Define and export SSPI API symbols for usage as a Windows SSPI DLL replacement" OFF)
|
|
|
|
|
|
|
|
if(SSPI_DLL)
|
|
|
|
add_definitions("-DSSPI_DLL")
|
|
|
|
endif()
|
|
|
|
|
2021-07-01 17:19:12 +03:00
|
|
|
option(WITH_DEBUG_NTLM "Print NTLM debug messages" ${DEFAULT_DEBUG_OPTION})
|
|
|
|
if(WITH_DEBUG_NTLM)
|
2022-04-29 11:36:37 +03:00
|
|
|
message(WARNING "WITH_DEBUG_NTLM=ON, the build might leak sensitive information, do not use with release builds!")
|
2021-07-01 17:19:12 +03:00
|
|
|
endif()
|
|
|
|
|
|
|
|
option(WITH_DEBUG_NLA "Print authentication related debug messages." ${DEFAULT_DEBUG_OPTION})
|
|
|
|
if(WITH_DEBUG_NLA)
|
2022-04-29 11:36:37 +03:00
|
|
|
message(WARNING "WITH_DEBUG_NLA=ON, the build might leak sensitive information, do not use with release builds!")
|
2021-07-01 17:19:12 +03:00
|
|
|
endif()
|
2021-06-22 15:39:10 +03:00
|
|
|
|
|
|
|
if (WITH_WINPR_DEPRECATED)
|
|
|
|
add_definitions(-DWITH_WINPR_DEPRECATED)
|
|
|
|
endif()
|
2021-06-10 09:57:40 +03:00
|
|
|
|
|
|
|
if (WITH_VERBOSE_WINPR_ASSERT)
|
2022-04-29 11:36:37 +03:00
|
|
|
add_definitions(-DWITH_VERBOSE_WINPR_ASSERT)
|
2021-06-10 09:57:40 +03:00
|
|
|
endif()
|
|
|
|
|
2012-09-21 06:11:56 +04:00
|
|
|
|
|
|
|
# Include cmake modules
|
|
|
|
include(CheckIncludeFiles)
|
|
|
|
include(CheckLibraryExists)
|
2015-10-06 17:56:24 +03:00
|
|
|
include(CheckSymbolExists)
|
2012-09-21 06:11:56 +04:00
|
|
|
include(CheckStructHasMember)
|
|
|
|
include(TestBigEndian)
|
|
|
|
|
2012-10-25 13:08:14 +04:00
|
|
|
# Check for cmake compatibility (enable/disable features)
|
|
|
|
include(CheckCmakeCompat)
|
2012-11-03 03:27:01 +04:00
|
|
|
include(FindFeature)
|
2015-10-06 17:56:24 +03:00
|
|
|
include(FeatureSummary)
|
2012-09-21 06:11:56 +04:00
|
|
|
include(CheckCCompilerFlag)
|
2021-06-10 10:54:35 +03:00
|
|
|
include(InstallFreeRDPMan)
|
|
|
|
include(SetFreeRDPCMakeInstallDir)
|
2014-02-03 07:37:54 +04:00
|
|
|
include(CMakePackageConfigHelpers)
|
2012-09-21 06:11:56 +04:00
|
|
|
|
2020-04-13 10:38:36 +03:00
|
|
|
if (NOT WIN32)
|
2022-04-29 11:36:37 +03:00
|
|
|
add_definitions(-DWINPR_CRITICAL_SECTION_DISABLE_SPINCOUNT)
|
2020-04-13 10:38:36 +03:00
|
|
|
endif()
|
|
|
|
|
2012-09-21 06:11:56 +04:00
|
|
|
# Soname versioning
|
2023-05-02 10:18:30 +03:00
|
|
|
set(VERSION_REGEX "^(.*)([0-9]+)\\.([0-9]+)\\.([0-9]+)-?(.*)")
|
2024-01-10 13:07:41 +03:00
|
|
|
set(RAW_VERSION_STRING "3.2.1-dev0")
|
2021-06-21 12:39:34 +03:00
|
|
|
if(EXISTS "${PROJECT_SOURCE_DIR}/.source_tag")
|
|
|
|
file(READ ${PROJECT_SOURCE_DIR}/.source_tag RAW_VERSION_STRING)
|
2019-08-22 16:54:18 +03:00
|
|
|
elseif(USE_VERSION_FROM_GIT_TAG)
|
|
|
|
git_get_exact_tag(_GIT_TAG --tags --always)
|
|
|
|
if (NOT ${_GIT_TAG} STREQUAL "n/a")
|
2023-05-02 10:18:30 +03:00
|
|
|
string(REGEX MATCH ${VERSION_REGEX} FOUND_TAG "${_GIT_TAG}")
|
|
|
|
if (FOUND_TAG)
|
|
|
|
set(RAW_VERSION_STRING ${_GIT_TAG})
|
|
|
|
endif()
|
2019-08-22 16:54:18 +03:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
string(STRIP ${RAW_VERSION_STRING} RAW_VERSION_STRING)
|
|
|
|
|
2022-09-14 12:16:01 +03:00
|
|
|
string(REGEX REPLACE "${VERSION_REGEX}" "\\2" WINPR_VERSION_MAJOR "${RAW_VERSION_STRING}")
|
|
|
|
string(REGEX REPLACE "${VERSION_REGEX}" "\\3" WINPR_VERSION_MINOR "${RAW_VERSION_STRING}")
|
|
|
|
string(REGEX REPLACE "${VERSION_REGEX}" "\\4" WINPR_VERSION_REVISION "${RAW_VERSION_STRING}")
|
|
|
|
string(REGEX REPLACE "${VERSION_REGEX}" "\\5" WINPR_VERSION_SUFFIX "${RAW_VERSION_STRING}")
|
2019-08-22 16:54:18 +03:00
|
|
|
|
2016-01-08 16:07:35 +03:00
|
|
|
set(WINPR_VERSION "${WINPR_VERSION_MAJOR}.${WINPR_VERSION_MINOR}.${WINPR_VERSION_REVISION}")
|
2016-01-13 19:37:19 +03:00
|
|
|
set(WINPR_API_VERSION "${WINPR_VERSION_MAJOR}")
|
2019-08-22 16:54:18 +03:00
|
|
|
if (WINPR_VERSION_SUFFIX)
|
|
|
|
set(WINPR_VERSION_FULL "${WINPR_VERSION}-${WINPR_VERSION_SUFFIX}")
|
|
|
|
else()
|
|
|
|
set(WINPR_VERSION_FULL "${WINPR_VERSION}")
|
|
|
|
endif()
|
2015-10-06 17:56:24 +03:00
|
|
|
|
2016-02-02 20:24:30 +03:00
|
|
|
if(NOT IOS)
|
2023-01-10 16:30:23 +03:00
|
|
|
CHECK_SYMBOL_EXISTS(strndup string.h WINPR_HAVE_STRNDUP)
|
|
|
|
check_include_files(unistd.h WINPR_HAVE_UNISTD_H)
|
|
|
|
check_include_files(execinfo.h WINPR_HAVE_EXECINFO_HEADER)
|
|
|
|
if (WINPR_HAVE_EXECINFO_HEADER)
|
|
|
|
check_symbol_exists(backtrace execinfo.h WINPR_HAVE_EXECINFO_BACKTRACE)
|
|
|
|
check_symbol_exists(backtrace_symbols execinfo.h WINPR_HAVE_EXECINFO_BACKTRACE_SYMBOLS)
|
|
|
|
check_symbol_exists(backtrace_symbols_fd execinfo.h WINPR_HAVE_EXECINFO_BACKTRACE_SYMBOLS_FD)
|
2022-09-15 13:03:07 +03:00
|
|
|
|
|
|
|
# Some implementations (e.g. Android NDK API < 33) provide execinfo.h but do not define
|
|
|
|
# the backtrace functions. Disable detection for these cases
|
2023-01-10 16:30:23 +03:00
|
|
|
if (WINPR_HAVE_EXECINFO_BACKTRACE AND WINPR_HAVE_EXECINFO_BACKTRACE_SYMBOLS AND WINPR_HAVE_EXECINFO_BACKTRACE_SYMBOLS_FD)
|
|
|
|
set(WINPR_HAVE_EXECINFO_H ON)
|
2022-09-15 13:03:07 +03:00
|
|
|
endif()
|
|
|
|
endif()
|
2023-08-03 11:02:19 +03:00
|
|
|
check_include_files(inttypes.h WINPR_HAVE_INTTYPES_H)
|
2023-01-10 16:30:23 +03:00
|
|
|
check_include_files(stdint.h WINPR_HAVE_STDINT_H)
|
2023-08-03 11:02:19 +03:00
|
|
|
check_include_files(inttypes.h WINPR_HAVE_INTTYPES_H)
|
2016-02-02 20:24:30 +03:00
|
|
|
else(NOT IOS)
|
2023-01-10 16:30:23 +03:00
|
|
|
set(WINPR_HAVE_STDINT_H 1)
|
|
|
|
set(WINPR_HAVE_STRNDUP 1)
|
2023-08-03 11:02:19 +03:00
|
|
|
set(WINPR_HAVE_INTTYPES_H 1)
|
2016-02-02 20:24:30 +03:00
|
|
|
endif(NOT IOS)
|
|
|
|
|
2021-06-10 10:54:35 +03:00
|
|
|
if (NOT IOS)
|
2023-01-10 16:30:23 +03:00
|
|
|
check_include_files(stdbool.h WINPR_HAVE_STDBOOL_H)
|
|
|
|
if (NOT WINPR_HAVE_STDBOOL_H)
|
2021-06-10 10:54:35 +03:00
|
|
|
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../compat/stdbool)
|
|
|
|
endif()
|
2015-10-06 17:56:24 +03:00
|
|
|
else()
|
2023-01-10 16:30:23 +03:00
|
|
|
set(WINPR_HAVE_STDBOOL_H 1)
|
2021-06-10 10:54:35 +03:00
|
|
|
endif()
|
|
|
|
|
2021-12-07 02:07:57 +03:00
|
|
|
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
|
2015-10-06 17:56:24 +03:00
|
|
|
|
2021-12-07 02:07:57 +03:00
|
|
|
if(NOT IOS)
|
|
|
|
find_package(Threads REQUIRED)
|
|
|
|
endif()
|
2015-10-06 17:56:24 +03:00
|
|
|
|
2021-12-07 02:07:57 +03:00
|
|
|
# Include files
|
|
|
|
if(NOT IOS)
|
2023-01-10 16:30:23 +03:00
|
|
|
check_include_files(fcntl.h WINPR_HAVE_FCNTL_H)
|
|
|
|
check_include_files(aio.h WINPR_HAVE_AIO_H)
|
|
|
|
check_include_files(sys/timerfd.h WINPR_HAVE_SYS_TIMERFD_H)
|
|
|
|
check_include_files(unistd.h WINPR_HAVE_UNISTD_H)
|
2023-08-03 11:02:19 +03:00
|
|
|
check_include_files(inttypes.h WINPR_HAVE_INTTYPES_H)
|
2023-01-10 16:30:23 +03:00
|
|
|
check_include_files(sys/filio.h WINPR_HAVE_SYS_FILIO_H)
|
|
|
|
check_include_files(sys/sockio.h WINPR_HAVE_SYS_SOCKIO_H)
|
|
|
|
check_include_files(syslog.h WINPR_HAVE_SYSLOG_H)
|
|
|
|
check_include_files(sys/select.h WINPR_HAVE_SYS_SELECT_H)
|
|
|
|
check_include_files(sys/eventfd.h WINPR_HAVE_SYS_EVENTFD_H)
|
|
|
|
check_include_files(unwind.h WINPR_HAVE_UNWIND_H)
|
|
|
|
if (WINPR_HAVE_SYS_EVENTFD_H)
|
2021-12-07 02:07:57 +03:00
|
|
|
check_symbol_exists(eventfd_read sys/eventfd.h WITH_EVENTFD_READ_WRITE)
|
2015-10-06 17:56:24 +03:00
|
|
|
endif()
|
2022-01-25 14:57:43 +03:00
|
|
|
|
|
|
|
include(CheckFunctionExists)
|
2023-01-10 16:30:23 +03:00
|
|
|
check_function_exists(getlogin_r WINPR_HAVE_GETLOGIN_R)
|
|
|
|
check_function_exists(getpwuid_r WINPR_HAVE_GETPWUID_R)
|
|
|
|
check_struct_has_member("struct tm" tm_gmtoff time.h WINPR_HAVE_TM_GMTOFF)
|
2021-12-07 02:07:57 +03:00
|
|
|
else()
|
2023-01-10 16:30:23 +03:00
|
|
|
set(WINPR_HAVE_FCNTL_H 1)
|
|
|
|
set(WINPR_HAVE_UNISTD_H 1)
|
2023-08-03 11:02:19 +03:00
|
|
|
set(WINPR_HAVE_INTTYPES_H 1)
|
2023-01-10 16:30:23 +03:00
|
|
|
set(WINPR_HAVE_SYS_FILIO_H 1)
|
|
|
|
set(WINPR_HAVE_TM_GMTOFF 1)
|
2021-12-07 02:07:57 +03:00
|
|
|
endif()
|
2015-10-06 17:56:24 +03:00
|
|
|
|
2022-04-29 11:36:37 +03:00
|
|
|
if(UNIX OR CYGWIN)
|
|
|
|
if (FREEBSD)
|
|
|
|
list(APPEND CMAKE_REQUIRED_INCLUDES ${EPOLLSHIM_INCLUDE_DIR})
|
|
|
|
endif()
|
|
|
|
if (FREEBSD)
|
|
|
|
list(REMOVE_ITEM CMAKE_REQUIRED_INCLUDES ${EPOLLSHIM_INCLUDE_DIR})
|
|
|
|
endif()
|
|
|
|
option(WITH_POLL "Check for and include poll.h" ON)
|
|
|
|
if (WITH_POLL)
|
2023-01-10 16:30:23 +03:00
|
|
|
check_include_files(poll.h WINPR_HAVE_POLL_H)
|
2022-04-29 11:36:37 +03:00
|
|
|
endif()
|
2021-12-07 02:07:57 +03:00
|
|
|
endif()
|
2015-10-06 17:56:24 +03:00
|
|
|
|
2021-12-07 02:07:57 +03:00
|
|
|
if(NOT WIN32 AND NOT IOS)
|
2023-01-10 16:30:23 +03:00
|
|
|
if (NOT WINPR_HAVE_PTHREAD_MUTEX_TIMEDLOCK_LIB)
|
|
|
|
CHECK_LIBRARY_EXISTS(pthreads pthread_mutex_timedlock "" WINPR_HAVE_PTHREAD_MUTEX_TIMEDLOCK_LIBS)
|
|
|
|
endif (NOT WINPR_HAVE_PTHREAD_MUTEX_TIMEDLOCK_LIB)
|
2016-06-03 15:23:06 +03:00
|
|
|
|
2023-01-10 16:30:23 +03:00
|
|
|
if (NOT WINPR_HAVE_PTHREAD_MUTEX_TIMEDLOCK_SYMBOL)
|
|
|
|
CHECK_LIBRARY_EXISTS(pthread pthread_mutex_timedlock "" WINPR_HAVE_PTHREAD_MUTEX_TIMEDLOCK_LIB)
|
|
|
|
endif (NOT WINPR_HAVE_PTHREAD_MUTEX_TIMEDLOCK_SYMBOL)
|
2021-06-30 11:07:50 +03:00
|
|
|
|
2021-12-07 02:07:57 +03:00
|
|
|
list(APPEND CMAKE_REQUIRED_LIBRARIES pthread)
|
2023-01-10 16:30:23 +03:00
|
|
|
CHECK_SYMBOL_EXISTS(pthread_mutex_timedlock pthread.h WINPR_HAVE_PTHREAD_MUTEX_TIMEDLOCK_SYMBOL)
|
2021-06-30 11:07:50 +03:00
|
|
|
|
2023-01-10 16:30:23 +03:00
|
|
|
if (WINPR_HAVE_PTHREAD_MUTEX_TIMEDLOCK_SYMBOL OR WINPR_HAVE_PTHREAD_MUTEX_TIMEDLOCK_LIB OR WINPR_HAVE_PTHREAD_MUTEX_TIMEDLOCK_LIBS)
|
|
|
|
set(WINPR_HAVE_PTHREAD_MUTEX_TIMEDLOCK ON)
|
|
|
|
endif (WINPR_HAVE_PTHREAD_MUTEX_TIMEDLOCK_SYMBOL OR WINPR_HAVE_PTHREAD_MUTEX_TIMEDLOCK_LIB OR WINPR_HAVE_PTHREAD_MUTEX_TIMEDLOCK_LIBS)
|
2021-12-07 02:07:57 +03:00
|
|
|
list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES pthread)
|
|
|
|
endif()
|
2015-10-06 17:56:24 +03:00
|
|
|
|
2023-12-21 01:30:24 +03:00
|
|
|
set(OPENSSL_FEATURE_TYPE "RECOMMENDED")
|
2015-10-06 17:56:24 +03:00
|
|
|
set(OPENSSL_FEATURE_PURPOSE "cryptography")
|
|
|
|
set(OPENSSL_FEATURE_DESCRIPTION "encryption, certificate validation, hashing functions")
|
|
|
|
|
|
|
|
set(MBEDTLS_FEATURE_TYPE "OPTIONAL")
|
|
|
|
set(MBEDTLS_FEATURE_PURPOSE "cryptography")
|
|
|
|
set(MBEDTLS_FEATURE_DESCRIPTION "encryption, certificate validation, hashing functions")
|
|
|
|
|
2023-12-21 01:30:24 +03:00
|
|
|
option(WITH_LIBRESSL "build with LibreSSL" OFF)
|
|
|
|
if (WITH_LIBRESSL)
|
|
|
|
find_package(LibreSSL REQUIRED)
|
|
|
|
set(OPENSSL_INCLUDE_DIR ${LIBRESSL_INCLUDE_DIR})
|
|
|
|
set(OPENSSL_LIBRARIES ${LIBRESSL_LIBRARIES})
|
|
|
|
set(OPENSSL_CRYPTO_LIBRARIES ${LIBRESSL_LIBRARIES})
|
|
|
|
set(WITH_OPENSSL ON)
|
|
|
|
set(OPENSSL_FOUND ON)
|
|
|
|
add_definitions("-DWITH_LIBRESSL")
|
|
|
|
add_definitions("-DWITH_OPENSSL")
|
|
|
|
else()
|
|
|
|
find_feature(OpenSSL ${OPENSSL_FEATURE_TYPE} ${OPENSSL_FEATURE_PURPOSE} ${OPENSSL_FEATURE_DESCRIPTION})
|
|
|
|
find_feature(MbedTLS ${MBEDTLS_FEATURE_TYPE} ${MBEDTLS_FEATURE_PURPOSE} ${MBEDTLS_FEATURE_DESCRIPTION})
|
|
|
|
endif()
|
2015-10-06 17:56:24 +03:00
|
|
|
|
2023-12-21 01:30:24 +03:00
|
|
|
if (NOT OPENSSL_FOUND AND NOT MBEDTLS_FOUND AND NOT LibreSSL_FOUND)
|
2023-12-15 23:59:36 +03:00
|
|
|
message(FATAL_ERROR "OpenSSL or MBedTLS are required, none enabled/found")
|
2015-10-06 17:56:24 +03:00
|
|
|
endif()
|
|
|
|
|
2023-12-15 23:59:36 +03:00
|
|
|
if(WITH_OPENSSL AND OPENSSL_FOUND)
|
|
|
|
add_definitions("-DWITH_OPENSSL")
|
2015-10-06 17:56:24 +03:00
|
|
|
endif()
|
|
|
|
|
2023-12-15 23:59:36 +03:00
|
|
|
if(WITH_MBEDTLS AND MBEDTLS_FOUND)
|
|
|
|
add_definitions("-DWITH_MBEDTLS")
|
2022-04-29 11:36:37 +03:00
|
|
|
endif()
|
2021-06-10 10:54:35 +03:00
|
|
|
|
2015-10-06 17:56:24 +03:00
|
|
|
enable_testing()
|
|
|
|
|
|
|
|
if(MSVC)
|
2021-06-21 12:39:34 +03:00
|
|
|
set(TESTING_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}")
|
2015-10-06 17:56:24 +03:00
|
|
|
else()
|
2021-06-21 12:39:34 +03:00
|
|
|
set(TESTING_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/Testing")
|
2015-10-06 17:56:24 +03:00
|
|
|
endif()
|
2012-09-21 04:45:56 +04:00
|
|
|
|
2023-06-27 21:16:28 +03:00
|
|
|
if (NOT WIN32 AND NOT IOS AND NOT ANDROID)
|
|
|
|
set(PKCS11_DEFAULT ON)
|
|
|
|
else()
|
|
|
|
set(PKCS11_DEFAULT OFF)
|
|
|
|
endif()
|
|
|
|
option(WITH_PKCS11 "encryption, certificate validation, hashing functions" ${PKCS11_DEFAULT})
|
|
|
|
if (WITH_PKCS11)
|
|
|
|
find_package(Pkcs11 REQUIRED)
|
|
|
|
add_definitions("-DWITH_PKCS11")
|
2021-12-07 02:07:57 +03:00
|
|
|
endif()
|
|
|
|
|
2017-02-15 22:50:24 +03:00
|
|
|
if(BUILD_SHARED_LIBS)
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWINPR_DLL")
|
|
|
|
endif()
|
|
|
|
|
2022-02-28 18:26:57 +03:00
|
|
|
add_definitions(-DWINPR_EXPORTS)
|
2014-02-03 07:37:54 +04:00
|
|
|
|
2018-05-02 17:59:33 +03:00
|
|
|
# Enable 64bit file support on linux and FreeBSD.
|
|
|
|
if("${CMAKE_SYSTEM_NAME}" MATCHES "Linux" OR FREEBSD)
|
2017-05-10 15:37:03 +03:00
|
|
|
add_definitions("-D_FILE_OFFSET_BITS=64")
|
|
|
|
endif()
|
|
|
|
|
2014-04-21 22:42:24 +04:00
|
|
|
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
|
|
|
|
include_directories(${CMAKE_CURRENT_BINARY_DIR}/include)
|
2012-08-01 00:22:10 +04:00
|
|
|
|
2022-02-16 12:08:00 +03:00
|
|
|
set(WINPR_INCLUDE_DIR "include/winpr${WINPR_VERSION_MAJOR}")
|
|
|
|
|
2012-08-15 03:55:48 +04:00
|
|
|
|
2012-08-14 23:49:39 +04:00
|
|
|
add_subdirectory(libwinpr)
|
2012-08-14 22:37:31 +04:00
|
|
|
|
2023-10-18 18:56:05 +03:00
|
|
|
if(WITH_WINPR_TOOLS)
|
2013-03-14 20:38:50 +04:00
|
|
|
add_subdirectory(tools)
|
|
|
|
endif()
|
2013-10-29 06:09:31 +04:00
|
|
|
|
2015-05-26 17:41:29 +03:00
|
|
|
if(BUILD_TESTING)
|
|
|
|
add_subdirectory(test)
|
|
|
|
endif()
|
|
|
|
|
2022-02-16 12:08:00 +03:00
|
|
|
add_subdirectory(include)
|
|
|
|
|
2023-12-21 21:29:58 +03:00
|
|
|
set(MANPAGE_NAME wlog)
|
|
|
|
if (WITH_BINARY_VERSIONING)
|
|
|
|
set(MANPAGE_NAME wlog${WINPR_API_VERSION})
|
|
|
|
endif()
|
2023-12-22 15:02:07 +03:00
|
|
|
configure_file(wlog.7.in ${CMAKE_CURRENT_BINARY_DIR}/${MANPAGE_NAME}.7 @ONLY)
|
2023-12-21 21:29:58 +03:00
|
|
|
install_freerdp_man(${CMAKE_CURRENT_BINARY_DIR}/${MANPAGE_NAME}.7 7)
|
2013-10-29 06:09:31 +04:00
|
|
|
# Exporting
|
|
|
|
|
2021-06-10 10:54:35 +03:00
|
|
|
export(PACKAGE winpr)
|
2013-10-29 06:09:31 +04:00
|
|
|
|
2021-06-10 10:54:35 +03:00
|
|
|
SetFreeRDPCMakeInstallDir(WINPR_CMAKE_INSTALL_DIR "WinPR${WINPR_VERSION_MAJOR}")
|
2013-10-29 06:09:31 +04:00
|
|
|
|
2021-06-10 10:54:35 +03:00
|
|
|
configure_package_config_file(WinPRConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/WinPRConfig.cmake
|
|
|
|
INSTALL_DESTINATION ${WINPR_CMAKE_INSTALL_DIR}
|
|
|
|
PATH_VARS WINPR_INCLUDE_DIR)
|
2013-10-29 06:09:31 +04:00
|
|
|
|
2021-06-10 10:54:35 +03:00
|
|
|
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/WinPRConfigVersion.cmake
|
|
|
|
VERSION ${WINPR_VERSION} COMPATIBILITY SameMajorVersion)
|
2013-10-29 22:47:40 +04:00
|
|
|
|
2021-06-10 10:54:35 +03:00
|
|
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/WinPRConfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/WinPRConfigVersion.cmake
|
|
|
|
DESTINATION ${WINPR_CMAKE_INSTALL_DIR})
|
2013-10-29 22:47:40 +04:00
|
|
|
|
2021-06-10 10:54:35 +03:00
|
|
|
install(EXPORT WinPRTargets DESTINATION ${WINPR_CMAKE_INSTALL_DIR})
|
2013-10-29 22:47:40 +04:00
|
|
|
|
2023-10-09 11:00:58 +03:00
|
|
|
include(pkg-config-install-prefix)
|
2016-01-08 16:07:35 +03:00
|
|
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/winpr.pc.in ${CMAKE_CURRENT_BINARY_DIR}/winpr${WINPR_VERSION_MAJOR}.pc @ONLY)
|
2024-01-02 21:51:33 +03:00
|
|
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/winpr${WINPR_VERSION_MAJOR}.pc DESTINATION ${PKG_CONFIG_PC_INSTALL_DIR})
|