Merge pull request #577 from andlaus/make_as_needed_optional

Make as needed optional
This commit is contained in:
Bård Skaflestad
2014-04-22 10:29:18 +02:00
2 changed files with 4 additions and 10 deletions

View File

@@ -232,14 +232,6 @@ if (UMFPACK_LIBRARY)
set (UMFPACK_EXTRA_LIBS "-NOTFOUND")
endif (CHOLMOD_LIBRARIES)
endif (HAVE_UMFPACK_WITHOUT_CHOLMOD)
# test if umfpack is underlinked (CentOS 5.9), i.e. doesn't specify
# that it depends on amd. in that case, force amd to be linked
if (UMFPACK_EXTRA_LIBS AND (CMAKE_CXX_PLATFORM_ID STREQUAL "Linux") AND CMAKE_COMPILER_IS_GNUCC)
try_compile_umfpack (HAVE_UMFPACK_NOT_UNDERLINKED "-Wl,--as-needed" ${UMFPACK_EXTRA_LIBS})
if (NOT HAVE_UMFPACK_NOT_UNDERLINKED)
list (APPEND UMFPACK_LINKER_FLAGS "-Wl,--no-as-needed")
endif (NOT HAVE_UMFPACK_NOT_UNDERLINKED)
endif (UMFPACK_EXTRA_LIBS AND (CMAKE_CXX_PLATFORM_ID STREQUAL "Linux") AND CMAKE_COMPILER_IS_GNUCC)
list (APPEND UMFPACK_LIBRARIES ${UMFPACK_EXTRA_LIBS})
list (REVERSE UMFPACK_LIBRARIES)
list (REMOVE_DUPLICATES UMFPACK_LIBRARIES)

View File

@@ -23,9 +23,11 @@ function (prepend var_name value)
endif (NOT ("${_var_pre}" STREQUAL "${value}"))
endfunction (prepend var_name value)
option (ONLY_NEEDED_LIBRARIES "Instruct the linker to not use libraries which are unused" OFF)
# only ELF shared objects can be underlinked, and only GNU will accept
# these parameters; otherwise just leave it to the defaults
if ((CMAKE_CXX_PLATFORM_ID STREQUAL "Linux") AND CMAKE_COMPILER_IS_GNUCC)
if ((CMAKE_CXX_PLATFORM_ID STREQUAL "Linux") AND CMAKE_COMPILER_IS_GNUCC AND ONLY_NEEDED_LIBRARIES)
# these are the modules whose probes will turn up incompatible
# flags on some systems
set (_maybe_underlinked
@@ -45,4 +47,4 @@ if ((CMAKE_CXX_PLATFORM_ID STREQUAL "Linux") AND CMAKE_COMPILER_IS_GNUCC)
prepend (CMAKE_MODULE_LINKER_FLAGS "-Wl,--as-needed")
prepend (CMAKE_SHARED_LINKER_FLAGS "-Wl,--as-needed")
endif (NOT _underlinked)
endif ((CMAKE_CXX_PLATFORM_ID STREQUAL "Linux") AND CMAKE_COMPILER_IS_GNUCC)
endif ((CMAKE_CXX_PLATFORM_ID STREQUAL "Linux") AND CMAKE_COMPILER_IS_GNUCC AND ONLY_NEEDED_LIBRARIES)