summaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authorPino Toscano <pino@kde.org>2010-03-20 17:51:07 +0100
committerPino Toscano <pino@kde.org>2010-03-20 17:51:07 +0100
commit97da1f9d060493d9fb54a20e980c3f6e2b82c97e (patch)
tree4ac97dc1db6ed00f5e57c6b7c368dd384c58bde3 /cmake
parent223bce6d14e632f457a81b2ec091fe16369d2eb6 (diff)
[CMake] check whether a link flag is supported before adding it to the link flags
this way we can add -Wl,--as-needed and -Wl,--no-add-needed only if the current GCC/LD supports them
Diffstat (limited to 'cmake')
-rw-r--r--cmake/modules/PopplerMacros.cmake23
1 files changed, 20 insertions, 3 deletions
diff --git a/cmake/modules/PopplerMacros.cmake b/cmake/modules/PopplerMacros.cmake
index 037f0fd0..36515629 100644
--- a/cmake/modules/PopplerMacros.cmake
+++ b/cmake/modules/PopplerMacros.cmake
@@ -70,6 +70,14 @@ macro(SHOW_END_MESSAGE_YESNO what enabled)
show_end_message("${what}" "${enabled_string}")
endmacro(SHOW_END_MESSAGE_YESNO)
+macro(POPPLER_CHECK_LINK_FLAG flag var)
+ set(_save_CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}")
+ include(CheckCXXSourceCompiles)
+ set(CMAKE_REQUIRED_LIBRARIES "${flag}")
+ check_cxx_source_compiles("int main() { return 0; }" ${var})
+ set(CMAKE_REQUIRED_LIBRARIES "${_save_CMAKE_REQUIRED_LIBRARIES}")
+endmacro(POPPLER_CHECK_LINK_FLAG)
+
set(CMAKE_SYSTEM_INCLUDE_PATH ${CMAKE_SYSTEM_INCLUDE_PATH}
"${CMAKE_INSTALL_PREFIX}/include" )
@@ -108,9 +116,18 @@ if(CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_C_FLAGS_DEBUGFULL "-g3 -fno-inline")
set(CMAKE_C_FLAGS_PROFILE "-g3 -fno-inline -ftest-coverage -fprofile-arcs")
- set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--as-needed -Wl,--no-add-needed")
- set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--as-needed -Wl,--no-add-needed")
- set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--as-needed -Wl,--no-add-needed")
+ poppler_check_link_flag("-Wl,--as-needed" GCC_HAS_AS_NEEDED)
+ if(GCC_HAS_AS_NEEDED)
+ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--as-needed")
+ set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--as-needed")
+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--as-needed")
+ endif(GCC_HAS_AS_NEEDED)
+ poppler_check_link_flag("-Wl,--no-add-needed" GCC_HAS_NO_ADD_NEEDED)
+ if(GCC_HAS_NO_ADD_NEEDED)
+ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-add-needed")
+ set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--no-add-needed")
+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--no-add-needed")
+ endif(GCC_HAS_NO_ADD_NEEDED)
endif (CMAKE_COMPILER_IS_GNUCXX)
if(CMAKE_C_COMPILER MATCHES "icc")