[mlpack-git] master, mlpack-1.0.x: Link against libstd++ when using Clang, and also use -Wall. (452d68a)
gitdub at big.cc.gt.atl.ga.us
gitdub at big.cc.gt.atl.ga.us
Thu Mar 5 21:49:12 EST 2015
Repository : https://github.com/mlpack/mlpack
On branches: master,mlpack-1.0.x
Link : https://github.com/mlpack/mlpack/compare/904762495c039e345beba14c1142fd719b3bd50e...f94823c800ad6f7266995c700b1b630d5ffdcf40
>---------------------------------------------------------------
commit 452d68a70adfc2583b6d74957f01fe45b0b90755
Author: Ryan Curtin <ryan at ratml.org>
Date: Mon Jun 23 21:06:24 2014 +0000
Link against libstd++ when using Clang, and also use -Wall.
>---------------------------------------------------------------
452d68a70adfc2583b6d74957f01fe45b0b90755
CMakeLists.txt | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index cce7e61..5895e7e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -14,10 +14,17 @@ option(MATLAB_BINDINGS "Compile MATLAB bindings if MATLAB is found." OFF)
# Set the CFLAGS and CXXFLAGS depending on the options the user specified.
# Only GCC-like compilers support -Wextra, and other compilers give tons of
# output for -Wall, so only -Wall and -Wextra on GCC.
-if(CMAKE_COMPILER_IS_GNUCC)
+if(CMAKE_COMPILER_IS_GNUCC OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra")
-endif(CMAKE_COMPILER_IS_GNUCC)
+endif(CMAKE_COMPILER_IS_GNUCC OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
+
+# If using clang, we have to link against libstdc++ (at least on some systems).
+if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lstdc++")
+ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -lstdc++")
+ set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -lstdc++")
+endif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
# Debugging CFLAGS. Turn optimizations off; turn debugging symbols on.
if(DEBUG)
More information about the mlpack-git
mailing list