qBittorrent/cmake/Modules/QbtTargetSources.cmake
Eugene Shalygin fa770871e9 Refactor CMake build scripts
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.
2018-06-05 11:39:11 +02:00

17 lines
747 B
CMake

# a helper function which appends source to the target
# sources file names are relative to the the target source dir
function (qbt_target_sources _target _scope)
get_target_property(targetSourceDir ${_target} SOURCE_DIR)
set(sourcesRelative "")
foreach(source IN ITEMS ${ARGN})
if(IS_ABSOLUTE "${source}")
set(sourceAbsolutePath "${source}")
else()
get_filename_component(sourceAbsolutePath "${source}" ABSOLUTE)
endif()
file(RELATIVE_PATH sourceRelativePath "${targetSourceDir}" "${sourceAbsolutePath}")
list(APPEND sourcesRelative "${sourceRelativePath}")
endforeach()
target_sources(${_target} ${_scope} "${sourcesRelative}")
endfunction(qbt_target_sources)