2012-10-09 07:02:04 +04:00
|
|
|
# FreeRDP: A Remote Desktop Protocol Implementation
|
2012-08-14 07:19:51 +04:00
|
|
|
# libfreerdp cmake build script
|
|
|
|
#
|
|
|
|
# Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
|
|
|
#
|
|
|
|
# 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-05 00:54:16 +04:00
|
|
|
set(MODULE_NAME "freerdp")
|
|
|
|
set(MODULE_PREFIX "FREERDP")
|
|
|
|
|
2024-10-24 12:59:13 +03:00
|
|
|
option(FREERDP_USE_VENDOR_PRODUCT_CONFIG_DIR "Use <vendor>/<product> path for resources" OFF)
|
|
|
|
set(FREERDP_RESOURCE_ROOT ${CMAKE_INSTALL_FULL_DATAROOTDIR})
|
|
|
|
if (FREERDP_USE_VENDOR_PRODUCT_CONFIG_DIR)
|
|
|
|
string(APPEND FREERDP_RESOURCE_ROOT "/${VENDOR}")
|
|
|
|
endif()
|
|
|
|
string(APPEND FREERDP_RESOURCE_ROOT "/${PRODUCT}")
|
|
|
|
|
|
|
|
if (WITH_RESOURCE_VERSIONING)
|
|
|
|
string(APPEND FREERDP_RESOURCE_ROOT "${FREERDP_VERSION_MAJOR}")
|
|
|
|
endif()
|
|
|
|
|
2019-08-14 17:39:27 +03:00
|
|
|
# CMake modules includes
|
|
|
|
include(FindCairo)
|
|
|
|
|
2014-09-12 02:19:53 +04:00
|
|
|
set(LIBFREERDP_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
|
|
|
set(LIBFREERDP_SRCS "")
|
2024-06-11 10:30:18 +03:00
|
|
|
set(LIBFREERDP_OBJECT_LIBS "")
|
2014-09-12 02:19:53 +04:00
|
|
|
set(LIBFREERDP_LIBS "")
|
|
|
|
set(LIBFREERDP_INCLUDES "")
|
|
|
|
set(LIBFREERDP_DEFINITIONS "")
|
2024-06-11 10:30:18 +03:00
|
|
|
set(LIBFREERDP_COMPILE_OPTIONS "")
|
2014-09-12 02:19:53 +04:00
|
|
|
|
|
|
|
macro (freerdp_module_add)
|
2020-04-13 10:41:55 +03:00
|
|
|
file (RELATIVE_PATH _relPath "${LIBFREERDP_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}")
|
|
|
|
foreach (_src ${ARGN})
|
|
|
|
if (_relPath)
|
|
|
|
list (APPEND LIBFREERDP_SRCS "${_relPath}/${_src}")
|
|
|
|
else()
|
|
|
|
list (APPEND LIBFREERDP_SRCS "${_src}")
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
if (_relPath)
|
|
|
|
set (LIBFREERDP_SRCS ${LIBFREERDP_SRCS} PARENT_SCOPE)
|
|
|
|
endif()
|
2014-09-12 02:19:53 +04:00
|
|
|
endmacro()
|
|
|
|
|
|
|
|
macro (freerdp_include_directory_add)
|
2020-04-13 10:41:55 +03:00
|
|
|
file (RELATIVE_PATH _relPath "${LIBFREERDP_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}")
|
|
|
|
foreach (_inc ${ARGN})
|
|
|
|
if (IS_ABSOLUTE ${_inc})
|
|
|
|
list (APPEND LIBFREERDP_INCLUDES "${_inc}")
|
|
|
|
else()
|
|
|
|
if (_relPath)
|
|
|
|
list (APPEND LIBFREERDP_INCLUDES "${_relPath}/${_inc}")
|
|
|
|
else()
|
|
|
|
list (APPEND LIBFREERDP_INCLUDES "${_inc}")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
if (_relPath)
|
|
|
|
set (LIBFREERDP_INCLUDES ${LIBFREERDP_INCLUDES} PARENT_SCOPE)
|
|
|
|
endif()
|
2014-09-12 02:19:53 +04:00
|
|
|
endmacro()
|
|
|
|
|
2023-07-20 12:46:03 +03:00
|
|
|
macro (freerdp_library_add_public)
|
2023-12-13 22:49:31 +03:00
|
|
|
foreach (_lib ${ARGN})
|
|
|
|
list (APPEND LIBFREERDP_PUB_LIBS "${_lib}")
|
|
|
|
endforeach()
|
|
|
|
set (LIBFREERDP_PUB_LIBS ${LIBFREERDP_PUB_LIBS} PARENT_SCOPE)
|
2023-07-20 12:46:03 +03:00
|
|
|
endmacro()
|
|
|
|
|
2024-06-11 10:30:18 +03:00
|
|
|
macro (freerdp_object_library_add)
|
|
|
|
foreach (_lib ${ARGN})
|
|
|
|
list (APPEND LIBFREERDP_OBJECT_LIBS "$<TARGET_OBJECTS:${_lib}>")
|
|
|
|
endforeach()
|
|
|
|
set (LIBFREERDP_OBJECT_LIBS ${LIBFREERDP_OBJECT_LIBS} PARENT_SCOPE)
|
|
|
|
endmacro()
|
|
|
|
|
2014-09-12 02:19:53 +04:00
|
|
|
macro (freerdp_library_add)
|
2023-12-13 22:49:31 +03:00
|
|
|
foreach (_lib ${ARGN})
|
|
|
|
list (APPEND LIBFREERDP_LIBS "${_lib}")
|
|
|
|
endforeach()
|
|
|
|
set (LIBFREERDP_LIBS ${LIBFREERDP_LIBS} PARENT_SCOPE)
|
2014-09-12 02:19:53 +04:00
|
|
|
endmacro()
|
|
|
|
|
|
|
|
macro (freerdp_definition_add)
|
2020-04-13 10:41:55 +03:00
|
|
|
foreach (_define ${ARGN})
|
|
|
|
list (APPEND LIBFREERDP_DEFINITIONS "${_define}")
|
|
|
|
endforeach()
|
|
|
|
set (LIBFREERDP_DEFINITIONS ${LIBFREERDP_DEFINITIONS} PARENT_SCOPE)
|
2014-09-12 02:19:53 +04:00
|
|
|
endmacro()
|
|
|
|
|
2024-06-11 10:30:18 +03:00
|
|
|
macro (freerdp_compile_options_add)
|
|
|
|
foreach (_lib ${ARGN})
|
|
|
|
list (APPEND LIBFREERDP_COMPILE_OPTIONS "${_lib}")
|
|
|
|
endforeach()
|
|
|
|
set (LIBFREERDP_COMPILE_OPTIONS ${LIBFREERDP_COMPILE_OPTIONS} PARENT_SCOPE)
|
|
|
|
endmacro()
|
|
|
|
|
2024-07-10 15:28:26 +03:00
|
|
|
option(WITH_FDK_AAC "Enable FDK_AAC support" OFF)
|
|
|
|
if (WITH_FDK_AAC)
|
|
|
|
find_package(PkgConfig REQUIRED)
|
|
|
|
pkg_check_modules(FDK_AAC REQUIRED fdk-aac)
|
|
|
|
|
|
|
|
add_definitions(-DWITH_FDK_AAC)
|
2024-08-26 12:01:54 +03:00
|
|
|
include_directories(SYSTEM ${FDK_AAC_INCLUDE_DIRS})
|
2024-07-10 15:28:26 +03:00
|
|
|
|
|
|
|
link_directories(${FDK_AAC_LIBRARY_DIRS})
|
|
|
|
freerdp_library_add(${FDK_AAC_LIBRARIES})
|
|
|
|
endif()
|
|
|
|
|
2024-06-25 12:29:47 +03:00
|
|
|
set(OPUS_DEFAULT OFF)
|
|
|
|
if (NOT WITH_DSP_FFMPEG)
|
|
|
|
find_package(Opus)
|
|
|
|
if (Opus_FOUND)
|
|
|
|
set(OPUS_DEFAULT ${OPUS_FOUND})
|
|
|
|
else()
|
|
|
|
find_package(PkgConfig)
|
|
|
|
if (PkgConfig_FOUND)
|
|
|
|
pkg_check_modules(OPUS opus)
|
|
|
|
set(OPUS_DEFAULT ${OPUS_FOUND})
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
message("Using OPUS: ${OPUS_DEFAULT}")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
option(WITH_OPUS "compile with opus codec support" ${OPUS_DEFAULT})
|
|
|
|
if (WITH_OPUS)
|
|
|
|
find_package(Opus)
|
|
|
|
if (Opus_FOUND)
|
|
|
|
freerdp_library_add(${OPUS_LIBRARIES})
|
|
|
|
else()
|
|
|
|
find_package(PkgConfig REQUIRED)
|
|
|
|
pkg_check_modules(OPUS REQUIRED opus)
|
|
|
|
freerdp_library_add(${OPUS_LIBRARIES})
|
|
|
|
freerdp_include_directory_add(${OPUS_INCLUDE_DIRS})
|
|
|
|
link_directories(${OPUS_LIBRARY_DIRS})
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2019-05-06 14:18:31 +03:00
|
|
|
if (WITH_SWSCALE)
|
2024-09-09 13:20:06 +03:00
|
|
|
find_package(FFmpeg REQUIRED COMPONENTS SWSCALE)
|
2019-05-06 14:18:31 +03:00
|
|
|
endif(WITH_SWSCALE)
|
|
|
|
if (WITH_CAIRO)
|
|
|
|
find_package(Cairo REQUIRED)
|
|
|
|
endif(WITH_CAIRO)
|
|
|
|
|
2019-10-23 17:13:25 +03:00
|
|
|
# Prefer SWScale over Cairo, both at the same time are not possible.
|
|
|
|
if (WITH_SWSCALE)
|
2024-09-09 13:20:06 +03:00
|
|
|
include_directories(SYSTEM ${SWSCALE_INCLUDE_DIRS})
|
2024-09-17 13:39:48 +03:00
|
|
|
freerdp_library_add(${SWSCALE_LIBRARIES})
|
2022-10-19 18:01:35 +03:00
|
|
|
endif()
|
|
|
|
if (WITH_CAIRO)
|
2024-08-26 12:01:54 +03:00
|
|
|
include_directories(SYSTEM ${CAIRO_INCLUDE_DIR})
|
2019-10-23 17:13:25 +03:00
|
|
|
freerdp_library_add(${CAIRO_LIBRARY})
|
2022-10-19 18:01:35 +03:00
|
|
|
endif()
|
|
|
|
if (NOT WITH_SWSCALE AND NOT WITH_CAIRO)
|
2020-04-13 10:41:55 +03:00
|
|
|
message(WARNING "-DWITH_SWSCALE=OFF and -DWITH_CAIRO=OFF, compiling without image scaling support!")
|
2019-10-23 17:13:25 +03:00
|
|
|
endif()
|
2019-05-06 14:18:31 +03:00
|
|
|
|
2012-10-05 00:54:16 +04:00
|
|
|
set(${MODULE_PREFIX}_SUBMODULES
|
2021-11-05 15:09:42 +03:00
|
|
|
emu
|
2020-04-13 10:41:55 +03:00
|
|
|
utils
|
|
|
|
common
|
|
|
|
gdi
|
|
|
|
cache
|
|
|
|
crypto
|
|
|
|
locale
|
|
|
|
core)
|
2012-10-04 03:29:28 +04:00
|
|
|
|
2012-10-05 03:15:44 +04:00
|
|
|
foreach(${MODULE_PREFIX}_SUBMODULE ${${MODULE_PREFIX}_SUBMODULES})
|
2020-04-13 10:41:55 +03:00
|
|
|
add_subdirectory(${${MODULE_PREFIX}_SUBMODULE})
|
2012-10-04 03:29:28 +04:00
|
|
|
endforeach()
|
2012-08-14 07:19:51 +04:00
|
|
|
|
2024-07-10 15:28:26 +03:00
|
|
|
if (NOT WITH_DSP_FFMPEG AND NOT WITH_FAAC AND NOT WITH_FDK_AAC)
|
|
|
|
message(WARNING "Compiling without WITH_DSP_FFMPEG, WITH_FAAC and WITH_FDK_AAC. AAC encoder support disabled")
|
2021-05-11 12:32:50 +03:00
|
|
|
endif ()
|
|
|
|
|
2024-06-11 10:30:18 +03:00
|
|
|
add_subdirectory(codec)
|
|
|
|
add_subdirectory(primitives)
|
2018-02-20 14:15:30 +03:00
|
|
|
|
2023-10-20 13:40:57 +03:00
|
|
|
if (WITH_AAD)
|
2024-05-14 18:41:06 +03:00
|
|
|
if (NOT WITH_WINPR_JSON)
|
|
|
|
message(FATAL_ERROR "Trying to build -DWITH_AAD=ON but WITH_WINPR_JSON is not defined")
|
|
|
|
endif()
|
2023-03-10 22:55:50 +03:00
|
|
|
endif()
|
|
|
|
|
2023-08-31 11:53:49 +03:00
|
|
|
list(APPEND LIBFREERDP_PUB_LIBS winpr)
|
|
|
|
|
2014-09-12 02:19:53 +04:00
|
|
|
list(REMOVE_DUPLICATES LIBFREERDP_DEFINITIONS)
|
|
|
|
list(REMOVE_DUPLICATES LIBFREERDP_INCLUDES)
|
2024-08-26 12:01:54 +03:00
|
|
|
include_directories(SYSTEM ${LIBFREERDP_INCLUDES})
|
2014-10-03 17:17:40 +04:00
|
|
|
|
2024-06-25 16:44:07 +03:00
|
|
|
if (LIBFREERDP_OBJECT_LIBS)
|
|
|
|
list(REMOVE_DUPLICATES LIBFREERDP_OBJECT_LIBS)
|
|
|
|
list(APPEND LIBFREERDP_SRCS ${LIBFREERDP_OBJECT_LIBS})
|
|
|
|
endif()
|
|
|
|
|
2024-03-19 14:19:07 +03:00
|
|
|
AddTargetWithResourceFile(${MODULE_NAME} FALSE "${FREERDP_VERSION}" LIBFREERDP_SRCS)
|
2014-10-03 17:17:40 +04:00
|
|
|
|
2024-10-24 12:59:13 +03:00
|
|
|
if (WITH_RESOURCE_VERSIONING)
|
|
|
|
target_compile_definitions(${MODULE_NAME} PRIVATE -DWITH_RESOURCE_VERSIONING)
|
|
|
|
endif()
|
|
|
|
if (FREERDP_USE_VENDOR_PRODUCT_CONFIG_DIR)
|
|
|
|
target_compile_definitions(${MODULE_NAME} PRIVATE -DFREERDP_USE_VENDOR_PRODUCT_CONFIG_DIR)
|
|
|
|
endif()
|
|
|
|
|
2014-09-12 02:19:53 +04:00
|
|
|
add_definitions(${LIBFREERDP_DEFINITIONS})
|
2012-08-14 08:31:06 +04:00
|
|
|
|
2024-06-11 10:30:18 +03:00
|
|
|
if (LIBFREERDP_COMPILE_OPTIONS)
|
|
|
|
list(REMOVE_DUPLICATES LIBFREERDP_COMPILE_OPTIONS)
|
|
|
|
target_compile_options(${MODULE_NAME} PRIVATE ${LIBFREERDP_COMPILE_OPTIONS})
|
|
|
|
endif()
|
|
|
|
|
2024-06-06 12:17:55 +03:00
|
|
|
if (WITH_FULL_CONFIG_PATH)
|
|
|
|
add_definitions(-DWITH_FULL_CONFIG_PATH)
|
|
|
|
endif()
|
|
|
|
|
2023-08-01 10:07:39 +03:00
|
|
|
target_include_directories(${MODULE_NAME} INTERFACE $<INSTALL_INTERFACE:include>)
|
2023-07-20 12:46:03 +03:00
|
|
|
target_link_libraries(${MODULE_NAME} PRIVATE ${LIBFREERDP_LIBS})
|
2023-08-31 11:53:49 +03:00
|
|
|
target_link_libraries(${MODULE_NAME} PUBLIC ${LIBFREERDP_PUB_LIBS})
|
2021-05-24 07:51:42 +03:00
|
|
|
install(TARGETS ${MODULE_NAME} COMPONENT libraries EXPORT FreeRDPTargets
|
|
|
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
|
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
|
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
|
|
|
|
|
2014-09-12 02:19:53 +04:00
|
|
|
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "FreeRDP/libfreerdp")
|
2016-01-08 16:07:35 +03:00
|
|
|
|
2023-10-09 11:00:58 +03:00
|
|
|
include(pkg-config-install-prefix)
|
2024-03-14 11:44:37 +03:00
|
|
|
set(FREERDP_REQUIRES_PRIVATE "")
|
2024-05-14 18:41:06 +03:00
|
|
|
|
2024-03-14 11:44:37 +03:00
|
|
|
if(WITH_SMARTCARD_EMULATE)
|
|
|
|
string(APPEND FREERDP_REQUIRES_PRIVATE " zlib")
|
2024-03-14 12:21:38 +03:00
|
|
|
list(APPEND FREERDP_PC_PRIVATE_LIBS "-lz")
|
2024-03-14 11:44:37 +03:00
|
|
|
endif()
|
2024-03-14 12:21:38 +03:00
|
|
|
list(JOIN FREERDP_PC_PRIVATE_LIBS " " FREERDP_PC_PRIVATE_LIBS)
|
2024-10-02 23:37:35 +03:00
|
|
|
cleaning_configure_file(${CMAKE_CURRENT_SOURCE_DIR}/freerdp.pc.in ${CMAKE_CURRENT_BINARY_DIR}/freerdp${FREERDP_VERSION_MAJOR}.pc @ONLY)
|
2024-01-02 21:51:33 +03:00
|
|
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/freerdp${FREERDP_VERSION_MAJOR}.pc DESTINATION ${PKG_CONFIG_PC_INSTALL_DIR})
|
2016-01-08 16:07:35 +03:00
|
|
|
|
|
|
|
## cmake project
|
2021-06-10 10:54:35 +03:00
|
|
|
export(PACKAGE freerdp)
|
2016-01-08 16:07:35 +03:00
|
|
|
|
2021-06-10 10:54:35 +03:00
|
|
|
SetFreeRDPCMakeInstallDir(FREERDP_CMAKE_INSTALL_DIR "FreeRDP${FREERDP_VERSION_MAJOR}")
|
2016-01-08 16:07:35 +03:00
|
|
|
|
2021-06-10 10:54:35 +03:00
|
|
|
configure_package_config_file(FreeRDPConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/FreeRDPConfig.cmake
|
|
|
|
INSTALL_DESTINATION ${FREERDP_CMAKE_INSTALL_DIR}
|
2023-04-22 12:07:59 +03:00
|
|
|
PATH_VARS FREERDP_INCLUDE_DIR FREERDP_PLUGIN_PATH)
|
2016-01-08 16:07:35 +03:00
|
|
|
|
2021-06-10 10:54:35 +03:00
|
|
|
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/FreeRDPConfigVersion.cmake
|
|
|
|
VERSION ${FREERDP_VERSION} COMPATIBILITY SameMajorVersion)
|
2016-01-08 16:07:35 +03:00
|
|
|
|
2021-06-10 10:54:35 +03:00
|
|
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/FreeRDPConfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/FreeRDPConfigVersion.cmake
|
|
|
|
DESTINATION ${FREERDP_CMAKE_INSTALL_DIR})
|
2016-01-08 16:07:35 +03:00
|
|
|
|
2021-06-10 10:54:35 +03:00
|
|
|
install(EXPORT FreeRDPTargets DESTINATION ${FREERDP_CMAKE_INSTALL_DIR})
|