2019-10-31 23:09:52 +00:00
2023-02-22 21:12:56 +00:00
include ( ${ PROJECT_SOURCE_DIR } /cmake/common_build_flags.cmake )
2019-10-31 23:09:52 +00:00
# All projects need to reference the WIL headers
2023-02-22 21:12:56 +00:00
include_directories ( ${ PROJECT_SOURCE_DIR } /include )
2019-10-31 23:09:52 +00:00
# TODO: Might be worth trying to conditionally do this on SDK version, assuming there's a semi-easy way to detect that
include_directories ( BEFORE SYSTEM ./workarounds/wrl )
2023-02-22 21:12:56 +00:00
# Because we don't always use msbuild, we need to run nuget manually
find_program ( NUGET nuget )
if ( NOT NUGET )
message ( FATAL_ERROR "Unable to find the nuget CLI tool. Please install it from https://www.nuget.org/downloads and ensure it has been added to the PATH" )
endif ( )
execute_process ( COMMAND
$ { N U G E T } i n s t a l l M i c r o s o f t . W i n d o w s . C p p W i n R T - V e r s i o n $ { C P P W I N R T _ V E R S I O N } - O u t p u t D i r e c t o r y p a c k a g e s
W O R K I N G _ D I R E C T O R Y $ { C M A K E _ B I N A R Y _ D I R }
R E S U L T _ V A R I A B L E r e t )
if ( NOT ret EQUAL 0 )
message ( FATAL_ERROR "Failed to install nuget package Microsoft.Windows.CppWinRT.${CPPWINRT_VERSION}" )
endif ( )
set ( CPPWINRT ${ CMAKE_BINARY_DIR } /packages/Microsoft.Windows.CppWinRT. ${ CPPWINRT_VERSION } /bin/cppwinrt.exe )
execute_process ( COMMAND
$ { C P P W I N R T } - i n p u t s d k - o u t p u t i n c l u d e
W O R K I N G _ D I R E C T O R Y $ { C M A K E _ B I N A R Y _ D I R }
R E S U L T _ V A R I A B L E r e t )
if ( NOT ret EQUAL 0 )
message ( FATAL_ERROR "Failed to run cppwinrt.exe" )
endif ( )
include_directories ( BEFORE SYSTEM ${ CMAKE_BINARY_DIR } /include )
2019-10-31 23:09:52 +00:00
# The build pipelines have limitations that local development environments do not, so turn a few knobs
if ( ${ FAST_BUILD } )
replace_cxx_flag ( "/GR" "/GR-" ) # Disables RTTI
add_definitions ( -DCATCH_CONFIG_FAST_COMPILE -DWIL_FAST_BUILD )
endif ( )
2023-02-22 21:12:56 +00:00
# For some unknown reason, 'RelWithDebInfo' compiles with '/Ob1' as opposed to '/Ob2' which prevents inlining of
# functions not marked 'inline'. The reason we prefer 'RelWithDebInfo' over 'Release' is to get debug info, so manually
# revert to the desired (and default) inlining behavior as that exercises more interesting code paths
if ( ${ CMAKE_BUILD_TYPE } STREQUAL "RelWithDebInfo" )
# TODO: This is currently blocked by an apparent Clang bug: https://github.com/llvm/llvm-project/issues/59690
# replace_cxx_flag("/Ob1" "/Ob2")
endif ( )
set ( COMMON_SOURCES
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / m a i n . c p p
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / C o m m o n T e s t s . c p p
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / C o m T e s t s . c p p
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / F i l e S y s t e m T e s t s . c p p
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / N T R e s u l t T e s t s . c p p
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / R e s o u r c e T e s t s . c p p
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / R e s u l t T e s t s . c p p
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / R p c . c p p
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / S a f e C a s t T e s t s . c p p
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / T r a c e L o g g i n g T e s t s . c p p
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / W i s t d T e s t s . c p p
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / w i T e s t . c p p
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / . . / n a t v i s / w i l . n a t v i s
)
2019-10-31 23:09:52 +00:00
add_subdirectory ( app )
add_subdirectory ( cpplatest )
add_subdirectory ( noexcept )
add_subdirectory ( normal )
2023-02-22 21:12:56 +00:00
add_subdirectory ( win7 )
set ( DEBUG_BUILD FALSE )
set ( HAS_DEBUG_INFO FALSE )
if ( ${ CMAKE_BUILD_TYPE } STREQUAL "Debug" )
set ( DEBUG_BUILD TRUE )
set ( HAS_DEBUG_INFO TRUE )
elseif ( ${ CMAKE_BUILD_TYPE } STREQUAL "RelWithDebInfo" )
set ( HAS_DEBUG_INFO TRUE )
endif ( )
set ( ASAN_AVAILABLE FALSE )
set ( UBSAN_AVAILABLE FALSE )
if ( CMAKE_CXX_COMPILER_ID MATCHES "MSVC" )
# Address Sanitizer is available for all architectures and build types, but warns/errors if debug info is not enabled
set ( ASAN_AVAILABLE ${ HAS_DEBUG_INFO } )
elseif ( CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
# Address Sanitizer is not available with debug libraries
set ( ASAN_AVAILABLE NOT ${ DEBUG_BUILD } )
set ( UBSAN_AVAILABLE NOT ${ DEBUG_BUILD } )
endif ( )
if ( ${ ASAN_AVAILABLE } )
add_subdirectory ( sanitize-address )
endif ( )
if ( ${ UBSAN_AVAILABLE } )
add_subdirectory ( sanitize-undefined-behavior )
endif ( )