Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve ergonomics of WIL::WIL CMake target for consumers using LLVM/MinGW #467

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,28 @@ file(GLOB_RECURSE HEADER_FILES "${PROJECT_SOURCE_DIR}/include/${PROJECT_NAME}/*.
add_library(${PROJECT_NAME} INTERFACE)
add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME})

# If MinGW and Clang, define SAL annotations as macros with empty definitions.
if(MINGW AND CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
target_compile_definitions(${PROJECT_NAME} INTERFACE
_Frees_ptr_=
_Frees_ptr_opt_=
_Post_z_=
_Pre_maybenull_=
_Pre_opt_valid_=
_Pre_valid_=
_Translates_last_error_to_HRESULT_=
InterlockedDecrementNoFence=InterlockedDecrement
InterlockedIncrementNoFence=InterlockedIncrement
WIL_NO_SLIM_EVENT=
)
target_compile_options(${PROJECT_NAME} INTERFACE
"-fms-extensions"
"-D_Ret_opt_bytecap_(size)="
"-D_Translates_NTSTATUS_to_HRESULT_(status)="
"-D_Translates_Win32_to_HRESULT_(err)="
)
endif()

# The interface's include directory.
target_include_directories(${PROJECT_NAME} INTERFACE
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
Expand Down