Skip to content

Conversation

@p-groarke
Copy link
Contributor

These changes allow a user to install WIL using cmake and consume it through available cmake mechanisms like find_package, ExternalProject_Add or FetchContent.

You can install it locally using the following command :

cmake .. -DCMAKE_INSTALL_PREFIX=install -DWIL_BUILD_TESTS=Off && cmake --build . && cmake --build . --target install
  • Adds an INTERFACE target for the headers.
  • Adds an install config to export the necessary target find info.
  • Adds options to disable packaging and tests since you usually don't want to build those when consuming a lib (default on to prevent breaking existing builds).
  • Fix the the path variable used in the tests cmake file to support consuming using FetchContent.

Unit tests were ran and passed.

@msftclas
Copy link

msftclas commented May 2, 2020

CLA assistant check
All CLA requirements met.

cmake_minimum_required(VERSION 3.11)
project(WIL)

include(GNUInstallDirs)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Required by install.

endif()

# Gather headers into an interface library.
file(GLOB_RECURSE HEADER_FILES "${PROJECT_SOURCE_DIR}/include/${PROJECT_NAME}/*.h")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adds the INTERFACE target.

file(GLOB_RECURSE HEADER_FILES "${PROJECT_SOURCE_DIR}/include/${PROJECT_NAME}/*.h")
add_library(${PROJECT_NAME} INTERFACE)

# The interface's include directory.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The following installs all cmake required files to find the library.

@@ -1,8 +1,8 @@

include(${CMAKE_SOURCE_DIR}/cmake/common_build_flags.cmake)
include(${PROJECT_SOURCE_DIR}/cmake/common_build_flags.cmake)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PROJECT_SOURCE_DIR is required when running through ExternalProject or FetchContent.

@dunhor dunhor merged commit 8cabf25 into microsoft:master May 7, 2020
@p-groarke p-groarke deleted the cmake branch May 9, 2020 13:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants