1- cmake_minimum_required (VERSION 3.16 )
2- project (winsdk)
1+ cmake_minimum_required (VERSION 3.24 )
2+ cmake_policy (SET CMP0091 NEW )
3+ project (winsdk LANGUAGES CXX )
34
45file (GLOB sources "${CMAKE_CURRENT_SOURCE_DIR} /pywinrt/${CMAKE_PROJECT_NAME} /src/*.cpp" )
56
6- file (GLOB headers RELATIVE "${CMAKE_CURRENT_SOURCE_DIR} "
7- "pywinrt/${CMAKE_PROJECT_NAME} /src/py.*.h"
8- )
9-
107set (CMAKE_CXX_STANDARD 20)
118set (CMAKE_CXX_STANDARD_REQUIRED ON )
129set (CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG :Debug >:Debug >" )
@@ -24,6 +21,12 @@ if (MSVC)
2421 endif ()
2522else ()
2623 add_compile_options (-Werror )
24+
25+ if (MINGW)
26+ add_definitions (-D_WIN32_WINNT=_WIN32_WINNT_WIN10 )
27+ # fixes "file too big"
28+ add_compile_options (-Wa,-mbig-obj )
29+ endif ()
2730endif ()
2831
2932find_package (Python3 REQUIRED COMPONENTS Development.Module )
@@ -32,13 +35,17 @@ Python3_add_library (_winrt MODULE ${sources})
3235set_target_properties (_winrt PROPERTIES LIBRARY_OUTPUT_NAME_DEBUG _winrt_d )
3336target_precompile_headers (_winrt PRIVATE ${headers} )
3437target_include_directories (_winrt PUBLIC "${CMAKE_CURRENT_SOURCE_DIR} /cppwinrt" "${CMAKE_CURRENT_SOURCE_DIR} /pywinrt/${CMAKE_PROJECT_NAME} /src" )
35- target_link_libraries (_winrt PRIVATE onecore )
3638
37- if ($ENV{CI} )
38- # CI has limited resources (runs out of heap space), so we limit the number
39- # of concurrent processes to combat this
40- set_property (GLOBAL PROPERTY JOB_POOLS compile_job=2 )
41- set_property (TARGET _winrt PROPERTY JOB_POOL_COMPILE compile_job )
42- endif ()
39+ # speed up builds by precompiling commonly used headers
40+ target_precompile_headers (_winrt PRIVATE
41+ "pywinrt/winsdk/src/py.Windows.Foundation.h"
42+ "pywinrt/winsdk/src/py.Windows.Storage.Streams.h"
43+ )
44+ # needed because including windows.h affects winrt
45+ set_property (SOURCE "${CMAKE_CURRENT_SOURCE_DIR} /pywinrt/winsdk/src/runtime.cpp" PROPERTY SKIP_PRECOMPILE_HEADERS ON )
46+ # needed because including Shobjidl.h affects winrt
47+ set_property (SOURCE "${CMAKE_CURRENT_SOURCE_DIR} /pywinrt/winsdk/src/_winrt.cpp" PROPERTY SKIP_PRECOMPILE_HEADERS ON )
48+ # needed because including unknwn.h affects winrt
49+ set_property (SOURCE "${CMAKE_CURRENT_SOURCE_DIR} /pywinrt/winsdk/src/py.Windows.Graphics.Capture.Interop.cpp" PROPERTY SKIP_PRECOMPILE_HEADERS ON )
4350
4451install (TARGETS _winrt DESTINATION "pywinrt/${CMAKE_PROJECT_NAME} " )
0 commit comments