-
Notifications
You must be signed in to change notification settings - Fork 271
cmake : Add install target to support consuming WIL through cmake. #137
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,12 @@ | ||
| cmake_minimum_required(VERSION 3.11) | ||
| project(WIL) | ||
|
|
||
| include(GNUInstallDirs) | ||
|
|
||
| # Set by build server to speed up build/reduce file/object size | ||
| option(FAST_BUILD "Sets options to speed up build/reduce obj/executable size" OFF) | ||
| option(WIL_BUILD_PACKAGING "Sets option to build the packaging, default on" On) | ||
| option(WIL_BUILD_TESTS "Sets option to build the unit tests, default on" On) | ||
|
|
||
| if (NOT DEFINED WIL_BUILD_VERSION) | ||
| set(WIL_BUILD_VERSION "0.0.0") | ||
|
|
@@ -17,5 +21,31 @@ else() | |
| string(REGEX REPLACE "\\\\$" "" WIL_WINDOWS_SDK_VERSION "$ENV{WindowsSDKVersion}") | ||
| endif() | ||
|
|
||
| add_subdirectory(packaging) | ||
| add_subdirectory(tests) | ||
| if (${WIL_BUILD_PACKAGING}) | ||
| add_subdirectory(packaging) | ||
| endif() | ||
|
|
||
| if (${WIL_BUILD_TESTS}) | ||
| add_subdirectory(tests) | ||
| endif() | ||
|
|
||
| # Gather headers into an interface library. | ||
| file(GLOB_RECURSE HEADER_FILES "${PROJECT_SOURCE_DIR}/include/${PROJECT_NAME}/*.h") | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adds the INTERFACE target. |
||
| add_library(${PROJECT_NAME} INTERFACE) | ||
|
|
||
| # The interface's include directory. | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The following installs all cmake required files to find the library. |
||
| target_include_directories(${PROJECT_NAME} INTERFACE | ||
| $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> | ||
| $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> | ||
| ) | ||
|
|
||
| # Install Package Configuration | ||
| install(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}_targets) | ||
| install(EXPORT ${PROJECT_NAME}_targets | ||
| NAMESPACE ${PROJECT_NAME}:: | ||
| FILE ${PROJECT_NAME}-config.cmake | ||
| DESTINATION "${CMAKE_INSTALL_DATADIR}/cmake/${PROJECT_NAME}" | ||
| ) | ||
|
|
||
| # Install the headers at a standard cmake location. | ||
| install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/${PROJECT_NAME}" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,8 @@ | ||
|
|
||
| include(${CMAKE_SOURCE_DIR}/cmake/common_build_flags.cmake) | ||
| include(${PROJECT_SOURCE_DIR}/cmake/common_build_flags.cmake) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| cmake_minimum_required(VERSION 3.11) | ||
|
|
||
| # All projects need to reference the WIL headers | ||
| include_directories(${CMAKE_SOURCE_DIR}/include) | ||
| include_directories(${PROJECT_SOURCE_DIR}/include) | ||
|
|
||
| # 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) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Required by install.