# HG changeset patch
# User hasufell
# Date 1352040212 -3600
# Node ID d5e49cf042d9392145bb16b756bac3074ea994cc
# Parent  80e2e50471d958bfa7f0e75992229bb4af43c252
fix parallel compilation

diff -r 80e2e50471d9 -r d5e49cf042d9 hedgewars/CMakeLists.txt
--- a/hedgewars/CMakeLists.txt	Sat Nov 03 22:45:24 2012 -0400
+++ b/hedgewars/CMakeLists.txt	Sun Nov 04 15:43:32 2012 +0100
@@ -193,7 +193,14 @@
 
 #this command is a workaround to some inlining issues present in older FreePascal versions and fixed in 2.6
 if(fpc_version LESS "020600")
-    add_custom_target(ENGINECLEAN COMMAND ${CMAKE_BUILD_TOOL} "clean" "${PROJECT_BINARY_DIR}" "${hedgewars_SOURCE_DIR}/hedgewars")
+    #under some configurations CMAKE_BUILD_TOOL fails to pass on the jobserver, breaking parallel compilation
+    #TODO: check if this is needed on windows too
+    if(UNIX)
+        set(SAFE_BUILD_TOOL $(MAKE))
+    else()
+        set(SAFE_BUILD_TOOL ${CMAKE_BUILD_TOOL})
+    endif()
+    add_custom_target(ENGINECLEAN COMMAND ${SAFE_BUILD_TOOL} "clean" "${PROJECT_BINARY_DIR}" "${hedgewars_SOURCE_DIR}/hedgewars")
 endif()