diff --git a/CMakeLists.txt b/CMakeLists.txt
index 37daaf09f2..bbf71b02a6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,4 +1,36 @@
-add_subdirectory( lib )
+########### configure tests ###############
+
+# KWIN_HAVE_COMPOSITING - whether any compositing support is available
+if( X11_Xcomposite_FOUND AND X11_Xdamage_FOUND )
+ set( KWIN_HAVE_COMPOSITING 1 )
+endif( X11_Xcomposite_FOUND AND X11_Xdamage_FOUND )
+
+# KWIN_HAVE_OPENGL_COMPOSITING - whether OpenGL-based compositing support is available
+if( KWIN_HAVE_COMPOSITING AND OPENGL_FOUND )
+ set( KWIN_HAVE_OPENGL_COMPOSITING 1 )
+endif( KWIN_HAVE_COMPOSITING AND OPENGL_FOUND )
+
+# KWIN_HAVE_XRENDER_COMPOSITING - whether XRender-based compositing support is available
+if( KWIN_HAVE_COMPOSITING AND X11_Xrender_FOUND AND X11_Xfixes_FOUND )
+ set( KWIN_HAVE_XRENDER_COMPOSITING 1 )
+endif( KWIN_HAVE_COMPOSITING AND X11_Xrender_FOUND AND X11_Xfixes_FOUND )
+
+# safety
+if( KWIN_HAVE_OPENGL_COMPOSITING OR KWIN_HAVE_XRENDER_COMPOSITING )
+ # ok
+else( KWIN_HAVE_OPENGL_COMPOSITING OR KWIN_HAVE_XRENDER_COMPOSITING )
+ set( KWIN_HAVE_COMPOSITING ) # unset
+endif( KWIN_HAVE_OPENGL_COMPOSITING OR KWIN_HAVE_XRENDER_COMPOSITING )
+
+macro_bool_to_01( OPENGL_FOUND KWIN_HAVE_OPENGL )
+
+# for things that are also used by kwin libraries
+configure_file(lib/kwinconfig.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/lib/kwinconfig.h )
+# for kwin internal things
+configure_file(config-kwin.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-kwin.h )
+
+
+########### global ###############
include_directories(
${CMAKE_CURRENT_BINARY_DIR}/lib
@@ -7,16 +39,14 @@ include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/effects
)
+
+add_subdirectory( lib )
add_subdirectory( killer )
add_subdirectory( kcmkwin )
add_subdirectory( clients )
add_subdirectory( effects )
add_subdirectory( data )
-configure_file(config-kwin.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-kwin.h )
-include_directories(${CMAKE_CURRENT_BINARY_DIR})
-
-
########### next target ###############
set(kwin_KDEINIT_SRCS
diff --git a/effects/CMakeLists.txt b/effects/CMakeLists.txt
index aa596cc142..5ed30a6ffa 100644
--- a/effects/CMakeLists.txt
+++ b/effects/CMakeLists.txt
@@ -91,7 +91,7 @@ install( FILES
zoom_config.desktop
DESTINATION ${SERVICES_INSTALL_DIR}/kwin )
-if(OPENGL_FOUND)
+if(KWIN_HAVE_OPENGL_COMPOSITING)
# opengl-based effects
SET(kwin4_effect_builtins_sources ${kwin4_effect_builtins_sources}
blur.cpp
@@ -154,10 +154,10 @@ if(OPENGL_FOUND)
sharpen_config.desktop
trackmouse_config.desktop
DESTINATION ${SERVICES_INSTALL_DIR}/kwin )
-endif(OPENGL_FOUND)
+endif(KWIN_HAVE_OPENGL_COMPOSITING)
# showfps, showpaint - need both xrender and opengl
-if( OPENGL_FOUND AND X11_Xrender_FOUND )
+if(KWIN_HAVE_OPENGL_COMPOSITING AND KWIN_HAVE_XRENDER_COMPOSITING)
SET(kwin4_effect_builtins_sources ${kwin4_effect_builtins_sources}
showfps.cpp
showpaint.cpp
@@ -166,16 +166,16 @@ if( OPENGL_FOUND AND X11_Xrender_FOUND )
showfps.desktop
showpaint.desktop
DESTINATION ${SERVICES_INSTALL_DIR}/kwin )
-endif( OPENGL_FOUND AND X11_Xrender_FOUND )
+endif(KWIN_HAVE_OPENGL_COMPOSITING AND KWIN_HAVE_XRENDER_COMPOSITING)
# add the plugin
KWIN4_ADD_EFFECT(builtins ${kwin4_effect_builtins_sources})
KWIN4_ADD_EFFECT_CONFIG(builtins ${kwin4_effect_builtins_config_sources})
# link to xrender if necessary
# note that libkwineffects already links to opengl, so no need to add this here
-if (X11_Xrender_FOUND)
+if (KWIN_HAVE_XRENDER_COMPOSITING)
target_link_libraries(kwin4_effect_builtins ${X11_Xrender_LIB})
-endif (X11_Xrender_FOUND)
+endif (KWIN_HAVE_XRENDER_COMPOSITING)
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
index 7d0b66bce6..ba8417ba6d 100644
--- a/lib/CMakeLists.txt
+++ b/lib/CMakeLists.txt
@@ -1,7 +1,3 @@
-
-configure_file(kwinconfig.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/kwinconfig.h )
-
-
########### next target ###############
set(kdecorations_LIB_SRCS
diff --git a/lib/kwinconfig.h.cmake b/lib/kwinconfig.h.cmake
index 8769f764ea..b653e8d8b9 100644
--- a/lib/kwinconfig.h.cmake
+++ b/lib/kwinconfig.h.cmake
@@ -15,30 +15,6 @@
#undef KWIN_HAVE_OPENGL
#endif
-#if ${HAVE_XRENDER}
-#define KWIN_HAVE_XRENDER 1
-#else
-#undef KWIN_HAVE_XRENDER
-#endif
-
-#if ${HAVE_XFIXES}
-#define KWIN_HAVE_XFIXES 1
-#else
-#undef KWIN_HAVE_XFIXES
-#endif
-
-#if ${HAVE_XDAMAGE}
-#define KWIN_HAVE_XDAMAGE 1
-#else
-#undef KWIN_HAVE_XDAMAGE
-#endif
-
-#if ${HAVE_XCOMPOSITE}
-#define KWIN_HAVE_XCOMPOSITE 1
-#else
-#undef KWIN_HAVE_XCOMPOSITE
-#endif
-
/*
These should be primarily used to detect what kind of compositing
@@ -47,28 +23,13 @@
*/
/* KWIN_HAVE_COMPOSITING - whether any compositing support is available */
-#if defined( KWIN_HAVE_XCOMPOSITE ) && defined( KWIN_HAVE_XDAMAGE )
-#define KWIN_HAVE_COMPOSITING 1
-#else
-#undef KWIN_HAVE_COMPOSITING
-#endif
+#cmakedefine KWIN_HAVE_COMPOSITING
/* KWIN_HAVE_OPENGL_COMPOSITING - whether OpenGL-based compositing support is available */
-#if defined( KWIN_HAVE_COMPOSITING ) && defined( KWIN_HAVE_OPENGL )
-#define KWIN_HAVE_OPENGL_COMPOSITING 1
-#else
-#undef KWIN_HAVE_OPENGL_COMPOSITING
-#endif
+#cmakedefine KWIN_HAVE_OPENGL_COMPOSITING
/* KWIN_HAVE_XRENDER_COMPOSITING - whether XRender-based compositing support is available */
-#if defined( KWIN_HAVE_COMPOSITING ) && defined( KWIN_HAVE_XRENDER ) && defined( KWIN_HAVE_XFIXES )
-#define KWIN_HAVE_XRENDER_COMPOSITING 1
-#else
-#undef KWIN_HAVE_XRENDER_COMPOSITING
-#endif
+#cmakedefine KWIN_HAVE_XRENDER_COMPOSITING
-#if !defined( KWIN_HAVE_OPENGL_COMPOSITING ) && !defined( KWIN_HAVE_XRENDER_COMPOSITING )
-#undef KWIN_HAVE_COMPOSITING
-#endif
#endif
diff --git a/lib/kwineffects.cpp b/lib/kwineffects.cpp
index e93f8eef5a..3f4d8e58f5 100644
--- a/lib/kwineffects.cpp
+++ b/lib/kwineffects.cpp
@@ -35,7 +35,7 @@ along with this program. If not, see .
#include
-#ifdef KWIN_HAVE_XRENDER
+#ifdef KWIN_HAVE_XRENDER_COMPOSITING
#include
#endif