mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-12-27 08:19:30 +08:00
fa770871e9
1. Use FeatureSummary module to show configuration results. 2. Invert option()/find_package() relationship: instead of calling find_package(... REQUIRED) when option is set, rely on optional find package call and PackageName_FOUND variable. 3. Refactor handling options that result in simple preprocessor defines (actually copy the snippet from libtorrent) so that everything is done in a single function call. 4. Populate target properties in order to get rid of include_directories() calls.
23 lines
940 B
CMake
23 lines
940 B
CMake
# Helper function for coupling add_feature_info(), option(), and add_definitions()
|
|
|
|
function(optional_compile_definitions _name)
|
|
set(options FEATURE)
|
|
set(oneValueArgs DESCRIPTION DEFAULT)
|
|
set(multiValueArgs ENABLED DISABLED)
|
|
cmake_parse_arguments(OCD "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
|
option(${_name} "${OCD_DESCRIPTION}" ${OCD_DEFAULT})
|
|
if (${${_name}})
|
|
set_property(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" APPEND PROPERTY COMPILE_DEFINITIONS ${OCD_ENABLED})
|
|
else()
|
|
set_property(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" APPEND PROPERTY COMPILE_DEFINITIONS ${OCD_DISABLED})
|
|
endif()
|
|
if(${OCD_FEATURE})
|
|
add_feature_info(${_name} ${_name} "${OCD_DESCRIPTION}")
|
|
endif()
|
|
endfunction()
|
|
|
|
macro(feature_option _name _description _default)
|
|
option(${_name} "${_description}" ${_default})
|
|
add_feature_info(${_name} ${_name} "${_description}")
|
|
endmacro()
|