mirror of
https://github.com/transmission/transmission.git
synced 2025-12-20 02:18:42 +00:00
Modernize CMake code (ongoing refactoring) (#4515)
* Use imported CMake target for CURL * Use imported CMake target for fmtlib * Use imported CMake target for WideInteger * Use imported CMake target for FastFloat * Use imported CMake target for UtfCpp * Use imported CMake target for Threads * Use imported CMake target for Iconv * Use imported CMake target for crypto backend * Use imported CMake target for GTK * Use imported CMake target for Qt * Use imported CMake target for deflate * Use imported CMake target for libevent * Use imported CMake target for natpmp * Use imported CMake target for miniupnpc * Use imported CMake target for dht * Use imported CMake target for psl * Use imported CMake target for libutp * Use imported CMake target for libb64 * Use include directories from libtransmission target
This commit is contained in:
@@ -1 +1,5 @@
|
||||
set(FAST_FLOAT_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/third-party/fast_float/include)
|
||||
add_library(FastFloat::fast_float INTERFACE IMPORTED)
|
||||
|
||||
target_include_directories(FastFloat::fast_float
|
||||
INTERFACE
|
||||
${CMAKE_CURRENT_LIST_DIR}/../third-party/fast_float/include)
|
||||
|
||||
@@ -1 +1,10 @@
|
||||
set(LIBFMT_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/third-party/fmt/include)
|
||||
add_library(fmt::fmt-header-only INTERFACE IMPORTED)
|
||||
|
||||
target_include_directories(fmt::fmt-header-only
|
||||
INTERFACE
|
||||
${CMAKE_CURRENT_LIST_DIR}/../third-party/fmt/include)
|
||||
|
||||
target_compile_definitions(fmt::fmt-header-only
|
||||
INTERFACE
|
||||
FMT_EXCEPTIONS=0
|
||||
FMT_HEADER_ONLY=1)
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
# Grabbed from http://public.kitware.com/Bug/view.php?id=13517 and slightly modified.
|
||||
|
||||
find_path(ICONV_INCLUDE_DIR
|
||||
NAMES iconv.h)
|
||||
find_library(ICONV_LIBRARY
|
||||
NAMES
|
||||
iconv
|
||||
libiconv
|
||||
libiconv-2
|
||||
c)
|
||||
|
||||
set(ICONV_INCLUDE_DIRS ${ICONV_INCLUDE_DIR})
|
||||
set(ICONV_LIBRARIES ${ICONV_LIBRARY})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
find_package_handle_standard_args(ICONV
|
||||
REQUIRED_VARS
|
||||
ICONV_LIBRARY
|
||||
ICONV_INCLUDE_DIR
|
||||
VERSION_VAR ICONV_VERSION)
|
||||
|
||||
if(ICONV_FOUND AND NOT DEFINED ICONV_SECOND_ARGUMENT_IS_CONST)
|
||||
include(CheckCXXSourceCompiles)
|
||||
|
||||
set(CMAKE_REQUIRED_INCLUDES ${ICONV_INCLUDE_DIRS})
|
||||
set(CMAKE_REQUIRED_LIBRARIES ${ICONV_LIBRARIES})
|
||||
|
||||
check_cxx_source_compiles("
|
||||
#include <iconv.h>
|
||||
int main()
|
||||
{
|
||||
iconv_t conv = 0;
|
||||
const char * in = 0;
|
||||
size_t ilen = 0;
|
||||
char * out = 0;
|
||||
size_t olen = 0;
|
||||
iconv(conv, &in, &ilen, &out, &olen);
|
||||
return 0;
|
||||
}"
|
||||
ICONV_SECOND_ARGUMENT_IS_CONST
|
||||
FAIL_REGEX "discards qualifiers in nested pointer types"
|
||||
FAIL_REGEX "incompatible pointer type"
|
||||
FAIL_REGEX "invalid conversion"
|
||||
FAIL_REGEX "no matching function")
|
||||
|
||||
set(CMAKE_REQUIRED_INCLUDES)
|
||||
set(CMAKE_REQUIRED_LIBRARIES)
|
||||
endif()
|
||||
|
||||
mark_as_advanced(ICONV_INCLUDE_DIR ICONV_LIBRARY ICONV_SECOND_ARGUMENT_IS_CONST)
|
||||
@@ -1 +1,5 @@
|
||||
set(UTFCPP_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/third-party/utfcpp/source)
|
||||
add_library(utf8::cpp INTERFACE IMPORTED)
|
||||
|
||||
target_include_directories(utf8::cpp
|
||||
INTERFACE
|
||||
${CMAKE_CURRENT_LIST_DIR}/../third-party/utfcpp/source)
|
||||
|
||||
@@ -1 +1,5 @@
|
||||
set(WIDE_INTEGER_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/third-party/wide-integer)
|
||||
add_library(WideInteger::WideInteger INTERFACE IMPORTED)
|
||||
|
||||
target_include_directories(WideInteger::WideInteger
|
||||
INTERFACE
|
||||
${CMAKE_CURRENT_LIST_DIR}/../third-party/wide-integer)
|
||||
|
||||
@@ -129,6 +129,8 @@ function(tr_process_list_conditions VAR_PREFIX)
|
||||
endfunction()
|
||||
|
||||
macro(tr_add_external_auto_library ID DIRNAME LIBNAME)
|
||||
cmake_parse_arguments(_TAEAL_ARG "" "TARGET" "CMAKE_ARGS" ${ARGN})
|
||||
|
||||
if(USE_SYSTEM_${ID})
|
||||
tr_get_required_flag(USE_SYSTEM_${ID} SYSTEM_${ID}_IS_REQUIRED)
|
||||
find_package(${ID} ${${ID}_MINIMUM} ${SYSTEM_${ID}_IS_REQUIRED})
|
||||
@@ -161,7 +163,6 @@ macro(tr_add_external_auto_library ID DIRNAME LIBNAME)
|
||||
ExternalProject_Add(
|
||||
${${ID}_UPSTREAM_TARGET}
|
||||
URL "${CMAKE_SOURCE_DIR}/third-party/${DIRNAME}"
|
||||
${ARGN}
|
||||
PREFIX "${${ID}_PREFIX}"
|
||||
CMAKE_ARGS
|
||||
-Wno-dev # We don't want to be warned over unused variables
|
||||
@@ -175,9 +176,29 @@ macro(tr_add_external_auto_library ID DIRNAME LIBNAME)
|
||||
"-DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>"
|
||||
"-DCMAKE_INSTALL_LIBDIR:STRING=lib"
|
||||
${${ID}_EXT_PROJ_CMAKE_ARGS}
|
||||
${_TAEAL_ARG_CMAKE_ARGS}
|
||||
BUILD_BYPRODUCTS "${${ID}_LIBRARY}")
|
||||
|
||||
set_property(TARGET ${${ID}_UPSTREAM_TARGET} PROPERTY FOLDER "third-party")
|
||||
|
||||
# Imported target (below) requires include directories to be present at configuration time
|
||||
file(MAKE_DIRECTORY ${${ID}_INCLUDE_DIRS})
|
||||
endif()
|
||||
|
||||
if(_TAEAL_ARG_TARGET)
|
||||
add_library(${_TAEAL_ARG_TARGET} INTERFACE IMPORTED)
|
||||
|
||||
target_include_directories(${_TAEAL_ARG_TARGET}
|
||||
INTERFACE
|
||||
${${ID}_INCLUDE_DIRS})
|
||||
|
||||
target_link_libraries(${_TAEAL_ARG_TARGET}
|
||||
INTERFACE
|
||||
${${ID}_LIBRARIES})
|
||||
|
||||
if(${ID}_UPSTREAM_TARGET)
|
||||
add_dependencies(${_TAEAL_ARG_TARGET} ${${ID}_UPSTREAM_TARGET})
|
||||
endif()
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user