Don't set empty CMAKE_TOOLCHAIN_FILE or CMAKE_BUILD_TYPE

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>
This commit is contained in:
Stephen Kelly 2012-08-31 11:59:30 +02:00 committed by Qt by Nokia
parent b2ae34d9b5
commit 449d1f620a

View 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()