Merge topic 'vs-generator-platform'
be6a555d
Tests: Test setting a generator platform in a toolchain filed506fee8
Tests: Use -A option to pass generator platform selection11c9ddd6
ExternalProject: Use -A option to pass generator platform29bd843e
CTest: Use -A option to pass generator platform selectioneb7d8156
cmake: Add -A option to specify a generator platform
This commit is contained in:
commit
b234836637
|
@ -51,6 +51,17 @@
|
||||||
|
|
||||||
See native build system documentation for allowed toolset names.
|
See native build system documentation for allowed toolset names.
|
||||||
|
|
||||||
|
``-A <platform-name>``
|
||||||
|
Specify platform name if supported by generator.
|
||||||
|
|
||||||
|
Some CMake generators support a platform name to be given to the
|
||||||
|
native build system to choose a compiler or SDK. This is supported only on
|
||||||
|
specific generators::
|
||||||
|
|
||||||
|
Visual Studio >= 8
|
||||||
|
|
||||||
|
See native build system documentation for allowed platform names.
|
||||||
|
|
||||||
``-Wno-dev``
|
``-Wno-dev``
|
||||||
Suppress developer warnings.
|
Suppress developer warnings.
|
||||||
|
|
||||||
|
|
|
@ -4,4 +4,6 @@ vs-generator-platform
|
||||||
* The Visual Studio generators for versions 8 (2005) and above
|
* The Visual Studio generators for versions 8 (2005) and above
|
||||||
learned to read the target platform name from a new
|
learned to read the target platform name from a new
|
||||||
:variable:`CMAKE_GENERATOR_PLATFORM` variable when it is
|
:variable:`CMAKE_GENERATOR_PLATFORM` variable when it is
|
||||||
not specified as part of the generator name.
|
not specified as part of the generator name. The platform
|
||||||
|
name may be specified on the :manual:`cmake(1)` command line
|
||||||
|
with the ``-A`` option, e.g. ``-G "Visual Studio 12 2013" -A x64``.
|
||||||
|
|
|
@ -5,6 +5,8 @@ Generator-specific target platform name specified by user.
|
||||||
|
|
||||||
Some CMake generators support a target platform name to be given
|
Some CMake generators support a target platform name to be given
|
||||||
to the native build system to choose a compiler toolchain.
|
to the native build system to choose a compiler toolchain.
|
||||||
|
If the user specifies a toolset name (e.g. via the cmake -A option)
|
||||||
|
the value will be available in this variable.
|
||||||
|
|
||||||
The value of this variable should never be modified by project code.
|
The value of this variable should never be modified by project code.
|
||||||
A toolchain file specified by the :variable:`CMAKE_TOOLCHAIN_FILE`
|
A toolchain file specified by the :variable:`CMAKE_TOOLCHAIN_FILE`
|
||||||
|
|
|
@ -1764,7 +1764,7 @@ function(_ep_add_configure_command name)
|
||||||
if(cmake_generator)
|
if(cmake_generator)
|
||||||
list(APPEND cmd "-G${cmake_generator}")
|
list(APPEND cmd "-G${cmake_generator}")
|
||||||
if(cmake_generator_platform)
|
if(cmake_generator_platform)
|
||||||
list(APPEND cmd "-DCMAKE_GENERATOR_PLATFORM=${cmake_generator_platform}")
|
list(APPEND cmd "-A${cmake_generator_platform}")
|
||||||
endif()
|
endif()
|
||||||
if(cmake_generator_toolset)
|
if(cmake_generator_toolset)
|
||||||
list(APPEND cmd "-T${cmake_generator_toolset}")
|
list(APPEND cmd "-T${cmake_generator_toolset}")
|
||||||
|
@ -1779,7 +1779,7 @@ function(_ep_add_configure_command name)
|
||||||
message(FATAL_ERROR "Option CMAKE_GENERATOR_PLATFORM not allowed without CMAKE_GENERATOR.")
|
message(FATAL_ERROR "Option CMAKE_GENERATOR_PLATFORM not allowed without CMAKE_GENERATOR.")
|
||||||
endif()
|
endif()
|
||||||
if(CMAKE_GENERATOR_PLATFORM)
|
if(CMAKE_GENERATOR_PLATFORM)
|
||||||
list(APPEND cmd "-DCMAKE_GENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM}")
|
list(APPEND cmd "-A${CMAKE_GENERATOR_PLATFORM}")
|
||||||
endif()
|
endif()
|
||||||
if(cmake_generator_toolset)
|
if(cmake_generator_toolset)
|
||||||
message(FATAL_ERROR "Option CMAKE_GENERATOR_TOOLSET not allowed without CMAKE_GENERATOR.")
|
message(FATAL_ERROR "Option CMAKE_GENERATOR_TOOLSET not allowed without CMAKE_GENERATOR.")
|
||||||
|
|
|
@ -70,7 +70,7 @@ int cmCTestBuildAndTestHandler::RunCMake(std::string* outstring,
|
||||||
}
|
}
|
||||||
if(!this->BuildGeneratorPlatform.empty())
|
if(!this->BuildGeneratorPlatform.empty())
|
||||||
{
|
{
|
||||||
std::string platform = "-DCMAKE_GENERATOR_PLATFORM=";
|
std::string platform = "-A";
|
||||||
platform += this->BuildGeneratorPlatform;
|
platform += this->BuildGeneratorPlatform;
|
||||||
args.push_back(platform);
|
args.push_back(platform);
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,7 +122,7 @@ cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler()
|
||||||
this->Makefile->GetDefinition("CTEST_CMAKE_GENERATOR_PLATFORM");
|
this->Makefile->GetDefinition("CTEST_CMAKE_GENERATOR_PLATFORM");
|
||||||
if(cmakeGeneratorPlatform && *cmakeGeneratorPlatform)
|
if(cmakeGeneratorPlatform && *cmakeGeneratorPlatform)
|
||||||
{
|
{
|
||||||
cmakeConfigureCommand += " \"-DCMAKE_GENERATOR_PLATFORM=";
|
cmakeConfigureCommand += " \"-A";
|
||||||
cmakeConfigureCommand += cmakeGeneratorPlatform;
|
cmakeConfigureCommand += cmakeGeneratorPlatform;
|
||||||
cmakeConfigureCommand += "\"";
|
cmakeConfigureCommand += "\"";
|
||||||
}
|
}
|
||||||
|
|
|
@ -639,6 +639,7 @@ void cmake::SetArgs(const std::vector<std::string>& args,
|
||||||
{
|
{
|
||||||
bool directoriesSet = directoriesSetBefore;
|
bool directoriesSet = directoriesSetBefore;
|
||||||
bool haveToolset = false;
|
bool haveToolset = false;
|
||||||
|
bool havePlatform = false;
|
||||||
for(unsigned int i=1; i < args.size(); ++i)
|
for(unsigned int i=1; i < args.size(); ++i)
|
||||||
{
|
{
|
||||||
std::string arg = args[i];
|
std::string arg = args[i];
|
||||||
|
@ -767,6 +768,27 @@ void cmake::SetArgs(const std::vector<std::string>& args,
|
||||||
"uninitialized variables.\n";
|
"uninitialized variables.\n";
|
||||||
this->SetCheckSystemVars(true);
|
this->SetCheckSystemVars(true);
|
||||||
}
|
}
|
||||||
|
else if(arg.find("-A",0) == 0)
|
||||||
|
{
|
||||||
|
std::string value = arg.substr(2);
|
||||||
|
if(value.size() == 0)
|
||||||
|
{
|
||||||
|
++i;
|
||||||
|
if(i >= args.size())
|
||||||
|
{
|
||||||
|
cmSystemTools::Error("No platform specified for -A");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
value = args[i];
|
||||||
|
}
|
||||||
|
if(havePlatform)
|
||||||
|
{
|
||||||
|
cmSystemTools::Error("Multiple -A options not allowed");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this->GeneratorPlatform = value;
|
||||||
|
havePlatform = true;
|
||||||
|
}
|
||||||
else if(arg.find("-T",0) == 0)
|
else if(arg.find("-T",0) == 0)
|
||||||
{
|
{
|
||||||
std::string value = arg.substr(2);
|
std::string value = arg.substr(2);
|
||||||
|
|
|
@ -476,6 +476,7 @@ private:
|
||||||
{"-U <globbing_expr>", "Remove matching entries from CMake cache."}, \
|
{"-U <globbing_expr>", "Remove matching entries from CMake cache."}, \
|
||||||
{"-G <generator-name>", "Specify a build system generator."},\
|
{"-G <generator-name>", "Specify a build system generator."},\
|
||||||
{"-T <toolset-name>", "Specify toolset name if supported by generator."}, \
|
{"-T <toolset-name>", "Specify toolset name if supported by generator."}, \
|
||||||
|
{"-A <platform-name>", "Specify platform name if supported by generator."}, \
|
||||||
{"-Wno-dev", "Suppress developer warnings."},\
|
{"-Wno-dev", "Suppress developer warnings."},\
|
||||||
{"-Wdev", "Enable developer warnings."}
|
{"-Wdev", "Enable developer warnings."}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ message("running: ${CMAKE_COMMAND}")
|
||||||
execute_process(COMMAND "${CMAKE_COMMAND}"
|
execute_process(COMMAND "${CMAKE_COMMAND}"
|
||||||
"@CMAKE_BUILD_TEST_SOURCE_DIR@"
|
"@CMAKE_BUILD_TEST_SOURCE_DIR@"
|
||||||
"-G@CMAKE_GENERATOR@"
|
"-G@CMAKE_GENERATOR@"
|
||||||
"-DCMAKE_GENERATOR_PLATFORM=@CMAKE_GENERATOR_PLATFORM@"
|
-A "@CMAKE_GENERATOR_PLATFORM@"
|
||||||
-T "@CMAKE_GENERATOR_TOOLSET@"
|
-T "@CMAKE_GENERATOR_TOOLSET@"
|
||||||
WORKING_DIRECTORY "@CMAKE_BUILD_TEST_BINARY_DIR@"
|
WORKING_DIRECTORY "@CMAKE_BUILD_TEST_BINARY_DIR@"
|
||||||
RESULT_VARIABLE RESULT)
|
RESULT_VARIABLE RESULT)
|
||||||
|
|
|
@ -1988,7 +1988,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
|
||||||
# A test for ctest_build() with targets in subdirectories
|
# A test for ctest_build() with targets in subdirectories
|
||||||
set(ctest_configure_options)
|
set(ctest_configure_options)
|
||||||
if(CMAKE_GENERATOR_PLATFORM)
|
if(CMAKE_GENERATOR_PLATFORM)
|
||||||
list(APPEND ctest_configure_options -DCMAKE_GENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM})
|
list(APPEND ctest_configure_options -A ${CMAKE_GENERATOR_PLATFORM})
|
||||||
endif()
|
endif()
|
||||||
if(CMAKE_GENERATOR_TOOLSET)
|
if(CMAKE_GENERATOR_TOOLSET)
|
||||||
list(APPEND ctest_configure_options -T ${CMAKE_GENERATOR_TOOLSET})
|
list(APPEND ctest_configure_options -T ${CMAKE_GENERATOR_TOOLSET})
|
||||||
|
|
|
@ -9,7 +9,7 @@ file(MAKE_DIRECTORY "${binary_dir}")
|
||||||
execute_process(
|
execute_process(
|
||||||
COMMAND ${CMAKE_COMMAND} ${CMAKE_ARGS}
|
COMMAND ${CMAKE_COMMAND} ${CMAKE_ARGS}
|
||||||
"${source_dir}" -G "@CMAKE_GENERATOR@"
|
"${source_dir}" -G "@CMAKE_GENERATOR@"
|
||||||
-DCMAKE_GENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM}
|
-A "@CMAKE_GENERATOR_PLATFORM@"
|
||||||
-T "@CMAKE_GENERATOR_TOOLSET@"
|
-T "@CMAKE_GENERATOR_TOOLSET@"
|
||||||
WORKING_DIRECTORY "${binary_dir}"
|
WORKING_DIRECTORY "${binary_dir}"
|
||||||
RESULT_VARIABLE result
|
RESULT_VARIABLE result
|
||||||
|
|
|
@ -19,7 +19,7 @@ message("cmake initial configure")
|
||||||
execute_process(COMMAND ${CMAKE_COMMAND}
|
execute_process(COMMAND ${CMAKE_COMMAND}
|
||||||
${arg}
|
${arg}
|
||||||
-G "@CMAKE_GENERATOR@"
|
-G "@CMAKE_GENERATOR@"
|
||||||
-DCMAKE_GENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM}
|
-A "@CMAKE_GENERATOR_PLATFORM@"
|
||||||
-T "@CMAKE_GENERATOR_TOOLSET@"
|
-T "@CMAKE_GENERATOR_TOOLSET@"
|
||||||
${CTEST_SOURCE_DIRECTORY}
|
${CTEST_SOURCE_DIRECTORY}
|
||||||
WORKING_DIRECTORY ${CTEST_BINARY_DIRECTORY}
|
WORKING_DIRECTORY ${CTEST_BINARY_DIRECTORY}
|
||||||
|
|
|
@ -13,7 +13,7 @@ macro(check_a_tag desired_tag resulting_sha fetch_expected)
|
||||||
# Configure
|
# Configure
|
||||||
execute_process(COMMAND ${CMAKE_COMMAND}
|
execute_process(COMMAND ${CMAKE_COMMAND}
|
||||||
-G ${CMAKE_GENERATOR} -T "${CMAKE_GENERATOR_TOOLSET}"
|
-G ${CMAKE_GENERATOR} -T "${CMAKE_GENERATOR_TOOLSET}"
|
||||||
-DCMAKE_GENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM}
|
-A "${CMAKE_GENERATOR_PLATFORM}"
|
||||||
-DTEST_GIT_TAG:STRING=${desired_tag}
|
-DTEST_GIT_TAG:STRING=${desired_tag}
|
||||||
${ExternalProjectUpdate_SOURCE_DIR}
|
${ExternalProjectUpdate_SOURCE_DIR}
|
||||||
WORKING_DIRECTORY ${ExternalProjectUpdate_BINARY_DIR}
|
WORKING_DIRECTORY ${ExternalProjectUpdate_BINARY_DIR}
|
||||||
|
|
|
@ -15,7 +15,7 @@ set(COMMAND)
|
||||||
execute_process(
|
execute_process(
|
||||||
WORKING_DIRECTORY "${bld}"
|
WORKING_DIRECTORY "${bld}"
|
||||||
COMMAND ${CMAKE_COMMAND} "${src}" -G "@CMAKE_GENERATOR@"
|
COMMAND ${CMAKE_COMMAND} "${src}" -G "@CMAKE_GENERATOR@"
|
||||||
"-DCMAKE_GENERATOR_PLATFORM=@CMAKE_GENERATOR_PLATFORM@"
|
-A "@CMAKE_GENERATOR_PLATFORM@"
|
||||||
-T "@CMAKE_GENERATOR_TOOLSET@"
|
-T "@CMAKE_GENERATOR_TOOLSET@"
|
||||||
"-DFortranC_TEST_FLAGS=1"
|
"-DFortranC_TEST_FLAGS=1"
|
||||||
"-DCMAKE_C_COMPILER=${bld}/cc.sh"
|
"-DCMAKE_C_COMPILER=${bld}/cc.sh"
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
set(CMAKE_GENERATOR_PLATFORM "Bad Platform")
|
|
@ -0,0 +1 @@
|
||||||
|
1
|
|
@ -0,0 +1,10 @@
|
||||||
|
CMake Error at CMakeLists.txt:[0-9]+ \(project\):
|
||||||
|
Generator
|
||||||
|
|
||||||
|
.*
|
||||||
|
|
||||||
|
does not support platform specification, but platform
|
||||||
|
|
||||||
|
Bad Platform
|
||||||
|
|
||||||
|
was specified.$
|
|
@ -0,0 +1 @@
|
||||||
|
message(FATAL_ERROR "This should not be reached!")
|
|
@ -10,3 +10,19 @@ else()
|
||||||
set(RunCMake_GENERATOR_PLATFORM "Bad Platform")
|
set(RunCMake_GENERATOR_PLATFORM "Bad Platform")
|
||||||
run_cmake(BadPlatform)
|
run_cmake(BadPlatform)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
set(RunCMake_GENERATOR_TOOLSET "")
|
||||||
|
|
||||||
|
set(RunCMake_TEST_OPTIONS -A "Extra Platform")
|
||||||
|
run_cmake(TwoPlatforms)
|
||||||
|
unset(RunCMake_TEST_OPTIONS)
|
||||||
|
|
||||||
|
if("${RunCMake_GENERATOR}" MATCHES "^Visual Studio ([89]|1[0124])( 20[0-9][0-9])?$")
|
||||||
|
set(RunCMake_TEST_OPTIONS -DCMAKE_TOOLCHAIN_FILE=${RunCMake_SOURCE_DIR}/TestPlatform-toolchain.cmake)
|
||||||
|
run_cmake(TestPlatformToolchain)
|
||||||
|
unset(RunCMake_TEST_OPTIONS)
|
||||||
|
else()
|
||||||
|
set(RunCMake_TEST_OPTIONS -DCMAKE_TOOLCHAIN_FILE=${RunCMake_SOURCE_DIR}/BadPlatform-toolchain.cmake)
|
||||||
|
run_cmake(BadPlatformToolchain)
|
||||||
|
unset(RunCMake_TEST_OPTIONS)
|
||||||
|
endif()
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
set(CMAKE_GENERATOR_PLATFORM "Test Platform")
|
|
@ -0,0 +1 @@
|
||||||
|
1
|
|
@ -0,0 +1,9 @@
|
||||||
|
CMake Error at TestPlatformToolchain.cmake:[0-9]+ \(message\):
|
||||||
|
CMAKE_GENERATOR_PLATFORM is "Test Platform" as expected.
|
||||||
|
Call Stack \(most recent call first\):
|
||||||
|
CMakeLists.txt:3 \(include\)
|
||||||
|
+
|
||||||
|
CMake Error at TestPlatformToolchain.cmake:[0-9]+ \(message\):
|
||||||
|
CMAKE_VS_PLATFORM_NAME is "Test Platform" as expected.
|
||||||
|
Call Stack \(most recent call first\):
|
||||||
|
CMakeLists.txt:3 \(include\)
|
|
@ -0,0 +1,16 @@
|
||||||
|
if("x${CMAKE_GENERATOR_PLATFORM}" STREQUAL "xTest Platform")
|
||||||
|
message(SEND_ERROR "CMAKE_GENERATOR_PLATFORM is \"Test Platform\" as expected.")
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR
|
||||||
|
"CMAKE_GENERATOR_PLATFORM is \"${CMAKE_GENERATOR_PLATFORM}\" "
|
||||||
|
"but should be \"Test Platform\"!")
|
||||||
|
endif()
|
||||||
|
if(CMAKE_GENERATOR MATCHES "Visual Studio")
|
||||||
|
if("x${CMAKE_VS_PLATFORM_NAME}" STREQUAL "xTest Platform")
|
||||||
|
message(SEND_ERROR "CMAKE_VS_PLATFORM_NAME is \"Test Platform\" as expected.")
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR
|
||||||
|
"CMAKE_VS_PLATFORM_NAME is \"${CMAKE_VS_PLATFORM_NAME}\" "
|
||||||
|
"but should be \"Test Platform\"!")
|
||||||
|
endif()
|
||||||
|
endif()
|
|
@ -0,0 +1 @@
|
||||||
|
1
|
|
@ -0,0 +1 @@
|
||||||
|
CMake Error: Multiple -A options not allowed
|
|
@ -0,0 +1 @@
|
||||||
|
message(FATAL_ERROR "This should not be reached!")
|
|
@ -53,7 +53,7 @@ function(run_cmake test)
|
||||||
execute_process(
|
execute_process(
|
||||||
COMMAND ${CMAKE_COMMAND} "${RunCMake_TEST_SOURCE_DIR}"
|
COMMAND ${CMAKE_COMMAND} "${RunCMake_TEST_SOURCE_DIR}"
|
||||||
-G "${RunCMake_GENERATOR}"
|
-G "${RunCMake_GENERATOR}"
|
||||||
"-DCMAKE_GENERATOR_PLATFORM=${RunCMake_GENERATOR_PLATFORM}"
|
-A "${RunCMake_GENERATOR_PLATFORM}"
|
||||||
-T "${RunCMake_GENERATOR_TOOLSET}"
|
-T "${RunCMake_GENERATOR_TOOLSET}"
|
||||||
-DRunCMake_TEST=${test}
|
-DRunCMake_TEST=${test}
|
||||||
--no-warn-unused-cli
|
--no-warn-unused-cli
|
||||||
|
|
|
@ -20,7 +20,7 @@ make_directory("${LIB2_BINARY_DIR}")
|
||||||
# generate lib1
|
# generate lib1
|
||||||
execute_process(
|
execute_process(
|
||||||
COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}"
|
COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}"
|
||||||
-DCMAKE_GENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM}
|
-A "${CMAKE_GENERATOR_PLATFORM}"
|
||||||
-T "${CMAKE_GENERATOR_TOOLSET}" "${VSExternalInclude_SOURCE_DIR}/Lib1"
|
-T "${CMAKE_GENERATOR_TOOLSET}" "${VSExternalInclude_SOURCE_DIR}/Lib1"
|
||||||
WORKING_DIRECTORY ${LIB1_BINARY_DIR}
|
WORKING_DIRECTORY ${LIB1_BINARY_DIR}
|
||||||
OUTPUT_VARIABLE OUT
|
OUTPUT_VARIABLE OUT
|
||||||
|
@ -31,7 +31,7 @@ message("CMAKE Ran with the following output:\n\"${OUT}\"")
|
||||||
# generate lib2
|
# generate lib2
|
||||||
execute_process(
|
execute_process(
|
||||||
COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}"
|
COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}"
|
||||||
-DCMAKE_GENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM}
|
-A "${CMAKE_GENERATOR_PLATFORM}"
|
||||||
-T "${CMAKE_GENERATOR_TOOLSET}" "${VSExternalInclude_SOURCE_DIR}/Lib2"
|
-T "${CMAKE_GENERATOR_TOOLSET}" "${VSExternalInclude_SOURCE_DIR}/Lib2"
|
||||||
WORKING_DIRECTORY ${LIB2_BINARY_DIR}
|
WORKING_DIRECTORY ${LIB2_BINARY_DIR}
|
||||||
OUTPUT_VARIABLE OUT
|
OUTPUT_VARIABLE OUT
|
||||||
|
|
Loading…
Reference in New Issue