mirror of https://github.com/xbmc/xbmc
[cmake] ModuleHelper function to generate dev_env variable for externalproject_add
Currently specifically for windows to set a dev environment for target configure and build steps for externalproject_add calls
This commit is contained in:
parent
b6d2a6af6a
commit
12c372da21
|
|
@ -919,3 +919,45 @@ function(create_mesonbuiltin)
|
|||
string(PREPEND output_string "[built-in options]\n")
|
||||
set(meson_builtin_string ${output_string} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# Creates a variable and sets in parent scope - ${${CMAKE_FIND_PACKAGE_NAME}_MODULE}_dev_env
|
||||
# Variable is purposely set with an ending COMMAND to allow the variable to be placed
|
||||
# in an externalproject_add build or configure step.
|
||||
#
|
||||
# eg. set(BUILD_COMMAND ${${${CMAKE_FIND_PACKAGE_NAME}_MODULE}_dev_env}
|
||||
# Ninja::Ninja -C ./build)
|
||||
#
|
||||
function(create_module_dev_env)
|
||||
if(WIN32 OR WINDOWS_STORE)
|
||||
set(Vcvars_FIND_VCVARSALL TRUE)
|
||||
|
||||
if(NOT VERBOSE_FIND)
|
||||
set(Vcvars_FIND_QUIETLY TRUE)
|
||||
endif()
|
||||
|
||||
find_package(Vcvars REQUIRED)
|
||||
if(WINDOWS_STORE)
|
||||
set(vcstore store)
|
||||
endif()
|
||||
|
||||
string(TOLOWER "${CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE}" _lower_hostarch)
|
||||
string(TOLOWER "${CMAKE_GENERATOR_PLATFORM}" _lower_targetarch)
|
||||
|
||||
if("${_lower_hostarch}" STREQUAL "x64")
|
||||
set(_lower_hostarch amd64)
|
||||
endif()
|
||||
if("${_lower_targetarch}" STREQUAL "x64")
|
||||
set(_lower_targetarch amd64)
|
||||
endif()
|
||||
|
||||
if("${_lower_hostarch}" STREQUAL "${_lower_targetarch}")
|
||||
set(vcarch ${_lower_hostarch})
|
||||
else()
|
||||
set(vcarch ${_lower_hostarch}_${_lower_targetarch})
|
||||
endif()
|
||||
|
||||
set(cmd_wrapper "${Vcvars_BATCH_FILE}" ${vcarch} ${vcstore} ${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION})
|
||||
# trailing COMMAND sets externalproject_add commands up, and is required
|
||||
set(${${CMAKE_FIND_PACKAGE_NAME}_MODULE}_dev_env ${cmd_wrapper} COMMAND PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
|
|
|||
Loading…
Reference in New Issue