move from find_package and find_opitonal_package (old version) to find_required_package, find_suggested_package and find_opitonal_package (new version)

This commit is contained in:
Nils Andresen 2011-08-30 22:39:46 +02:00
parent 3adf0875ca
commit 6063a352b7
6 changed files with 33 additions and 16 deletions

View File

@ -79,13 +79,13 @@ check_include_files(fcntl.h HAVE_FCNTL_H)
check_include_files(unistd.h HAVE_UNISTD_H) check_include_files(unistd.h HAVE_UNISTD_H)
# Libraries that we have a hard dependency on # Libraries that we have a hard dependency on
find_package(OpenSSL REQUIRED) find_required_package(OpenSSL)
if(NOT WIN32) if(NOT WIN32)
find_package(ZLIB REQUIRED) find_required_package(ZLIB)
find_optional_package(ALSA) find_suggested_package(ALSA)
find_optional_package(PulseAudio) find_optional_package(PulseAudio)
find_optional_package(Cups) find_suggested_package(Cups)
endif() endif()
# Endian # Endian

View File

@ -25,7 +25,7 @@ if(NOT WIN32)
add_subdirectory(test) add_subdirectory(test)
# Build X11 Client # Build X11 Client
find_optional_package(X11) find_suggested_package(X11)
if(X11_FOUND) if(X11_FOUND)
add_subdirectory(X11) add_subdirectory(X11)
endif() endif()

View File

@ -44,21 +44,21 @@ if(WITH_MANPAGES)
install(FILES xfreerdp.1 DESTINATION share/man/man1) install(FILES xfreerdp.1 DESTINATION share/man/man1)
endif() endif()
find_optional_package(Xinerama) find_suggested_package(Xinerama)
if(XINERAMA_FOUND) if(XINERAMA_FOUND)
add_definitions(-DWITH_XINERAMA -DWITH_XEXT) add_definitions(-DWITH_XINERAMA -DWITH_XEXT)
include_directories(${XINERAMA_INCLUDE_DIRS}) include_directories(${XINERAMA_INCLUDE_DIRS})
target_link_libraries(xfreerdp ${XINERAMA_LIBRARIES}) target_link_libraries(xfreerdp ${XINERAMA_LIBRARIES})
endif() endif()
find_optional_package(Xext) find_suggested_package(Xext)
if(XEXT_FOUND) if(XEXT_FOUND)
add_definitions(-DWITH_XEXT) add_definitions(-DWITH_XEXT)
include_directories(${XEXT_INCLUDE_DIRS}) include_directories(${XEXT_INCLUDE_DIRS})
target_link_libraries(xfreerdp ${XEXT_LIBRARIES}) target_link_libraries(xfreerdp ${XEXT_LIBRARIES})
endif() endif()
find_optional_package(Xcursor) find_suggested_package(Xcursor)
if(Xcursor_FOUND) if(Xcursor_FOUND)
add_definitions(-DWITH_XCURSOR) add_definitions(-DWITH_XCURSOR)
include_directories(${Xcursor_INCLUDE_DIRS}) include_directories(${Xcursor_INCLUDE_DIRS})

View File

@ -1,7 +1,10 @@
# - FindOptionalPackage # - FindOptionalPackage
# Enable or disable optional packages. Also force optional packages. # 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. # 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) macro(find_optional_package _normal_package)
STRING(TOUPPER ${_normal_package} _upper_package) string(TOUPPER ${_normal_package} _upper_package)
OPTION(WITH_${_upper_package} "Force dependencies to ${_normal_package}" OFF) option(WITH_${_upper_package} "Add dependency to ${_normal_package}" OFF)
OPTION(WITHOUT_${_upper_package} "Never depend on ${_normal_package}" OFF)
if(WITH_${_upper_package}) if(WITH_${_upper_package})
find_package(${_normal_package} REQUIRED) find_package(${_normal_package} REQUIRED)
elseif(NOT WITHOUT_${_upper_package}) else(WITH_${_upper_package})
find_package(${_normal_package}) message(STATUS "Skipping optional package ${_normal_package}.")
message(STATUS " Enable this using \"-DWITH_${_upper_package}=ON\".")
endif(WITH_${_upper_package}) endif(WITH_${_upper_package})
endmacro(find_optional_package) endmacro(find_optional_package)

View File

@ -29,7 +29,7 @@ set(FREERDP_KBD_SRCS
add_library(freerdp-kbd SHARED ${FREERDP_KBD_SRCS}) add_library(freerdp-kbd SHARED ${FREERDP_KBD_SRCS})
find_optional_package(XKBFile) find_suggested_package(XKBFile)
if(XKBFILE_FOUND) if(XKBFILE_FOUND)
add_definitions(-DWITH_XKBFILE) add_definitions(-DWITH_XKBFILE)
include_directories(${XKBFILE_INCLUDE_DIRS}) include_directories(${XKBFILE_INCLUDE_DIRS})

View File

@ -18,7 +18,7 @@
# limitations under the License. # limitations under the License.
set(CMAKE_THREAD_PREFER_PTHREAD) set(CMAKE_THREAD_PREFER_PTHREAD)
find_package(Threads REQUIRED) find_required_package(Threads)
set(FREERDP_UTILS_SRCS set(FREERDP_UTILS_SRCS
args.c args.c