From ef71462e3e500f3161c11885447776658438d9ec Mon Sep 17 00:00:00 2001 From: Alexander Neundorf Date: Wed, 18 Jun 2008 19:02:20 -0400 Subject: BUG: modify the compiler flags only if KDE3 has actually been found Alex --- Modules/FindKDE3.cmake | 86 ++++++++++++++++++++++++++------------------------ 1 file changed, 45 insertions(+), 41 deletions(-) diff --git a/Modules/FindKDE3.cmake b/Modules/FindKDE3.cmake index 55f4a1e..1552e17 100644 --- a/Modules/FindKDE3.cmake +++ b/Modules/FindKDE3.cmake @@ -80,44 +80,6 @@ FIND_PACKAGE(Qt3 ${_REQ_STRING_KDE3}) FIND_PACKAGE(X11 ${_REQ_STRING_KDE3}) -# add some KDE specific stuff -SET(KDE3_DEFINITIONS -DQT_CLEAN_NAMESPACE -D_GNU_SOURCE) -SET(_KDE3_USE_FLAGS FALSE) -IF(CMAKE_COMPILER_IS_GNUCXX) - SET(_KDE3_USE_FLAGS TRUE) # use flags for gnu compiler - EXECUTE_PROCESS(COMMAND ${CMAKE_CXX_COMPILER} --version - OUTPUT_VARIABLE out) - # gnu gcc 2.96 does not work with flags -# I guess 2.95 also doesn't then - IF("${out}" MATCHES "2.9[56]") - SET(_KDE3_USE_FLAGS FALSE) - ENDIF("${out}" out MATCHES "2.9[56]") -ENDIF(CMAKE_COMPILER_IS_GNUCXX) - -#only on linux, but NOT e.g. on FreeBSD: -IF(CMAKE_SYSTEM_NAME MATCHES "Linux" AND _KDE3_USE_FLAGS) - SET (KDE3_DEFINITIONS ${KDE3_DEFINITIONS} -D_XOPEN_SOURCE=500 -D_BSD_SOURCE) - SET ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-long-long -ansi -Wundef -Wcast-align -Wconversion -Wchar-subscripts -Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security -Wmissing-format-attribute -fno-common") - SET ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wnon-virtual-dtor -Wno-long-long -ansi -Wundef -Wcast-align -Wconversion -Wchar-subscripts -Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security -fno-exceptions -fno-check-new -fno-common") -ENDIF(CMAKE_SYSTEM_NAME MATCHES "Linux" AND _KDE3_USE_FLAGS) - -# works on FreeBSD, NOT tested on NetBSD and OpenBSD -IF (CMAKE_SYSTEM_NAME MATCHES BSD AND _KDE3_USE_FLAGS) - SET ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-long-long -ansi -Wundef -Wcast-align -Wconversion -Wchar-subscripts -Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security -Wmissing-format-attribute -fno-common") - SET ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wnon-virtual-dtor -Wno-long-long -Wundef -Wcast-align -Wconversion -Wchar-subscripts -Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security -Wmissing-format-attribute -fno-exceptions -fno-check-new -fno-common") -ENDIF (CMAKE_SYSTEM_NAME MATCHES BSD AND _KDE3_USE_FLAGS) - -# if no special buildtype is selected, add -O2 as default optimization -IF (NOT CMAKE_BUILD_TYPE AND _KDE3_USE_FLAGS) - SET ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2") - SET ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2") -ENDIF (NOT CMAKE_BUILD_TYPE AND _KDE3_USE_FLAGS) - - -#SET(CMAKE_SHARED_LINKER_FLAGS "-avoid-version -module -Wl,--no-undefined -Wl,--allow-shlib-undefined") -#SET(CMAKE_SHARED_LINKER_FLAGS "-Wl,--fatal-warnings -avoid-version -Wl,--no-undefined -lc") -#SET(CMAKE_MODULE_LINKER_FLAGS "-Wl,--fatal-warnings -avoid-version -Wl,--no-undefined -lc") - #now try to find some kde stuff FIND_PROGRAM(KDECONFIG_EXECUTABLE NAMES kde-config HINTS @@ -206,9 +168,6 @@ FIND_PROGRAM(KDE3_KCFGC_EXECUTABLE NAMES kconfig_compiler /opt/kde/bin ) -# KDE3Macros.cmake contains all the KDE specific macros -INCLUDE(KDE3Macros) - #SET KDE3_FOUND IF (KDE3_INCLUDE_DIR AND KDE3_LIB_DIR AND KDE3_DCOPIDL_EXECUTABLE AND KDE3_DCOPIDL2CPP_EXECUTABLE AND KDE3_KCFGC_EXECUTABLE) @@ -217,6 +176,51 @@ ELSE (KDE3_INCLUDE_DIR AND KDE3_LIB_DIR AND KDE3_DCOPIDL_EXECUTABLE AND KDE3_DCO SET(KDE3_FOUND FALSE) ENDIF (KDE3_INCLUDE_DIR AND KDE3_LIB_DIR AND KDE3_DCOPIDL_EXECUTABLE AND KDE3_DCOPIDL2CPP_EXECUTABLE AND KDE3_KCFGC_EXECUTABLE) +# add some KDE specific stuff +SET(KDE3_DEFINITIONS -DQT_CLEAN_NAMESPACE -D_GNU_SOURCE) + +# set compiler flags only if KDE3 has actually been found +IF(KDE3_FOUND) + SET(_KDE3_USE_FLAGS FALSE) + IF(CMAKE_COMPILER_IS_GNUCXX) + SET(_KDE3_USE_FLAGS TRUE) # use flags for gnu compiler + EXECUTE_PROCESS(COMMAND ${CMAKE_CXX_COMPILER} --version + OUTPUT_VARIABLE out) + # gnu gcc 2.96 does not work with flags + # I guess 2.95 also doesn't then + IF("${out}" MATCHES "2.9[56]") + SET(_KDE3_USE_FLAGS FALSE) + ENDIF("${out}" out MATCHES "2.9[56]") + ENDIF(CMAKE_COMPILER_IS_GNUCXX) + + #only on linux, but NOT e.g. on FreeBSD: + IF(CMAKE_SYSTEM_NAME MATCHES "Linux" AND _KDE3_USE_FLAGS) + SET (KDE3_DEFINITIONS ${KDE3_DEFINITIONS} -D_XOPEN_SOURCE=500 -D_BSD_SOURCE) + SET ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-long-long -ansi -Wundef -Wcast-align -Wconversion -Wchar-subscripts -Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security -Wmissing-format-attribute -fno-common") + SET ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wnon-virtual-dtor -Wno-long-long -ansi -Wundef -Wcast-align -Wconversion -Wchar-subscripts -Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security -fno-exceptions -fno-check-new -fno-common") + ENDIF(CMAKE_SYSTEM_NAME MATCHES "Linux" AND _KDE3_USE_FLAGS) + + # works on FreeBSD, NOT tested on NetBSD and OpenBSD + IF (CMAKE_SYSTEM_NAME MATCHES BSD AND _KDE3_USE_FLAGS) + SET ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-long-long -ansi -Wundef -Wcast-align -Wconversion -Wchar-subscripts -Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security -Wmissing-format-attribute -fno-common") + SET ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wnon-virtual-dtor -Wno-long-long -Wundef -Wcast-align -Wconversion -Wchar-subscripts -Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security -Wmissing-format-attribute -fno-exceptions -fno-check-new -fno-common") + ENDIF (CMAKE_SYSTEM_NAME MATCHES BSD AND _KDE3_USE_FLAGS) + + # if no special buildtype is selected, add -O2 as default optimization + IF (NOT CMAKE_BUILD_TYPE AND _KDE3_USE_FLAGS) + SET ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2") + SET ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2") + ENDIF (NOT CMAKE_BUILD_TYPE AND _KDE3_USE_FLAGS) + +#SET(CMAKE_SHARED_LINKER_FLAGS "-avoid-version -module -Wl,--no-undefined -Wl,--allow-shlib-undefined") +#SET(CMAKE_SHARED_LINKER_FLAGS "-Wl,--fatal-warnings -avoid-version -Wl,--no-undefined -lc") +#SET(CMAKE_MODULE_LINKER_FLAGS "-Wl,--fatal-warnings -avoid-version -Wl,--no-undefined -lc") +ENDIF(KDE3_FOUND) + + +# KDE3Macros.cmake contains all the KDE specific macros +INCLUDE(KDE3Macros) + MACRO (KDE3_PRINT_RESULTS) IF(KDE3_INCLUDE_DIR) -- cgit v0.12