From d36885590dffef10e061f64d09897c8af46d274c Mon Sep 17 00:00:00 2001 From: Jinzhe Zeng Date: Mon, 19 Apr 2021 20:09:23 -0400 Subject: [PATCH] only enable link what you use on GNU compilers Clang doesn't support this flag, cause an error on osx: > ld: unknown option: --no-as-needed This commit should be cherry-picked to `r1.2` branch. --- source/CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 84c3d326da..9bb4486de6 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -1,6 +1,8 @@ cmake_minimum_required(VERSION 3.7) project(DeePMD) -set(CMAKE_LINK_WHAT_YOU_USE TRUE) +if (CMAKE_COMPILER_IS_GNU) + set(CMAKE_LINK_WHAT_YOU_USE TRUE) +endif () # build cpp or python interfaces if (NOT DEFINED BUILD_CPP_IF)