floooh / fips

High-level build system for distributed, multi-platform C/C++ projects.
MIT License
468 stars 82 forks source link

Ability to Support the target for Windows Apps (Universal Apps, Windows Store 8., Windows Phone 8.1 and Windows 10 Apps) #84

Open wpbest opened 9 years ago

wpbest commented 9 years ago

Ability to Support the target for Windows Apps (Universal Apps, Windows Store 8., Windows Phone 8.1 and Windows 10 Apps). Microsoft forked of the original CMake project: http://cmake.org There project is the current working fork of CMake that is maintained by Microsoft. There current working branch MSWinRTPhoneStore adds support for producing Windows Store and Windows Phone 8.0 and 8.1 projects with Visual Studio 2012 and 2013. GitHub: https://github.com/Microsoft/CMake. I have a requirement to support Microsoft Universal Applications. Is it possible fips could support this feature?

floooh commented 9 years ago

It should be easy to support this, but I can't really test this. Basically (if I understand it right, haven't used this yet), cmake needs to be started with an additional -A and/or -T option (-T is generator-specific toolset version, -A is generator-specific platform). There should be 2 new keywords in the fips-config files in addition to 'generator', called 'generator-toolset' and 'generator-platform', and when cmake is invoked, these should be provided to cmake as command line args. Then add a few more standard-config.yml files under fips/config.

floooh commented 9 years ago

...one caveat could be that these options are only supported since cmake 3.x if I remember right, but fips still needs to support cmake 2.8 because of some Linux distros.

wpbest commented 9 years ago

If you like I could implement this feature. CMake started supporting Windows Apps (Store/Phone) in version 3.0. CMake has Generators for Visual Studio 11 (2012) and above learned to generate projects for Windows Phone and Windows Store. You can set the CMAKE_SYSTEM_NAME variable to WindowsPhone or WindowsStore on the cmake(1) command-line or in a CMAKE_TOOLCHAIN_FILE to activate these platforms. Also set CMAKE_SYSTEM_VERSION to 8.0 or 8.1 to specify the version of Windows to be targeted.

wpbest commented 9 years ago

Here is the commands in CMake for Windows Store Windows 8.1 for Visual Studio 2013 Platform:Win32 cmake -DCMAKE_SYSTEM_NAME:STRING=WindowsStore -DCMAKE_SYSTEM_VERSION:STRING=8.1 . -G "Visual Studio 12 2013 Win32" Platform:x64 cmake -DCMAKE_SYSTEM_NAME:STRING=WindowsStore -DCMAKE_SYSTEM_VERSION:STRING=8.1 . -G "Visual Studio 12 2013 Win64" Visual Studio 12 2013 ARM Platform:ARM cmake -DCMAKE_SYSTEM_NAME:STRING=WindowsStore -DCMAKE_SYSTEM_VERSION:STRING=8.1 . -G "Visual Studio 12 2013 ARM"

For Windows Phone Change -DCMAKE_SYSTEM_NAME:STRING=WindowsPhone For Windows 8.0 change -DCMAKE_SYSTEM_VERSION:STRING=8.0 For Visual Studio 2012 change to either to -G "Visual Studio 11 2012 Win32", -G "Visual Studio 11 2012 Win64", -G "Visual Studio 11 2012 ARM" for platforms Win32, x84 and ARM respectively.

wpbest commented 9 years ago

I looked at your Python code base and I'm not sure how to implement this feature. In the configs directory add configurations for:

win32store-vstudio-debug.yml win32store-vstudio-release.yml win64store-vstudio-debug.yml win64store-vstudio-release.yml armstore-vstudio-debug.yml armstore-vstudio-release.yml win32phone-vstudio-debug.yml win32phone-vstudio-release.yml win64phone-vstudio-debug.yml win64phone-vstudio-release.yml armphone-vstudio-debug.yml armstore-vstudio-release.yml

win64store-vstudio-debug.yml

platform: win64 generator: Visual Studio 12 build_tool: cmake build_type: Debug system_name: WindowsStore system_version: 8.1

Would we need system_name and system_version inplemented in your fips python scripts? it would be passed to CMake parameters.

How to build for x64 Windows Store Apps. fips set config win64store-vstudio-debug fips build

floooh commented 9 years ago

I'm interested in adding Windows Universal App support to fips and Oryol, but I guess I need to get a dedicated Windows laptop first. Running Windows in a VM doesn't really cut it. I'll see if I can hack in the basic support for system name and version into fips (shouldn't be much work). For Oryol I'll need to get some hardware first ;)

floooh commented 9 years ago

PS: if it is sufficient to pass the CMAKE_SYSTEM_NAME and CMAKE_SYSTEM_VERSION strings to cmake like you described, then the config file should look like this:

platform: win64
generator: Visual Studio 12
build_tool: cmake
build_type: Debug
defines:
    CMAKE_SYSTEM_NAME: 'WindowsStore'
    CMAKE_SYSTEM_VERSION: '8.1'

This would cause cmake to be called with -DCMAKE_SYSTEM_NAME=WindowsStore and -DCMAKE_SYSTEM_VERSION=8.1 (without the :STRING type, hopefully this doesn't make a difference).

May be this already would work without supporting the new "-T" and "-A" command line args.

wpbest commented 9 years ago

Yes, I agree you need actual hardware because the Android and Windows Phone Emulators run under Hyper-V. I will give this a try. I will create a simple example. It would be nice maybe someday to "fipsify" the ANGLE project so we could create an example using the Oryol graphics library.

wpbest commented 9 years ago

I started to implement Windows Store Apps and Windows Phone Apps for fips. I forked your fips git repository. I added the configs for Windows Store and Windows Phone. https://github.com/wpbest/fips.git

I also created two examples to test. fips-win-store-app: https://github.com/wpbest/fips-win-store-app.git fips-win-phone-app: https://github.com/wpbest/fips-win-phone-app.git

I believe we need to create/define/implement fips specific CMake commands? I don't see how to define these?

set (APP_MANIFEST_NAME Package.appxmanifest) set(APP_MANIFEST_NAME WMAppManifest.xml) set(PACKAGE_GUID "6514377e-dfd4-4cdb-80df-4e0366346efc") set(CONTENT_FILES ${CONTENT_FILES} ${CMAKE_CURRENT_BINARY_DIR}/${APP_MANIFEST_NAME} ... {asset file} ) set(CONTENT_FILES ${CONTENT_FILES} ${CMAKE_CURRENT_BINARY_DIR}/${APP_MANIFEST_NAME} ) set(RESOURCE_FILES ${CONTENT_FILES} ${DEBUG_CONTENT_FILES} ${RELEASE_CONTENT_FILES} ${ASSET_FILES} APP_NAME_TemporaryKey.pfx) add_executable(${EXE_NAME} WIN32 ${SOURCE_FILES} ${HEADER_FILES} ${RESOURCE_FILES}) set_property(TARGET ${EXE_NAME} PROPERTY VS_WINRT_COMPONENT TRUE) target_link_libraries(${EXE_NAME} {libs})

Here is the output of the build so far: C:\git\fips-win-store-app>fips build win32store-vstudio-debug C:\git\fips-win-store-app>REM Windows wrapper batch file C:\git\fips-win-store-app>python fips build win32store-vstudio-debug === dependency: 'fips-angle': Cloning into 'fips-angle'... remote: Counting objects: 8, done. remote: Compressing objects: 100% (8/8), done. remote: Total 8 (delta 1), reused 0 (delta 0), pack-reused 0 Unpacking objects: 100% (8/8), done. Checking connectivity... done. === building: win32store-vstudio-debug cmake --build . --config Debug Microsoft (R) Build Engine version 12.0.31101.0 [Microsoft .NET Framework, version 4.0.30319.0] Copyright (C) Microsoft Corporation. All rights reserved. Build started 4/16/2015 4:49:38 PM. The target "AfterGenerateAppxManifest" listed in an AfterTargets attribute at "C:\Program Files (x86)\MSBuild\Microsoft.NetNative\Microsoft.NetNative.targets (60,1 1)" does not exist in the project, and will be ignored. The target "AfterGenerateAppxManifest" listed in an AfterTargets attribute at "C:\Program Files (x86)\MSBuild\Microsoft.NetNative\Microsoft.NetNative.targets (108, 11)" does not exist in the project, and will be ignored. The target "AfterGenerateAppxManifest" listed in an AfterTargets attribute at "C:\Program Files (x86)\MSBuild\Microsoft.NetNative\Microsoft.NetNative.targets (60,1 1)" does not exist in the project, and will be ignored. The target "AfterGenerateAppxManifest" listed in an AfterTargets attribute at "C:\Program Files (x86)\MSBuild\Microsoft.NetNative\Microsoft.NetNative.targets (108, 11)" does not exist in the project, and will be ignored. Project "C:\git\fips-build\fips-win-store-app\win32store-vstudio-debug\ALL_BUILD.vcxproj" on node 1 (default targets). Project "C:\git\fips-build\fips-win-store-app\win32store-vstudio-debug\ALL_BUILD.vcxproj" (1) is building "C:\git\fips-build\fips-win-store-app\win32store-vstudio-d ebug\ZERO_CHECK.vcxproj" (2) on node 1 (default targets). InitializeBuildStatus: Creating "Win32\Debug\ZERO_CHECK\ZERO_CHECK.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified. CustomBuild: Checking Build System CMake is re-running because C:/git/fips-build/fips-win-store-app/win32store-vstudio-debug/CMakeFiles/generate.stamp is out-of-date. the file 'C:/git/fips-win-store-app/.fips-imports.cmake' is newer than 'C:/git/fips-build/fips-win-store-app/win32store-vstudio-debug/CMakeFiles/generate.stamp.depend' result='-1' CMAKE_BUILD_TYPE: Debug FIPS_ROOT_DIR: C:/git/fips FIPS_PROJECT_DIR: C:/git/fips-win-store-app FIPS_DEPLOY_DIR: C:/git/fips-deploy Host system: Windows CMAKE_CXX_COMPILER_ID: MSVC Detected C++ Compiler: VStudio (FIPS_MSVC) FIPS_CONFIG: win32store-vstudio-debug Target Platform: Windows 32-bit C++ exceptions are disabled FIPS_PLATFORM: WIN32 -- Configuring done -- Generating done -- Build files have been written to: C:/git/fips-build/fips-win-store-app/win32store-vstudio-debug FinalizeBuildStatus: Deleting file "Win32\Debug\ZERO_CHECK\ZERO_CHECK.tlog\unsuccessfulbuild". Touching "Win32\Debug\ZERO_CHECK\ZERO_CHECK.tlog\ZERO_CHECK.lastbuildstate". Done Building Project "C:\git\fips-build\fips-win-store-app\win32store-vstudio-debug\ZERO_CHECK.vcxproj" (default targets). Project "C:\git\fips-build\fips-win-store-app\win32store-vstudio-debug\ALL_BUILD.vcxproj" (1) is building "C:\git\fips-build\fips-win-store-app\win32store-vstudio-d ebug\src\fips-win-store-app.vcxproj" (3) on node 1 (default targets). C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.CppBuild.targets(1679,5): error MSB8024: Using static version of the C++ runtime library is not sup ported. [C:\git\fips-build\fips-win-store-app\win32store-vstudio-debug\src\fips-win-store-app.vcxproj] Done Building Project "C:\git\fips-build\fips-win-store-app\win32store-vstudio-debug\src\fips-win-store-app.vcxproj" (default targets) -- FAILED. Done Building Project "C:\git\fips-build\fips-win-store-app\win32store-vstudio-debug\ALL_BUILD.vcxproj" (default targets) -- FAILED. Build FAILED. "C:\git\fips-build\fips-win-store-app\win32store-vstudio-debug\ALL_BUILD.vcxproj" (default target) (1) -> "C:\git\fips-build\fips-win-store-app\win32store-vstudio-debug\src\fips-win-store-app.vcxproj" (default target) (3) -> (ComputeCrtSDKReference target) -> C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.CppBuild.targets(1679,5): error MSB8024: Using static version of the C++ runtime library is not s upported. [C:\git\fips-build\fips-win-store-app\win32store-vstudio-debug\src\fips-win-store-app.vcxproj] 0 Warning(s) 1 Error(s) Time Elapsed 00:00:00.54 [ERROR] Failed to build config 'win32store-vstudio-debug' of project 'fips-win-store-app' C:\git\fips-win-store-app>fips build win32store-vstudio-debug C:\git\fips-win-store-app>REM Windows wrapper batch file C:\git\fips-win-store-app>python fips build win32store-vstudio-debug === dependency: 'fips-win-store-angle': Cloning into 'fips-win-store-angle'... remote: Counting objects: 8, done. remote: Compressing objects: 100% (8/8), done. remote: Total 8 (delta 1), reused 0 (delta 0), pack-reused 0 Unpacking objects: 100% (8/8), done. Checking connectivity... done. === building: win32store-vstudio-debug cmake --build . --config Debug Microsoft (R) Build Engine version 12.0.31101.0 [Microsoft .NET Framework, version 4.0.30319.0] Copyright (C) Microsoft Corporation. All rights reserved. Build started 4/16/2015 4:54:11 PM. The target "AfterGenerateAppxManifest" listed in an AfterTargets attribute at "C:\Program Files (x86)\MSBuild\Microsoft.NetNative\Microsoft.NetNative.targets (60,1 1)" does not exist in the project, and will be ignored. The target "AfterGenerateAppxManifest" listed in an AfterTargets attribute at "C:\Program Files (x86)\MSBuild\Microsoft.NetNative\Microsoft.NetNative.targets (108, 11)" does not exist in the project, and will be ignored. The target "AfterGenerateAppxManifest" listed in an AfterTargets attribute at "C:\Program Files (x86)\MSBuild\Microsoft.NetNative\Microsoft.NetNative.targets (60,1 1)" does not exist in the project, and will be ignored. The target "AfterGenerateAppxManifest" listed in an AfterTargets attribute at "C:\Program Files (x86)\MSBuild\Microsoft.NetNative\Microsoft.NetNative.targets (108, 11)" does not exist in the project, and will be ignored. Project "C:\git\fips-build\fips-win-store-app\win32store-vstudio-debug\ALL_BUILD.vcxproj" on node 1 (default targets). Project "C:\git\fips-build\fips-win-store-app\win32store-vstudio-debug\ALL_BUILD.vcxproj" (1) is building "C:\git\fips-build\fips-win-store-app\win32store-vstudio-d ebug\ZERO_CHECK.vcxproj" (2) on node 1 (default targets). InitializeBuildStatus: Creating "Win32\Debug\ZERO_CHECK\ZERO_CHECK.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified. CustomBuild: Checking Build System CMake is re-running because C:/git/fips-build/fips-win-store-app/win32store-vstudio-debug/CMakeFiles/generate.stamp is out-of-date. the file 'C:/git/fips-win-store-app/.fips-imports.cmake' is newer than 'C:/git/fips-build/fips-win-store-app/win32store-vstudio-debug/CMakeFiles/generate.stamp.depend' result='-1' CMAKE_BUILD_TYPE: Debug FIPS_ROOT_DIR: C:/git/fips FIPS_PROJECT_DIR: C:/git/fips-win-store-app FIPS_DEPLOY_DIR: C:/git/fips-deploy Host system: Windows CMAKE_CXX_COMPILER_ID: MSVC Detected C++ Compiler: VStudio (FIPS_MSVC) FIPS_CONFIG: win32store-vstudio-debug Target Platform: Windows 32-bit C++ exceptions are disabled FIPS_PLATFORM: WIN32 -- Configuring done -- Generating done -- Build files have been written to: C:/git/fips-build/fips-win-store-app/win32store-vstudio-debug FinalizeBuildStatus: Deleting file "Win32\Debug\ZERO_CHECK\ZERO_CHECK.tlog\unsuccessfulbuild". Touching "Win32\Debug\ZERO_CHECK\ZERO_CHECK.tlog\ZERO_CHECK.lastbuildstate". Done Building Project "C:\git\fips-build\fips-win-store-app\win32store-vstudio-debug\ZERO_CHECK.vcxproj" (default targets). Project "C:\git\fips-build\fips-win-store-app\win32store-vstudio-debug\ALL_BUILD.vcxproj" (1) is building "C:\git\fips-build\fips-win-store-app\win32store-vstudio-d ebug\src\fips-win-store-app.vcxproj" (3) on node 1 (default targets). C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.CppBuild.targets(1679,5): error MSB8024: Using static version of the C++ runtime library is not sup ported. [C:\git\fips-build\fips-win-store-app\win32store-vstudio-debug\src\fips-win-store-app.vcxproj] Done Building Project "C:\git\fips-build\fips-win-store-app\win32store-vstudio-debug\src\fips-win-store-app.vcxproj" (default targets) -- FAILED. Done Building Project "C:\git\fips-build\fips-win-store-app\win32store-vstudio-debug\ALL_BUILD.vcxproj" (default targets) -- FAILED. Build FAILED. "C:\git\fips-build\fips-win-store-app\win32store-vstudio-debug\ALL_BUILD.vcxproj" (default target) (1) -> "C:\git\fips-build\fips-win-store-app\win32store-vstudio-debug\src\fips-win-store-app.vcxproj" (default target) (3) -> (ComputeCrtSDKReference target) -> C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.CppBuild.targets(1679,5): error MSB8024: Using static version of the C++ runtime library is not s upported. [C:\git\fips-build\fips-win-store-app\win32store-vstudio-debug\src\fips-win-store-app.vcxproj] 0 Warning(s) 1 Error(s) Time Elapsed 00:00:00.53 [ERROR] Failed to build config 'win32store-vstudio-debug' of project 'fips-win-store-app'

wpbest commented 9 years ago

I created two CMake project examples for Windows Store and Windows Phone.

Windows Store: https://github.com/wpbest/cmake-win-store-app.git Windows Phone: https://github.com/wpbest/fips-win-phone-app.git

I'm going to dive in and get fips working with Windows Store and Phone platforms.

wpbest commented 9 years ago

I installed the Python Wing IDE and debugged through the fips build functionality. It seems to get Windows Store and Windows Phone support we just need to modify the mocros in fips.cmake. If you like I can make the changes. Is there are any design requirements I need to follow? Im not sure how to implement target_link_libraries. Please let me know.

Add these to the CMakeLists.txt or create mocros:

set(CONTENT_FILES ${CONTENT_FILES} ${CMAKE_CURRENT_BINARY_DIR}/${APP_MANIFEST_NAME} ) set(ASSET_FILES ${ASSET_FILES} Assets/Logo.png Assets/SmallLogo.png Assets/SplashScreen.png Assets/StoreLogo.png ) set(RESOURCE_FILES ${CONTENT_FILES} ${DEBUG_CONTENT_FILES} ${RELEASE_CONTENT_FILES} ${ASSET_FILES} win-store-app_TemporaryKey.pfx) set_property(SOURCE ${CONTENT_FILES} PROPERTY VS_DEPLOYMENT_CONTENT 1) set_property(SOURCE ${ASSET_FILES} PROPERTY VS_DEPLOYMENT_CONTENT 1) set_property(SOURCE ${ASSET_FILES} PROPERTY VS_DEPLOYMENT_LOCATION "Assets") set_property(SOURCE ${DEBUG_CONTENT_FILES} PROPERTY VS_DEPLOYMENT_CONTENT $CONFIG:Debug) set_property(SOURCE ${RELEASE_CONTENT_FILES} PROPERTY VS_DEPLOYMENT_CONTENT $CONFIG:Release)

Modify the macro fips_end_app if (${CurAppType} STREQUAL "windowed")

a windowed application

    if (FIPS_OSX OR FIPS_IOS)
        add_executable(${CurTargetName} MACOSX_BUNDLE ${CurSources})
        fips_osx_add_target_properties(${CurTargetName})
        fips_copy_osx_dylib_files(${CurTargetName} 1)
    elseif (FIPS_WIN32 OR FIPS_WIN64)
        add_executable(${CurTargetName} WIN32 ${CurSources})
    elseif (FIPS_WINRT)
         set (APP_MANIFEST_NAME Package.appxmanifest)
         set(PLATFORM STORE)
         add_executable(${CurTargetName} WIN32 ${CurSources} ${RESOURCE_FILES})
         set_property(TARGET ${EXE_NAME} PROPERTY VS_WINRT_COMPONENT TRUE)  
         target_link_libraries(${EXE_NAME} d2d1.lib d3d11.lib dxgi.lib windowscodecs.lib dwrite.lib )
    elseif (FIPS_ANDROID)
        add_library(${CurTargetName} SHARED ${CurSources})
    else()
        add_executable(${CurTargetName} ${CurSources})
    endif()
else()
    # a command line application
    if (FIPS_ANDROID)
        add_library(${CurTargetName} SHARED ${CurSources})
    else()
        add_executable(${CurTargetName} ${CurSources})
    endif()
    if (FIPS_OSX OR FIPS_IOS)
        fips_copy_osx_dylib_files(${CurTargetName} 0)
    endif()
endif()
floooh commented 9 years ago

It would be nice if you could wrap the windows app specific cmake code in a separate cmake file called fips_windows.cmake (similar to fips_osx.cmake, fips_android.cmake and fips_pnacl.cmake), these files contain some more or less complex platform specific macros, which are then called from the main fips.cmake files (mostly in the fips_end_xxx() macros).