Don't set empty CMAKE_TOOLCHAIN_FILE or CMAKE_BUILD_TYPE
authorStephen Kelly <stephen.kelly@kdab.com>
Fri, 31 Aug 2012 09:59:30 +0000 (11:59 +0200)
committerQt by Nokia <qt-info@nokia.com>
Fri, 31 Aug 2012 14:51:27 +0000 (16:51 +0200)
The CMake Visual Studio 10 generator generates an include() for
the empty CMAKE_TOOLCHAIN_FILE, causing the errors in the bug.

There may be other remaining errors to cause the Windows CMake build
to fail with that generator, but this patch is an improvement
anyway - there is no point in setting empty strings as values for
those variables.

Task-number: QTBUG-27087
Change-Id: I68cce9e3dce07835db5f42777ac02d440f90f967
Reviewed-by: Brad King <brad.king@kitware.com>
Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
src/corelib/Qt5CTestMacros.cmake

index 9c786c5..d4a0b72 100644 (file)
@@ -1,4 +1,14 @@
 
+set(BUILD_OPTIONS_LIST)
+
+if (CMAKE_BUILD_TYPE)
+  list(APPEND BUILD_OPTIONS_LIST "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}")
+endif()
+
+if (CMAKE_TOOLCHAIN_FILE)
+  list(APPEND BUILD_OPTIONS_LIST "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}")
+endif()
+
 macro(expect_pass _dir)
   string(REPLACE "(" "_" testname "${_dir}")
   string(REPLACE ")" "_" testname "${testname}")
@@ -8,7 +18,7 @@ macro(expect_pass _dir)
     "${CMAKE_CURRENT_BINARY_DIR}/${_dir}"
     --build-generator ${CMAKE_GENERATOR}
     --build-makeprogram ${CMAKE_MAKE_PROGRAM}
-    --build-options "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}" "-DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}" "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}"
+    --build-options "-DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}" ${BUILD_OPTIONS_LIST}
   )
 endmacro()
 
@@ -42,6 +52,6 @@ macro(expect_fail _dir)
     "${CMAKE_CURRENT_BINARY_DIR}/failbuild/${_dir}/build"
     --build-generator ${CMAKE_GENERATOR}
     --build-makeprogram ${CMAKE_MAKE_PROGRAM}
-    --build-options "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}" "-DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}" "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}"
+    --build-options "-DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}" ${BUILD_OPTIONS_LIST}
   )
 endmacro()