-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Encapsulate the WinRTComponent build.
- Loading branch information
1 parent
a1481f3
commit 5cb0e9b
Showing
88 changed files
with
98 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,44 @@ | ||
cmake_minimum_required(VERSION 3.21.0) | ||
|
||
project(WinRTComponent LANGUAGES CXX) | ||
# Support using this directory as a standalone project or as a subdirectory. | ||
if("${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}") | ||
cmake_minimum_required(VERSION 3.21.0) | ||
project(WinRTComponent LANGUAGES CXX) | ||
endif() | ||
|
||
# Generate the WinRTComponent.winmd file if not previously done | ||
if("${WINRTCOMPONENT_WINMD}" STREQUAL "") | ||
set(WINRTCOMPONENT_WINMD "${CMAKE_CURRENT_BINARY_DIR}/WinRTComponent.winmd") | ||
include(GenerateWinMD.cmake) | ||
generate_winrtcomponent_winmd( | ||
IDL "${CMAKE_CURRENT_SOURCE_DIR}/WinRTComponent.idl" | ||
WINMD "${WINRTCOMPONENT_WINMD}") | ||
if (NOT DEFINED SWIFTWINRT_EXE) | ||
message(FATAL_ERROR "SWIFTWINRT_EXE must be defined") | ||
endif() | ||
cmake_path(ABSOLUTE_PATH SWIFTWINRT_EXE NORMALIZE) | ||
|
||
# Generate the WinRTComponent.winmd file | ||
set(WINRTCOMPONENT_WINMD "${CMAKE_CURRENT_BINARY_DIR}/WinRTComponent.winmd") | ||
include(GenerateWinMD.cmake) | ||
generate_winrtcomponent_winmd( | ||
IDL "${CMAKE_CURRENT_SOURCE_DIR}/IDL/WinRTComponent.idl" | ||
WINMD "${WINRTCOMPONENT_WINMD}") | ||
|
||
# Generate Swift projection | ||
message(STATUS "Generating Swift projection for WinRTComponent...") | ||
include(GenerateProjection.cmake) | ||
generate_projection( | ||
SWIFTWINRT_EXE "${SWIFTWINRT_EXE}" | ||
WINRTCOMPONENT_WINMD "${WINRTCOMPONENT_WINMD}" | ||
PROJECTION_JSON "${CMAKE_CURRENT_SOURCE_DIR}/projection.json" | ||
PROJECTION_DIR "${CMAKE_CURRENT_BINARY_DIR}/Projection/Sources") | ||
|
||
# Generate the C++/WinRT boilerplate | ||
message(STATUS "Generating C++/WinRT boilerplate for WinRTComponent...") | ||
set(CPPWINRT_EXE_NATIVE "$ENV{WindowsSdkVerBinPath}$ENV{VSCMD_ARG_HOST_ARCH}\\cppwinrt.exe") | ||
cmake_path(CONVERT "${WINRTCOMPONENT_WINMD}" TO_NATIVE_PATH_LIST WINRTCOMPONENT_WINMD_NATIVE) | ||
string(REPLACE "\\" "" WINSDK_VERSION "$ENV{WindowsSDKVersion}") | ||
set(CPPWINRT_GENERATED_DIR "${CMAKE_CURRENT_BINARY_DIR}/CppWinRT") | ||
cmake_path(CONVERT "${CPPWINRT_GENERATED_DIR}" TO_NATIVE_PATH_LIST CPPWINRT_GENERATED_DIR_NATIVE) | ||
execute_process( | ||
COMMAND "${CPPWINRT_EXE_NATIVE}" | ||
-input "${WINRTCOMPONENT_WINMD_NATIVE}" | ||
-reference "${WINSDK_VERSION}" | ||
-component "${CPPWINRT_GENERATED_DIR_NATIVE}" -overwrite -optimize | ||
-output "${CPPWINRT_GENERATED_DIR_NATIVE}" | ||
COMMAND_ERROR_IS_FATAL ANY) | ||
# Define the dll build (requires cl.exe) | ||
include(ExternalProject) | ||
ExternalProject_Add(WinRTComponentDll | ||
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Dll" | ||
BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/Dll" | ||
CMAKE_ARGS | ||
-D "WINRTCOMPONENT_WINMD=${WINRTCOMPONENT_WINMD}" | ||
-D "CMAKE_CXX_COMPILER=cl.exe" | ||
-D "CMAKE_CXX_FLAGS=/std:c++latest /W4 /EHsc" | ||
INSTALL_COMMAND "" | ||
TEST_COMMAND "") | ||
|
||
# Build WinRTComponent.dll | ||
file(GLOB SOURCES "*.cpp") | ||
add_library(WinRTComponent SHARED | ||
${SOURCES} | ||
"${CPPWINRT_GENERATED_DIR}/module.g.cpp" # Other .g.cpp files are #included by our .cpp files | ||
WinRTComponent.def) | ||
target_include_directories(WinRTComponent PRIVATE | ||
"${CMAKE_CURRENT_SOURCES_DIR}" | ||
"${CPPWINRT_GENERATED_DIR}") | ||
target_precompile_headers(WinRTComponent PRIVATE pch.h) | ||
# Define the projection build | ||
# TODO(https://github.com/tristanlabelle/swift-winrt/issues/302): Fix linking issues | ||
# add_subdirectory( | ||
# ${CMAKE_CURRENT_BINARY_DIR}/Projection/Sources | ||
# ${CMAKE_CURRENT_BINARY_DIR}/Projection/Build) |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
if(NOT DEFINED WINRTCOMPONENT_WINMD) | ||
message(FATAL_ERROR "WINRTCOMPONENT_WINMD must be defined") | ||
endif() | ||
|
||
# Generate the C++/WinRT boilerplate | ||
message(STATUS "Generating C++/WinRT boilerplate for WinRTComponent...") | ||
set(CPPWINRT_EXE_NATIVE "$ENV{WindowsSdkVerBinPath}$ENV{VSCMD_ARG_HOST_ARCH}\\cppwinrt.exe") | ||
if(NOT EXISTS "${CPPWINRT_EXE_NATIVE}") | ||
message(FATAL_ERROR "Could not find cppwinrt.exe at ${CPPWINRT_EXE_NATIVE}") | ||
endif() | ||
|
||
cmake_path(CONVERT "${WINRTCOMPONENT_WINMD}" TO_NATIVE_PATH_LIST WINRTCOMPONENT_WINMD_NATIVE) | ||
string(REPLACE "\\" "" WINSDK_VERSION "$ENV{WindowsSDKVersion}") | ||
set(CPPWINRT_GENERATED_DIR "${CMAKE_CURRENT_BINARY_DIR}/CppWinRT") | ||
cmake_path(CONVERT "${CPPWINRT_GENERATED_DIR}" TO_NATIVE_PATH_LIST CPPWINRT_GENERATED_DIR_NATIVE) | ||
execute_process( | ||
COMMAND "${CPPWINRT_EXE_NATIVE}" | ||
-input "${WINRTCOMPONENT_WINMD_NATIVE}" | ||
-reference "${WINSDK_VERSION}" | ||
-component "${CPPWINRT_GENERATED_DIR_NATIVE}" -overwrite -optimize | ||
-output "${CPPWINRT_GENERATED_DIR_NATIVE}" | ||
COMMAND_ERROR_IS_FATAL ANY) | ||
|
||
# Build WinRTComponent.dll | ||
file(GLOB SOURCES "*.cpp") | ||
add_library(WinRTComponent SHARED | ||
${SOURCES} | ||
"${CPPWINRT_GENERATED_DIR}/module.g.cpp" # Other .g.cpp files are #included by our .cpp files | ||
WinRTComponent.def) | ||
target_include_directories(WinRTComponent PRIVATE | ||
"${CMAKE_CURRENT_SOURCES_DIR}" | ||
"${CPPWINRT_GENERATED_DIR}") | ||
target_precompile_headers(WinRTComponent PRIVATE pch.h) |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
File renamed without changes.