Index: OpenSceneGraph/trunk/CMakeLists.txt
===================================================================
--- OpenSceneGraph/trunk/CMakeLists.txt (revision 11817)
+++ OpenSceneGraph/trunk/CMakeLists.txt (revision 11904)
@@ -387,4 +387,7 @@
 FIND_PACKAGE(SDL)
 
+# Include macro utilities here
+INCLUDE(OsgMacroUtils)
+
 # To select a specific version of QT define DESIRED_QT_VERSION
 # via cmake -DDESIRED_QT_VERSION=4
@@ -532,6 +535,11 @@
 # On CMake 2.6.x use the newly minted CMAKE_LIBRARY_OUTPUT_DIRECTORY,
 # CMAKE_ARCHIVE_OUTPUT_DIRECTORY & CMAKE_RUNTIME_OUTPUT_DIRECTORY
-
+#
+# CMake >= 2.8.1 changed the output directory algorithm (See doc).
+# Here we also set per-configuration directories (CMAKE_*_OUTPUT_DIRECTORY_<CONFIG>), or else binaries are generated in /bin/Debug and /bin/Release, etc. with MSVC and Xcode.
+# (Doc reads "multi-configuration generators (VS, Xcode) do NOT append a per-configuration subdirectory to the specified directory").
+# The workaround for 2.6.x (adding "../" as an output prefix for each target) seem to have no effect in >=2.8.1, so there is no need to change this.
 IF(CMAKE_MAJOR_VERSION EQUAL 2 AND CMAKE_MINOR_VERSION LESS 5)
+    # If CMake < 2.6.0
     SET(EXECUTABLE_OUTPUT_PATH ${OUTPUT_BINDIR})
     SET(LIBRARY_OUTPUT_PATH    ${OUTPUT_LIBDIR})
@@ -545,4 +553,19 @@
         SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${OUTPUT_LIBDIR})
     ENDIF(WIN32)
+
+    # Testing CMAKE_VERSION is possible in >= 2.6.4 only
+    BUILDER_VERSION_GREATER(2 8 0)
+    IF(VALID_BUILDER_VERSION)  # If CMake >= 2.8.1
+        FOREACH(CONF ${CMAKE_CONFIGURATION_TYPES})        # For each configuration (Debug, Release, MinSizeRel... and/or anything the user chooses)
+            STRING(TOUPPER "${CONF}" CONF)                # Go uppercase (DEBUG, RELEASE...)
+            SET("CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CONF}" "${OUTPUT_LIBDIR}")
+            SET("CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CONF}" "${OUTPUT_BINDIR}")
+            IF(WIN32)
+                SET("CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CONF}" "${OUTPUT_BINDIR}")
+            ELSE()
+                SET("CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CONF}" "${OUTPUT_LIBDIR}")
+            ENDIF()
+        ENDFOREACH()
+    ENDIF(VALID_BUILDER_VERSION)
 ENDIF()
 
@@ -647,5 +670,5 @@
 ENDIF()
 
-INCLUDE(OsgMacroUtils)
+
 # OSG Core
 ADD_SUBDIRECTORY(src)
