ClickHouse/cmake
Azat Khuzhin a5cb0aed12
Sanitize LINK_LIBRARIES property for the directories (#12160)
When you will try to link target with the directory (that exists), cmake will
skip this without an error, only the following warning will be reported:

    target_link_libraries(main /tmp)

    WARNING: Target "main" requests linking to directory "/tmp".  Targets may link only to libraries.  CMake is dropping the item.

And there is no cmake policy that controls this.
(I guess the reason that it is allowed is because of FRAMEWORK for OSX).

So to avoid error-prone cmake rules, this can be sanitized.
There are the following ways:
- overwrite target_link_libraries()/link_libraries() and check *before*
  calling real macro, but this requires duplicate all supported syntax
  -- too complex
- overwrite target_link_libraries() and check LINK_LIBRARIES property, this
  works great
  -- but cannot be used with link_libraries()
- use BUILDSYSTEM_TARGETS property to get list of all targets and sanitize
  -- this will work.

I also tested it with the following patch:

    $ git di
    diff --git a/base/daemon/CMakeLists.txt b/base/daemon/CMakeLists.txt
    index 26d59a57e7..35e6ff6432 100644
    --- a/base/daemon/CMakeLists.txt
    +++ b/base/daemon/CMakeLists.txt
    @@ -9,4 +9,5 @@ target_link_libraries (daemon PUBLIC loggers PRIVATE clickhouse_common_io clickh

     if (USE_SENTRY)
         target_link_libraries (daemon PRIVATE ${SENTRY_LIBRARY})
    +    target_link_libraries (daemon PRIVATE /tmp)
     endif ()

And it works:

    CMake Error at cmake/sanitize_target_link_libraries.cmake:48 (message):
       daemon requested to link with directory: /tmp
    Call Stack (most recent call first):
      cmake/sanitize_target_link_libraries.cmake:55 (sanitize_link_libraries)
      CMakeLists.txt:425 (include)

Refs: #12041
2020-07-07 19:22:41 +03:00
..
darwin Catalina support 2020-01-10 00:53:07 +01:00
find Merge pull request #12041 from azat/curl-proper-cmake 2020-07-06 06:31:51 +03:00
freebsd Fix mistake in FreeBSD toolchain 2020-05-17 06:57:16 +03:00
linux Make the comment more readable. 2020-06-22 17:59:38 +03:00
Modules Refactor CMake build files (#11390) 2020-06-09 13:54:49 +03:00
toolchain Update cross-builds to use clang-10 compiler (#10724) 2020-05-07 15:32:17 +03:00
yandex Add lost VERSION_* defines to ya.make.versions.inc 2020-05-28 19:44:30 +03:00
add_check.cmake cmake: Avoiding check target conflicts. [#CHEBOTAREV-14] 2017-08-24 16:37:27 +03:00
add_warning.cmake Code clean-up 2020-02-16 11:04:03 +03:00
analysis.cmake dbms/ → src/ 2020-04-03 18:14:31 +03:00
arch.cmake Add cross-compile build for FreeBSD (#9643) 2020-04-07 11:33:49 +03:00
autogenerated_versions.txt Auto version update to [20.6.1.1] [54436] 2020-06-22 20:40:26 +03:00
contrib_finder.cmake cmake/find_* → cmake/find/* 2019-09-13 17:54:22 +03:00
cpu_features.cmake cmake/test_cpu → cmake/cpu_features 2019-09-13 17:54:22 +03:00
dbms_glob_sources.cmake Better add_globs 2019-10-22 15:09:49 +08:00
fuzzer.cmake split fuzzers and sanitizers 2020-04-25 10:12:38 +03:00
generate_code.cmake CLICKHOUSE-4137 DictionaryFactory, DictionarySourceFactory (#3653) 2018-11-28 14:37:12 +03:00
limit_jobs.cmake Better compile with low memory; Fix macos build, add utils/build/build_debian_unbundled_split.sh test script (#4030) 2019-01-11 15:40:19 +03:00
print_flags.cmake CLICKHOUSE-3600 Use correct lld version, cmake fixes (#1968) 2018-02-26 21:34:22 +03:00
print_include_directories.cmake Refactor CMake build files (#11390) 2020-06-09 13:54:49 +03:00
protobuf_generate_cpp.cmake Fix build scripts related to protobuf and gRPC for Mac. 2020-05-29 23:09:01 +03:00
sanitize_target_link_libraries.cmake Sanitize LINK_LIBRARIES property for the directories (#12160) 2020-07-07 19:22:41 +03:00
sanitize.cmake Remove obsolete TSan suppressions 2020-05-11 10:05:46 +03:00
target.cmake Fix FreeBSD build (#10150) 2020-05-02 15:07:57 +03:00
tools.cmake Cleaned up AppleClang version check 2020-05-06 20:47:13 +04:00
version.cmake Add anonymize option and version tag 2020-05-30 11:02:13 +03:00
warnings.cmake Disable -Wsequence-point on gcc10 (otherwise it stuck on GatherUtils compiling) 2020-05-21 21:18:34 +03:00