diff --git a/CMakeLists.txt b/CMakeLists.txt index 6a93216e6..53c5759c2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -79,13 +79,13 @@ check_include_files(fcntl.h HAVE_FCNTL_H) check_include_files(unistd.h HAVE_UNISTD_H) # Libraries that we have a hard dependency on -find_package(OpenSSL REQUIRED) +find_required_package(OpenSSL) if(NOT WIN32) - find_package(ZLIB REQUIRED) - find_optional_package(ALSA) + find_required_package(ZLIB) + find_suggested_package(ALSA) find_optional_package(PulseAudio) - find_optional_package(Cups) + find_suggested_package(Cups) endif() # Endian diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index c97ad2a4e..36bed424d 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -25,7 +25,7 @@ if(NOT WIN32) add_subdirectory(test) # Build X11 Client - find_optional_package(X11) + find_suggested_package(X11) if(X11_FOUND) add_subdirectory(X11) endif() diff --git a/client/X11/CMakeLists.txt b/client/X11/CMakeLists.txt index cbae05848..ef15d2eb5 100644 --- a/client/X11/CMakeLists.txt +++ b/client/X11/CMakeLists.txt @@ -44,21 +44,21 @@ if(WITH_MANPAGES) install(FILES xfreerdp.1 DESTINATION share/man/man1) endif() -find_optional_package(Xinerama) +find_suggested_package(Xinerama) if(XINERAMA_FOUND) add_definitions(-DWITH_XINERAMA -DWITH_XEXT) include_directories(${XINERAMA_INCLUDE_DIRS}) target_link_libraries(xfreerdp ${XINERAMA_LIBRARIES}) endif() -find_optional_package(Xext) +find_suggested_package(Xext) if(XEXT_FOUND) add_definitions(-DWITH_XEXT) include_directories(${XEXT_INCLUDE_DIRS}) target_link_libraries(xfreerdp ${XEXT_LIBRARIES}) endif() -find_optional_package(Xcursor) +find_suggested_package(Xcursor) if(Xcursor_FOUND) add_definitions(-DWITH_XCURSOR) include_directories(${Xcursor_INCLUDE_DIRS}) diff --git a/cmake/FindOptionalPackage.cmake b/cmake/FindOptionalPackage.cmake index dd89f7eb0..792df37dc 100644 --- a/cmake/FindOptionalPackage.cmake +++ b/cmake/FindOptionalPackage.cmake @@ -1,7 +1,10 @@ # - FindOptionalPackage # Enable or disable optional packages. Also force optional packages. # -# This module defines the following variables: +# This module defines the following macros: +# find_required_package : find a required package, can not be disabled +# find_suggested_package : find a suggested package - required but can be disabled +# find_optional_package : find an optional package - required only if enabled # #============================================================================= @@ -20,15 +23,29 @@ # limitations under the License. #============================================================================= +macro(find_required_package _normal_package) + find_package(${_normal_package} REQUIRED) +endmacro(find_required_package) + +macro(find_suggested_package _normal_package) + string(TOUPPER ${_normal_package} _upper_package) + option(WITH_${_upper_package} "Add dependency to ${_normal_package} - recommended" ON) + + if(NOT WITHOUT_${_upper_package}) + message(STATUS "Finding suggested package ${_normal_package}.") + message(STATUS " Disable this using \"-DWITH_${_upper_package}=OFF\".") + find_package(${_normal_package} REQUIRED) + endif(NOT WITHOUT_${_upper_package}) +endmacro(find_suggested_package) macro(find_optional_package _normal_package) - STRING(TOUPPER ${_normal_package} _upper_package) - OPTION(WITH_${_upper_package} "Force dependencies to ${_normal_package}" OFF) - OPTION(WITHOUT_${_upper_package} "Never depend on ${_normal_package}" OFF) + string(TOUPPER ${_normal_package} _upper_package) + option(WITH_${_upper_package} "Add dependency to ${_normal_package}" OFF) if(WITH_${_upper_package}) find_package(${_normal_package} REQUIRED) - elseif(NOT WITHOUT_${_upper_package}) - find_package(${_normal_package}) + else(WITH_${_upper_package}) + message(STATUS "Skipping optional package ${_normal_package}.") + message(STATUS " Enable this using \"-DWITH_${_upper_package}=ON\".") endif(WITH_${_upper_package}) endmacro(find_optional_package) diff --git a/libfreerdp-kbd/CMakeLists.txt b/libfreerdp-kbd/CMakeLists.txt index 2a07932d5..d5dfec87c 100644 --- a/libfreerdp-kbd/CMakeLists.txt +++ b/libfreerdp-kbd/CMakeLists.txt @@ -29,7 +29,7 @@ set(FREERDP_KBD_SRCS add_library(freerdp-kbd SHARED ${FREERDP_KBD_SRCS}) -find_optional_package(XKBFile) +find_suggested_package(XKBFile) if(XKBFILE_FOUND) add_definitions(-DWITH_XKBFILE) include_directories(${XKBFILE_INCLUDE_DIRS}) diff --git a/libfreerdp-utils/CMakeLists.txt b/libfreerdp-utils/CMakeLists.txt index 71a9eda63..b869f5de9 100644 --- a/libfreerdp-utils/CMakeLists.txt +++ b/libfreerdp-utils/CMakeLists.txt @@ -18,7 +18,7 @@ # limitations under the License. set(CMAKE_THREAD_PREFER_PTHREAD) -find_package(Threads REQUIRED) +find_required_package(Threads) set(FREERDP_UTILS_SRCS args.c