Commit b4087a23 authored by Brad King's avatar Brad King Committed by Kitware Robot

Merge topic 'vs-ReferenceOutputAssembly-conditions'

4dc8c153 Tests: Teach VSWinStorePhone to verify the content of generated xap
481070a7 Tests: Teach VSWinStorePhone to verify the content of generated appx/msix
acdb3266 VS: Do not reference output assemblies of targets with no output
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Merge-request: !3778
parents 28a2613d 4dc8c153
Pipeline #147152 passed with stage
in 0 seconds
......@@ -4078,32 +4078,8 @@ void cmVisualStudio10TargetGenerator::WriteProjectReferences(Elem& e0)
e2.Element("Name", name);
this->WriteDotNetReferenceCustomTags(e2, name);
// If the dependency target is not managed (compiled with /clr or
// C# target) and not a WinRT component we cannot reference it and
// have to set 'ReferenceOutputAssembly' to false.
auto referenceNotManaged =
dt->GetManagedType("") < cmGeneratorTarget::ManagedType::Mixed;
// Workaround to check for manually set /clr flags.
if (referenceNotManaged) {
if (const auto* flags = dt->GetProperty("COMPILE_OPTIONS")) {
std::string flagsStr = flags;
if (flagsStr.find("clr") != std::string::npos) {
// There is a warning already issued when building the flags.
referenceNotManaged = false;
}
}
}
// Workaround for static library C# targets
if (referenceNotManaged && dt->GetType() == cmStateEnums::STATIC_LIBRARY) {
referenceNotManaged = !dt->IsCSharpOnly();
}
// Referencing WinRT components is okay.
if (referenceNotManaged) {
referenceNotManaged = !dt->GetPropertyAsBool("VS_WINRT_COMPONENT");
}
if (referenceNotManaged) {
// Don't reference targets that don't produce any output.
if (dt->GetManagedType("") == cmGeneratorTarget::ManagedType::Undefined) {
e2.Element("ReferenceOutputAssembly", "false");
e2.Element("CopyToOutputDirectory", "Never");
}
......
......@@ -2079,6 +2079,9 @@ ${CMake_SOURCE_DIR}/Utilities/Release/push.bash --dir dev -- '${CMake_BUILD_NIGH
--build-config $<CONFIGURATION>
--build-options -DCMAKE_SYSTEM_NAME=${systemName}
-DCMAKE_SYSTEM_VERSION=${systemVersion}
--test-command
${CMAKE_CMAKE_COMMAND} -DAPP_PACKAGE_DIR="${CMake_BINARY_DIR}/Tests/VSWinStorePhone/${name}"
-P "${CMake_SOURCE_DIR}/Tests/VSWinStorePhone/VerifyAppPackage.cmake"
)
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/VSWinStorePhone/${name}")
endmacro()
......
......@@ -9,6 +9,7 @@ elseif(MSVC_VERSION GREATER 1600)
endif()
add_subdirectory(WinRT)
add_subdirectory(CxxDLL)
set (APP_MANIFEST_NAME Package.appxmanifest)
if("${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsPhone")
......@@ -151,4 +152,4 @@ if("${SHORT_VERSION}" STREQUAL "10.0")
set_property(TARGET ${EXE_NAME} PROPERTY VS_SDK_REFERENCES "Microsoft.UniversalCRT.Debug, Version=${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}")
endif()
target_link_libraries(${EXE_NAME} d3d11 JusticeLeagueWinRT)
target_link_libraries(${EXE_NAME} d3d11 JusticeLeagueWinRT CxxDll)
project(CxxDll CXX)
add_library(CxxDll SHARED cxxdll.cpp)
#include "cxxdll.h"
#include <iostream>
void CxxDllClass::SomeMethod()
{
std::cout << "CxxDllClass::SomeMethod\n";
}
class __declspec(dllexport) CxxDllClass
{
public:
static void SomeMethod();
};
set(APP_PKG_NAME Direct3DApp1)
# List of files that are expected to be present in the generated app package
set(EXPECTED_APP_PKG_CONTENT
${APP_PKG_NAME}.exe
CxxDll.dll
JusticeLeagueWinRT.winmd
JusticeLeagueWinRT.dll
)
# Windows app package formats can be either msix, appx or xap
file(GLOB_RECURSE ALL_APP_PKG_FILES ${APP_PACKAGE_DIR} ${APP_PKG_NAME}*.msix ${APP_PKG_NAME}*.appx ${APP_PKG_NAME}*.xap)
# There can be only one generated app package
list(LENGTH ALL_APP_PKG_FILES APP_PKG_COUNT)
if(NOT APP_PKG_COUNT EQUAL 1)
message(FATAL_ERROR "Expected 1 generated app package, but detected ${APP_PKG_COUNT}: ${ALL_APP_PKG_FILES}")
endif()
execute_process(COMMAND ${CMAKE_COMMAND} -E tar tf ${ALL_APP_PKG_FILES}
OUTPUT_VARIABLE APP_PKG_CONTENT_OUTPUT
ERROR_VARIABLE error
RESULT_VARIABLE result)
if(NOT result EQUAL 0)
message(FATAL_ERROR "Listing app package content failed with: ${error}")
endif()
foreach(app_pkg_item ${EXPECTED_APP_PKG_CONTENT})
string(FIND ${APP_PKG_CONTENT_OUTPUT} ${app_pkg_item} _found)
if(_found EQUAL -1)
message(FATAL_ERROR "Generated app package is missing an expected item: ${app_pkg_item}")
endif()
endforeach()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment