From ee8c419517fad9d7bcbf9fa13321a024889e5440 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 dc35ee5dc0..b92ea9574d 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)