2015-02-10 18:05:40 +01:00
include ( CMakeDependentOption )
2012-08-12 18:05:25 -04:00
2014-09-08 16:24:43 -04:00
if ( ( CMAKE_SYSTEM_PROCESSOR MATCHES "i386|i686|x86|AMD64" ) AND ( CMAKE_SIZEOF_VOID_P EQUAL 4 ) )
2012-10-12 17:55:12 -04:00
set ( TARGET_ARCH "x86" )
elseif ( ( CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|AMD64" ) AND ( CMAKE_SIZEOF_VOID_P EQUAL 8 ) )
set ( TARGET_ARCH "x64" )
2013-03-11 22:05:49 +01:00
elseif ( ( CMAKE_SYSTEM_PROCESSOR MATCHES "i386" ) AND ( CMAKE_SIZEOF_VOID_P EQUAL 8 ) AND ( APPLE ) )
# Mac is weird like that.
set ( TARGET_ARCH "x64" )
2015-02-03 13:14:40 -08:00
elseif ( CMAKE_SYSTEM_PROCESSOR MATCHES "^arm*" )
2012-10-22 19:01:19 -04:00
set ( TARGET_ARCH "ARM" )
2015-02-05 08:46:56 -08:00
elseif ( CMAKE_SYSTEM_PROCESSOR MATCHES "sparc" )
set ( TARGET_ARCH "sparc" )
2023-11-29 21:39:48 +03:00
elseif ( CMAKE_SYSTEM_PROCESSOR MATCHES "e2k" )
set ( TARGET_ARCH "e2k" )
2012-10-12 17:55:12 -04:00
endif ( )
2023-12-14 19:17:18 +01:00
if ( NOT OPENBSD AND NOT WIN32 )
2023-10-10 20:46:43 +02:00
set ( MANPAGE_DEF ON )
endif ( )
option ( WITH_MANPAGES "Generate manpages." ${ MANPAGE_DEF } )
2012-03-22 13:33:01 +01:00
option ( WITH_PROFILER "Compile profiler." OFF )
2013-09-18 13:12:52 +02:00
option ( WITH_GPROF "Compile with GProf profiler." OFF )
2012-10-12 17:55:12 -04:00
2023-12-12 13:23:23 +01:00
option ( WITH_SSE2 "Enable SSE2 optimization." OFF )
2024-10-02 15:13:06 +02:00
cmake_dependent_option ( WITH_AVX2 "Compile AVX2 optimizations" ON "WITH_SSE2" OFF )
2023-12-12 13:23:23 +01:00
option ( WITH_NEON "Enable NEON optimization." OFF )
2013-05-31 13:51:50 -04:00
2012-07-24 18:26:24 -07:00
option ( WITH_JPEG "Use JPEG decoding." OFF )
2012-03-22 13:33:01 +01:00
2024-06-25 09:08:54 +02:00
include ( CompilerDetect )
2012-08-12 18:05:25 -04:00
2014-05-12 18:01:29 +02:00
if ( NOT WIN32 )
2016-10-10 19:17:21 +02:00
CMAKE_DEPENDENT_OPTION ( WITH_VALGRIND_MEMCHECK "Compile with valgrind helpers." OFF
" N O T W I T H _ S A N I T I Z E _ A D D R E S S ; N O T W I T H _ S A N I T I Z E _ M E M O R Y ; N O T W I T H _ S A N I T I Z E _ T H R E A D " O F F )
CMAKE_DEPENDENT_OPTION ( WITH_SANITIZE_ADDRESS "Compile with gcc/clang address sanitizer." OFF
" N O T W I T H _ V A L G R I N D _ M E M C H E C K ; N O T W I T H _ S A N I T I Z E _ M E M O R Y ; N O T W I T H _ S A N I T I Z E _ T H R E A D " O F F )
CMAKE_DEPENDENT_OPTION ( WITH_SANITIZE_MEMORY "Compile with gcc/clang memory sanitizer." OFF
" N O T W I T H _ V A L G R I N D _ M E M C H E C K ; N O T W I T H _ S A N I T I Z E _ A D D R E S S ; N O T W I T H _ S A N I T I Z E _ T H R E A D " O F F )
CMAKE_DEPENDENT_OPTION ( WITH_SANITIZE_THREAD "Compile with gcc/clang thread sanitizer." OFF
" N O T W I T H _ V A L G R I N D _ M E M C H E C K ; N O T W I T H _ S A N I T I Z E _ A D D R E S S ; N O T W I T H _ S A N I T I Z E _ M E M O R Y " O F F )
2015-08-11 07:51:59 +02:00
else ( )
2016-03-29 16:03:15 -04:00
if ( NOT UWP )
2021-12-14 12:34:21 +01:00
option ( WITH_MEDIA_FOUNDATION "Enable H264 media foundation decoder." OFF )
2017-07-17 09:32:34 +02:00
endif ( )
2014-05-12 18:01:29 +02:00
endif ( )
2016-03-29 16:03:15 -04:00
if ( WIN32 AND NOT UWP )
2012-12-27 19:19:52 +08:00
option ( WITH_WINMM "Use Windows Multimedia" ON )
2012-09-19 17:51:06 -04:00
option ( WITH_WIN8 "Use Windows 8 libraries" OFF )
2012-08-12 20:43:24 -04:00
endif ( )
2024-10-23 14:20:26 +02:00
option ( BUILD_TESTING "Build unit tests (compatible with packaging)" OFF )
CMAKE_DEPENDENT_OPTION ( BUILD_TESTING_INTERNAL "Build unit tests (CI only, not for packaging!)" OFF "NOT BUILD_TESTING" OFF )
CMAKE_DEPENDENT_OPTION ( TESTS_WTSAPI_EXTRA "Build extra WTSAPI tests (interactive)" OFF "BUILD_TESTING_INTERNAL" OFF )
CMAKE_DEPENDENT_OPTION ( BUILD_COMM_TESTS "Build comm related tests (require comm port)" OFF "BUILD_TESTING_INTERNAL" OFF )
2015-02-10 18:05:40 +01:00
2023-08-03 09:25:00 +02:00
option ( WITH_SAMPLE "Build sample code" ON )
2012-10-02 11:56:10 -04:00
2015-11-04 09:53:13 +01:00
option ( WITH_CLIENT_COMMON "Build client common library" ON )
2020-02-25 16:17:47 +01:00
CMAKE_DEPENDENT_OPTION ( WITH_CLIENT "Build client binaries" ON "WITH_CLIENT_COMMON" OFF )
2022-12-30 11:25:28 +01:00
CMAKE_DEPENDENT_OPTION ( WITH_CLIENT_SDL "[experimental] Build SDL client " ON "WITH_CLIENT" OFF )
2015-11-04 13:15:37 +01:00
2023-08-03 09:24:21 +02:00
option ( WITH_SERVER "Build server binaries" ON )
2012-10-04 23:19:05 -04:00
2012-08-12 18:05:25 -04:00
option ( WITH_CHANNELS "Build virtual channel plugins" ON )
2012-09-22 20:16:38 -04:00
2021-06-10 09:54:35 +02:00
option ( FREERDP_UNIFIED_BUILD "Build WinPR, uwac, RdTk and FreeRDP in one go" ON )
2019-08-14 15:10:00 +02:00
2020-02-25 16:17:47 +01:00
CMAKE_DEPENDENT_OPTION ( WITH_CLIENT_CHANNELS "Build virtual channel plugins" ON
2015-11-10 14:18:51 +01:00
" W I T H _ C L I E N T _ C O M M O N ; W I T H _ C H A N N E L S " O F F )
2012-09-22 20:16:38 -04:00
2020-02-25 16:17:47 +01:00
CMAKE_DEPENDENT_OPTION ( WITH_MACAUDIO "Enable OSX sound backend" ON "APPLE;NOT IOS" OFF )
2016-02-02 11:58:05 -08:00
2012-09-22 20:16:38 -04:00
if ( WITH_SERVER AND WITH_CHANNELS )
option ( WITH_SERVER_CHANNELS "Build virtual channel plugins" ON )
endif ( )
2012-08-12 18:05:25 -04:00
option ( WITH_THIRD_PARTY "Build third-party components" OFF )
2016-05-09 10:25:31 +02:00
option ( WITH_CLIENT_INTERFACE "Build clients as a library with an interface" OFF )
2024-03-19 12:19:07 +01:00
CMAKE_DEPENDENT_OPTION ( CLIENT_INTERFACE_SHARED "Build clients as a shared library with an interface" OFF "WITH_CLIENT_INTERFACE" OFF )
2013-04-29 19:53:56 -04:00
option ( WITH_SERVER_INTERFACE "Build servers as a library with an interface" ON )
2012-09-15 22:19:26 -04:00
2012-09-08 15:27:00 -04:00
option ( WITH_DEBUG_ALL "Print all debug messages." OFF )
if ( WITH_DEBUG_ALL )
2020-11-26 14:41:59 +01:00
message ( WARNING "WITH_DEBUG_ALL=ON, the build will be slow and might leak sensitive information, do not use with release builds!" )
2024-02-13 16:52:51 +01:00
set ( DEFAULT_DEBUG_OPTION ON CACHE INTERNAL "debug default" )
2012-09-08 15:27:00 -04:00
else ( )
2024-02-13 16:52:51 +01:00
set ( DEFAULT_DEBUG_OPTION OFF CACHE INTERNAL "debug default" )
2012-09-08 15:27:00 -04:00
endif ( )
option ( WITH_DEBUG_CERTIFICATE "Print certificate related debug messages." ${ DEFAULT_DEBUG_OPTION } )
2020-11-26 14:41:59 +01:00
if ( WITH_DEBUG_CERTIFICATE )
message ( WARNING "WITH_DEBUG_CERTIFICATE=ON, the build might leak sensitive information, do not use with release builds!" )
endif ( )
2013-02-12 16:25:16 -05:00
option ( WITH_DEBUG_CAPABILITIES "Print capability negotiation debug messages." ${ DEFAULT_DEBUG_OPTION } )
2012-09-08 15:27:00 -04:00
option ( WITH_DEBUG_CHANNELS "Print channel manager debug messages." ${ DEFAULT_DEBUG_OPTION } )
option ( WITH_DEBUG_CLIPRDR "Print clipboard redirection debug messages" ${ DEFAULT_DEBUG_OPTION } )
2022-12-13 11:18:11 +01:00
option ( WITH_DEBUG_CODECS "Print codec debug messages" ${ DEFAULT_DEBUG_OPTION } )
2019-06-04 10:28:03 +03:00
option ( WITH_DEBUG_RDPGFX "Print RDPGFX debug messages" ${ DEFAULT_DEBUG_OPTION } )
2012-09-08 15:27:00 -04:00
option ( WITH_DEBUG_DVC "Print dynamic virtual channel debug messages." ${ DEFAULT_DEBUG_OPTION } )
2020-02-25 15:21:16 +01:00
CMAKE_DEPENDENT_OPTION ( WITH_DEBUG_TSMF "Print TSMF virtual channel debug messages." ${ DEFAULT_DEBUG_OPTION } "CHANNEL_TSMF" OFF )
2012-09-08 15:27:00 -04:00
option ( WITH_DEBUG_KBD "Print keyboard related debug messages." ${ DEFAULT_DEBUG_OPTION } )
2020-11-26 14:41:59 +01:00
if ( WITH_DEBUG_KBD )
message ( WARNING "WITH_DEBUG_KBD=ON, the build might leak sensitive information, do not use with release builds!" )
endif ( )
2012-09-08 15:27:00 -04:00
option ( WITH_DEBUG_LICENSE "Print license debug messages." ${ DEFAULT_DEBUG_OPTION } )
2020-11-26 14:41:59 +01:00
if ( WITH_DEBUG_LICENSE )
message ( WARNING "WITH_DEBUG_LICENSE=ON, the build might leak sensitive information, do not use with release builds!" )
endif ( )
2012-09-08 15:27:00 -04:00
option ( WITH_DEBUG_NEGO "Print negotiation related debug messages." ${ DEFAULT_DEBUG_OPTION } )
2020-11-26 14:41:59 +01:00
if ( WITH_DEBUG_NEGO )
message ( WARNING "WITH_DEBUG_NEGO=ON, the build might leak sensitive information, do not use with release builds!" )
endif ( )
2012-09-08 15:27:00 -04:00
option ( WITH_DEBUG_NLA "Print authentication related debug messages." ${ DEFAULT_DEBUG_OPTION } )
2020-11-26 14:41:59 +01:00
if ( WITH_DEBUG_NLA )
message ( WARNING "WITH_DEBUG_NLA=ON, the build might leak sensitive information, do not use with release builds!" )
endif ( )
2012-09-08 15:27:00 -04:00
option ( WITH_DEBUG_TSG "Print Terminal Server Gateway debug messages" ${ DEFAULT_DEBUG_OPTION } )
option ( WITH_DEBUG_RAIL "Print RemoteApp debug messages" ${ DEFAULT_DEBUG_OPTION } )
option ( WITH_DEBUG_RDP "Print RDP debug messages" ${ DEFAULT_DEBUG_OPTION } )
2016-12-13 22:47:08 +01:00
option ( WITH_DEBUG_RDPEI "Print input virtual channel debug messages" ${ DEFAULT_DEBUG_OPTION } )
2012-09-08 15:27:00 -04:00
option ( WITH_DEBUG_REDIR "Redirection debug messages" ${ DEFAULT_DEBUG_OPTION } )
2016-11-30 13:48:33 -08:00
option ( WITH_DEBUG_RDPDR "Rdpdr debug messages" ${ DEFAULT_DEBUG_OPTION } )
2012-09-08 15:27:00 -04:00
option ( WITH_DEBUG_RFX "Print RemoteFX debug messages." ${ DEFAULT_DEBUG_OPTION } )
option ( WITH_DEBUG_SCARD "Print smartcard debug messages" ${ DEFAULT_DEBUG_OPTION } )
2013-09-23 12:38:44 +02:00
option ( WITH_DEBUG_SND "Print rdpsnd debug messages" ${ DEFAULT_DEBUG_OPTION } )
2012-09-08 15:27:00 -04:00
option ( WITH_DEBUG_SVC "Print static virtual channel debug messages." ${ DEFAULT_DEBUG_OPTION } )
option ( WITH_DEBUG_TRANSPORT "Print transport debug messages." ${ DEFAULT_DEBUG_OPTION } )
option ( WITH_DEBUG_TIMEZONE "Print timezone debug messages." ${ DEFAULT_DEBUG_OPTION } )
option ( WITH_DEBUG_WND "Print window order debug messages" ${ DEFAULT_DEBUG_OPTION } )
option ( WITH_DEBUG_X11_LOCAL_MOVESIZE "Print X11 Client local movesize debug messages" ${ DEFAULT_DEBUG_OPTION } )
option ( WITH_DEBUG_X11 "Print X11 Client debug messages" ${ DEFAULT_DEBUG_OPTION } )
option ( WITH_DEBUG_XV "Print XVideo debug messages" ${ DEFAULT_DEBUG_OPTION } )
2015-02-03 15:28:05 +01:00
option ( WITH_DEBUG_RINGBUFFER "Enable Ringbuffer debug messages" ${ DEFAULT_DEBUG_OPTION } )
2015-12-15 17:19:58 +01:00
option ( WITH_DEBUG_SYMBOLS "Pack debug symbols to installer" OFF )
2017-01-25 09:05:27 +01:00
option ( WITH_CCACHE "Use ccache support if available" ON )
2019-05-23 14:14:31 +02:00
option ( WITH_CLANG_FORMAT "Detect clang-format. run 'cmake --build . --target clangformat' to format." ON )
2012-08-12 18:05:25 -04:00
2018-03-14 16:10:12 +01:00
option ( WITH_DSP_EXPERIMENTAL "Enable experimental sound encoder/decoder formats" OFF )
2022-07-05 17:30:35 +02:00
2023-08-03 09:48:19 +02:00
option ( WITH_FFMPEG "Enable FFMPEG for audio/video encoding/decoding" ON )
CMAKE_DEPENDENT_OPTION ( WITH_DSP_FFMPEG "Use FFMPEG for audio encoding/decoding" ON
2022-07-05 17:30:35 +02:00
" W I T H _ F F M P E G " O F F )
CMAKE_DEPENDENT_OPTION ( WITH_VIDEO_FFMPEG "Use FFMPEG for video encoding/decoding" ON
" W I T H _ F F M P E G " O F F )
CMAKE_DEPENDENT_OPTION ( WITH_VAAPI "Use FFMPEG VAAPI" OFF
" W I T H _ V I D E O _ F F M P E G " O F F )
2018-02-20 12:15:30 +01:00
2022-06-20 07:48:38 +02:00
option ( USE_VERSION_FROM_GIT_TAG "Extract FreeRDP version from git tag." ON )
2017-11-08 14:22:38 +01:00
2019-05-06 13:18:31 +02:00
option ( WITH_CAIRO "Use CAIRO image library for screen resizing" OFF )
2023-08-03 09:48:19 +02:00
option ( WITH_SWSCALE "Use SWScale image library for screen resizing" ON )
2019-05-06 13:18:31 +02:00
if ( ANDROID )
include ( ConfigOptionsAndroid )
2013-01-29 12:59:58 +01:00
endif ( ANDROID )
2013-02-14 14:59:12 +01:00
2019-05-06 13:18:31 +02:00
if ( IOS )
include ( ConfigOptionsiOS )
2013-02-14 14:59:12 +01:00
endif ( IOS )
2020-12-22 15:45:40 +03:00
2023-10-10 20:00:46 +02:00
if ( UNIX AND NOT APPLE )
find_package ( ALSA )
find_package ( PulseAudio )
find_package ( OSS )
option ( WITH_ALSA "use alsa for sound" ${ ALSA_FOUND } )
option ( WITH_PULSE "use alsa for sound" ${ PULSE_FOUND } )
option ( WITH_OSS "use alsa for sound" ${ OSS_FOUND } )
endif ( )
2023-10-10 20:46:43 +02:00
if ( OPENBSD )
find_package ( SNDIO )
option ( WITH_SNDIO "use SNDIO for sound" $ {SNDIO_FOUND # OpenBSD
endif ( )
} )
endif ( )
2020-12-22 15:45:40 +03:00
option ( BUILD_FUZZERS "Use BUILD_FUZZERS to build fuzzing tests" OFF )
if ( BUILD_FUZZERS )
if ( NOT OSS_FUZZ )
2022-11-29 10:19:19 +03:00
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=fuzzer-no-link" )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=fuzzer-no-link" )
set ( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=fuzzer-no-link" )
2020-12-22 15:45:40 +03:00
endif ( )
if ( OSS_FUZZ AND NOT DEFINED ENV{LIB_FUZZING_ENGINE} )
message ( SEND_ERROR
" O S S - F u z z b u i l d s r e q u i r e t h e e n v i r o n m e n t v a r i a b l e "
" L I B _ F U Z Z I N G _ E N G I N E t o b e s e t . I f y o u a r e s e e i n g t h i s "
" w a r n i n g , i t p o i n t s t o a d e e p e r p r o b l e m i n t h e o s s f u z z "
" b u i l d s e t u p . " )
endif ( )
if ( CMAKE_COMPILER_IS_GNUCC )
message ( FATAL_ERROR
" \ n "
" F u z z i n g i s u n s u p p o r t e d w i t h G C C c o m p i l e r . U s e C l a n g : \ n "
" $ C C = c l a n g C X X = c l a n g + + c m a k e . < . . . > - D B U I L D _ F U Z Z E R S = O N & & m a k e - j \ n "
" \ n " )
endif ( )
2024-10-23 14:20:26 +02:00
set ( BUILD_TESTING_INTERNAL ON CACHE BOOL "fuzzer default" FORCE )
2020-12-22 15:45:40 +03:00
2023-05-17 19:44:04 +03:00
if ( BUILD_SHARED_LIBS STREQUAL "OFF" )
set ( CMAKE_FIND_LIBRARY_SUFFIXES ".a" )
set ( CMAKE_CXX_FLAGS "-static ${CMAKE_CXX_FLAGS}" )
endif ( )
2020-12-22 15:45:40 +03:00
# A special target with fuzzer and sanitizer flags.
add_library ( fuzzer_config INTERFACE )
target_compile_options (
f u z z e r _ c o n f i g
I N T E R F A C E
$ < $ < N O T : $ < B O O L : $ { O S S _ F U Z Z } > > :
- f s a n i t i z e = f u z z e r
>
$ < $ < B O O L : $ { O S S _ F U Z Z } > :
$ { C X X }
$ { C X X F L A G S }
>
)
target_link_libraries (
f u z z e r _ c o n f i g
I N T E R F A C E
$ < $ < N O T : $ < B O O L : $ { O S S _ F U Z Z } > > :
- f s a n i t i z e = f u z z e r
>
$ < $ < B O O L : $ { O S S _ F U Z Z } > :
$ E N V { L I B _ F U Z Z I N G _ E N G I N E }
>
)
endif ( )
2024-06-06 11:17:55 +02:00
option ( WITH_FULL_CONFIG_PATH "Use <appdata>/Vendor/Product instead of <appdata>/product (lowercase, only if vendor equals product) as config directory" OFF )
2024-07-24 15:38:43 +02:00
# Configuration settings for manpages
if ( NOT WITH_FULL_CONFIG_PATH AND "${VENDOR}" STREQUAL "${PRODUCT}" )
string ( TOLOWER "${VENDOR}" VENDOR_PRODUCT )
else ( )
set ( VENDOR_PRODUCT "${VENDOR}/${PRODUCT}" )
endif ( )