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.
|
|
|
|
|
2012-10-04 17:42:23 +04:00
|
|
|
cmake_minimum_required(VERSION 2.8)
|
2012-09-21 06:11:56 +04:00
|
|
|
|
|
|
|
project(WinPR C)
|
|
|
|
|
|
|
|
set(CMAKE_COLOR_MAKEFILE ON)
|
|
|
|
|
|
|
|
if(FREERDP_VERSION)
|
2014-02-03 07:37:54 +04:00
|
|
|
set(FREERDP_BUILD 1)
|
2012-09-21 06:11:56 +04:00
|
|
|
endif()
|
|
|
|
|
|
|
|
# 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(FindPkgConfig)
|
|
|
|
include(TestBigEndian)
|
|
|
|
|
|
|
|
# Include our extra modules
|
|
|
|
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../cmake/)
|
|
|
|
|
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)
|
2012-09-21 06:11:56 +04:00
|
|
|
include(ConfigOptions)
|
2015-10-06 17:56:24 +03:00
|
|
|
include(ComplexLibrary)
|
|
|
|
include(FeatureSummary)
|
2012-09-21 06:11:56 +04:00
|
|
|
include(CheckCCompilerFlag)
|
|
|
|
include(GNUInstallDirsWrapper)
|
2014-02-03 07:37:54 +04:00
|
|
|
include(CMakePackageConfigHelpers)
|
2012-09-21 06:11:56 +04:00
|
|
|
|
|
|
|
# Soname versioning
|
2020-04-10 08:40:04 +03:00
|
|
|
set(RAW_VERSION_STRING "3.0.0-dev")
|
2019-08-22 16:54:18 +03:00
|
|
|
if(EXISTS "${CMAKE_SOURCE_DIR}/.source_tag")
|
|
|
|
file(READ ${CMAKE_SOURCE_DIR}/.source_tag RAW_VERSION_STRING)
|
|
|
|
elseif(USE_VERSION_FROM_GIT_TAG)
|
|
|
|
git_get_exact_tag(_GIT_TAG --tags --always)
|
|
|
|
if (NOT ${_GIT_TAG} STREQUAL "n/a")
|
|
|
|
set(RAW_VERSION_STRING ${_GIT_TAG})
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
string(STRIP ${RAW_VERSION_STRING} RAW_VERSION_STRING)
|
|
|
|
|
|
|
|
set(VERSION_REGEX "^.?([0-9]+)\\.([0-9]+)\\.([0-9]+)-?(.*)")
|
|
|
|
string(REGEX REPLACE "${VERSION_REGEX}" "\\1" WINPR_VERSION_MAJOR "${RAW_VERSION_STRING}")
|
|
|
|
string(REGEX REPLACE "${VERSION_REGEX}" "\\2" WINPR_VERSION_MINOR "${RAW_VERSION_STRING}")
|
|
|
|
string(REGEX REPLACE "${VERSION_REGEX}" "\\3" WINPR_VERSION_REVISION "${RAW_VERSION_STRING}")
|
|
|
|
string(REGEX REPLACE "${VERSION_REGEX}" "\\4" WINPR_VERSION_SUFFIX "${RAW_VERSION_STRING}")
|
|
|
|
|
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)
|
|
|
|
check_include_files(stdbool.h WINPR_HAVE_STDBOOL_H)
|
|
|
|
check_include_files(stdint.h WINPR_HAVE_STDINT_H)
|
2016-12-14 00:47:08 +03:00
|
|
|
check_include_files(inttypes.h WINPR_HAVE_INTTYPES_H)
|
2016-02-02 20:24:30 +03:00
|
|
|
else(NOT IOS)
|
|
|
|
set(WINPR_HAVE_STDBOOL_H 1)
|
|
|
|
set(WINPR_HAVE_STDINT_H 1)
|
2016-12-14 00:47:08 +03:00
|
|
|
set(WINPR_HAVE_INTTYPES_H 1)
|
2016-02-02 20:24:30 +03:00
|
|
|
endif(NOT IOS)
|
|
|
|
|
2015-10-06 17:56:24 +03:00
|
|
|
if(FREERDP_BUILD)
|
|
|
|
set(WINPR_VERSION_FULL ${WINPR_VERSION_FULL} PARENT_SCOPE)
|
2016-01-13 19:37:19 +03:00
|
|
|
set(WINPR_VERSION ${WINPR_VERSION} PARENT_SCOPE)
|
2016-02-26 01:38:53 +03:00
|
|
|
set(WINPR_API_VERSION ${WINPR_API_VERSION} PARENT_SCOPE)
|
2015-10-06 17:56:24 +03:00
|
|
|
else()
|
|
|
|
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
|
|
|
|
|
2016-06-02 16:33:00 +03:00
|
|
|
if(NOT IOS)
|
2015-10-06 17:56:24 +03:00
|
|
|
find_package(Threads REQUIRED)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Include files
|
|
|
|
if(NOT IOS)
|
|
|
|
check_include_files(fcntl.h HAVE_FCNTL_H)
|
|
|
|
check_include_files(unistd.h HAVE_UNISTD_H)
|
|
|
|
check_include_files(execinfo.h HAVE_EXECINFO_H)
|
|
|
|
check_include_files(inttypes.h HAVE_INTTYPES_H)
|
|
|
|
check_include_files(sys/modem.h HAVE_SYS_MODEM_H)
|
|
|
|
check_include_files(sys/filio.h HAVE_SYS_FILIO_H)
|
|
|
|
check_include_files(sys/sockio.h HAVE_SYS_SOCKIO_H)
|
|
|
|
check_include_files(sys/strtio.h HAVE_SYS_STRTIO_H)
|
|
|
|
check_include_files(sys/select.h HAVE_SYS_SELECT_H)
|
|
|
|
else()
|
|
|
|
set(HAVE_FCNTL_H 1)
|
|
|
|
set(HAVE_UNISTD_H 1)
|
|
|
|
set(HAVE_INTTYPES_H 1)
|
|
|
|
set(HAVE_SYS_FILIO_H 1)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(NOT IOS)
|
|
|
|
check_struct_has_member("struct tm" tm_gmtoff time.h HAVE_TM_GMTOFF)
|
|
|
|
else()
|
|
|
|
set(HAVE_TM_GMTOFF 1)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(NOT WIN32)
|
2016-06-03 15:23:06 +03:00
|
|
|
CHECK_SYMBOL_EXISTS(pthread_mutex_timedlock pthread.h HAVE_PTHREAD_MUTEX_TIMEDLOCK_SYMBOL)
|
|
|
|
if (NOT HAVE_PTHREAD_MUTEX_TIMEDLOCK_SYMBOL)
|
|
|
|
CHECK_LIBRARY_EXISTS(pthread pthread_mutex_timedlock "" HAVE_PTHREAD_MUTEX_TIMEDLOCK_LIB)
|
|
|
|
endif (NOT HAVE_PTHREAD_MUTEX_TIMEDLOCK_SYMBOL)
|
|
|
|
if (NOT HAVE_PTHREAD_MUTEX_TIMEDLOCK_LIB)
|
|
|
|
CHECK_LIBRARY_EXISTS(pthreads pthread_mutex_timedlock "" HAVE_PTHREAD_MUTEX_TIMEDLOCK_LIBS)
|
|
|
|
endif (NOT HAVE_PTHREAD_MUTEX_TIMEDLOCK_LIB)
|
|
|
|
|
|
|
|
if (HAVE_PTHREAD_MUTEX_TIMEDLOCK_SYMBOL OR HAVE_PTHREAD_MUTEX_TIMEDLOCK_LIB OR HAVE_PTHREAD_MUTEX_TIMEDLOCK_LIBS)
|
|
|
|
set(HAVE_PTHREAD_MUTEX_TIMEDLOCK ON)
|
|
|
|
endif (HAVE_PTHREAD_MUTEX_TIMEDLOCK_SYMBOL OR HAVE_PTHREAD_MUTEX_TIMEDLOCK_LIB OR HAVE_PTHREAD_MUTEX_TIMEDLOCK_LIBS)
|
2015-10-06 17:56:24 +03:00
|
|
|
endif()
|
|
|
|
|
|
|
|
set(OPENSSL_FEATURE_TYPE "OPTIONAL")
|
|
|
|
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")
|
|
|
|
|
|
|
|
find_feature(OpenSSL ${OPENSSL_FEATURE_TYPE} ${OPENSSL_FEATURE_PURPOSE} ${OPENSSL_FEATURE_DESCRIPTION})
|
|
|
|
find_feature(MbedTLS ${MBEDTLS_FEATURE_TYPE} ${MBEDTLS_FEATURE_PURPOSE} ${MBEDTLS_FEATURE_DESCRIPTION})
|
|
|
|
|
|
|
|
if(OPENSSL_FOUND)
|
|
|
|
add_definitions("-DWITH_OPENSSL")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(MBEDTLS_FOUND)
|
|
|
|
add_definitions("-DWITH_MBEDTLS")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Include directories
|
|
|
|
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
|
|
|
|
|
|
|
# Configure files
|
|
|
|
add_definitions("-DHAVE_CONFIG_H")
|
|
|
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
|
|
|
|
|
|
|
|
enable_testing()
|
|
|
|
|
|
|
|
if(MSVC)
|
|
|
|
set(TESTING_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
|
|
|
|
else()
|
|
|
|
set(TESTING_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/Testing")
|
|
|
|
endif()
|
|
|
|
endif()
|
2012-09-21 04:45:56 +04:00
|
|
|
|
2012-09-21 06:11:56 +04:00
|
|
|
# Default to release build type
|
|
|
|
if(NOT CMAKE_BUILD_TYPE)
|
|
|
|
set(CMAKE_BUILD_TYPE "Release")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Default to build shared libs
|
|
|
|
if(NOT DEFINED BUILD_SHARED_LIBS)
|
|
|
|
set(BUILD_SHARED_LIBS ON)
|
|
|
|
endif()
|
|
|
|
|
2017-02-15 22:50:24 +03:00
|
|
|
if(BUILD_SHARED_LIBS)
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWINPR_DLL")
|
|
|
|
endif()
|
|
|
|
|
2014-02-03 07:37:54 +04:00
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWINPR_EXPORTS")
|
|
|
|
|
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
|
|
|
|
2013-09-10 22:03:15 +04:00
|
|
|
add_subdirectory(include)
|
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
|
|
|
|
2019-08-14 16:10:00 +03:00
|
|
|
if(NOT ANDROID AND NOT IOS AND NOT UWP AND 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()
|
|
|
|
|
2017-01-16 13:34:32 +03:00
|
|
|
install_freerdp_man(wlog.7 7)
|
2013-10-29 06:09:31 +04:00
|
|
|
# Exporting
|
|
|
|
|
2013-10-29 22:47:40 +04:00
|
|
|
if(${CMAKE_VERSION} VERSION_GREATER "2.8.10")
|
2013-10-29 06:09:31 +04:00
|
|
|
|
2013-10-29 22:47:40 +04:00
|
|
|
export(PACKAGE winpr)
|
2013-10-29 06:09:31 +04:00
|
|
|
|
2018-05-02 18:03:53 +03:00
|
|
|
SetFreeRDPCMakeInstallDir(WINPR_CMAKE_INSTALL_DIR "WinPR${WINPR_VERSION_MAJOR}")
|
2013-10-29 06:09:31 +04:00
|
|
|
|
2016-01-08 16:07:35 +03:00
|
|
|
set(WINPR_INCLUDE_DIR "include/winpr${WINPR_VERSION_MAJOR}")
|
2013-10-29 06:09:31 +04:00
|
|
|
|
2013-10-29 22:47:40 +04:00
|
|
|
configure_package_config_file(WinPRConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/WinPRConfig.cmake
|
|
|
|
INSTALL_DESTINATION ${WINPR_CMAKE_INSTALL_DIR}
|
2015-12-30 20:45:09 +03:00
|
|
|
PATH_VARS WINPR_INCLUDE_DIR)
|
2013-10-29 22:47:40 +04:00
|
|
|
|
|
|
|
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/WinPRConfigVersion.cmake
|
|
|
|
VERSION ${WINPR_VERSION} COMPATIBILITY SameMajorVersion)
|
|
|
|
|
|
|
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/WinPRConfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/WinPRConfigVersion.cmake
|
|
|
|
DESTINATION ${WINPR_CMAKE_INSTALL_DIR})
|
|
|
|
|
|
|
|
install(EXPORT WinPRTargets DESTINATION ${WINPR_CMAKE_INSTALL_DIR})
|
|
|
|
|
|
|
|
endif()
|
2013-10-29 06:09:31 +04:00
|
|
|
|
2016-01-13 19:37:19 +03:00
|
|
|
if(FREERDP_BUILD)
|
|
|
|
set(WINPR_PKG_CONFIG_FILENAME winpr${WINPR_VERSION_MAJOR} PARENT_SCOPE)
|
|
|
|
endif()
|
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)
|
|
|
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/winpr${WINPR_VERSION_MAJOR}.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
|