diff options
author | Evan Shelhamer <shelhamer@imaginarynumber.net> | 2016-02-11 13:19:50 -0800 |
---|---|---|
committer | Evan Shelhamer <shelhamer@imaginarynumber.net> | 2016-02-11 13:19:50 -0800 |
commit | 0c89b38b142ba1bb3f2339e55c9aecc47447f876 (patch) | |
tree | 9674221263ffc59bfb66881ce64a11f34a7509d8 | |
parent | 33f2445b47fddd260ac59901c0920f2bb671d579 (diff) | |
parent | 12f85982c4599734a43d95e2c4b7565aad410530 (diff) | |
download | caffeonacl-0c89b38b142ba1bb3f2339e55c9aecc47447f876.tar.gz caffeonacl-0c89b38b142ba1bb3f2339e55c9aecc47447f876.tar.bz2 caffeonacl-0c89b38b142ba1bb3f2339e55c9aecc47447f876.zip |
Merge pull request #3451 from intelcaffe/cmake-clang-fix
Fix to cmake build for clang on linux
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | cmake/Targets.cmake | 19 |
2 files changed, 12 insertions, 9 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 32cc42ac..c5d99cef 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,6 +47,8 @@ if(UNIX OR APPLE) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -Wall") endif() +caffe_set_caffe_link() + if(USE_libstdcpp) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libstdc++") message("-- Warning: forcing libstdc++ (controlled by USE_libstdcpp option in cmake)") diff --git a/cmake/Targets.cmake b/cmake/Targets.cmake index 2401f252..a796d005 100644 --- a/cmake/Targets.cmake +++ b/cmake/Targets.cmake @@ -1,16 +1,17 @@ ################################################################################################ # Defines global Caffe_LINK flag, This flag is required to prevent linker from excluding # some objects which are not addressed directly but are registered via static constructors -if(BUILD_SHARED_LIBS) - set(Caffe_LINK caffe) -else() - if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - set(Caffe_LINK -Wl,-force_load caffe) - elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - set(Caffe_LINK -Wl,--whole-archive caffe -Wl,--no-whole-archive) +macro(caffe_set_caffe_link) + if(BUILD_SHARED_LIBS) + set(Caffe_LINK caffe) + else() + if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + set(Caffe_LINK -Wl,-force_load caffe) + elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + set(Caffe_LINK -Wl,--whole-archive caffe -Wl,--no-whole-archive) + endif() endif() -endif() - +endmacro() ################################################################################################ # Convenient command to setup source group for IDEs that support this feature (VS, XCode) # Usage: |