Commit 2324cfbe authored by Adam Simpkins's avatar Adam Simpkins Committed by Facebook Github Bot

cmake: fix generation of folly-config.cmake

Summary:
The install step for folly CMake-based builds installs a folly-config.cmake
file that downstream projects can use to depend on folly in their own
CMakeLists.txt files.

CMakeLists.txt was previously generating the folly-config.cmake file by copying
CMake/folly-deps.cmake.  This seems wrong, as the installed folly-config.cmake
file should not contain `find_package()` statements that depend on CMake
modules only available in the folly source.

This adds a new folly-config.cmake.in template instead.

Reviewed By: yfeldblum

Differential Revision: D7035992

fbshipit-source-id: e6023094a807cf481ac49998c6f21b213be6c288
parent 9b7a5507
# CMake configuration file for folly
# It defines the following variables
# FOLLY_INCLUDE_DIRS
# FOLLY_LIBRARIES
# Compute paths
get_filename_component(FOLLY_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
get_filename_component(
FOLLY_INCLUDE_DIRS
"${FOLLY_CMAKE_DIR}/../../include"
ABSOLUTE)
# Include the folly-targets.cmake file, which is generated from our CMake rules
if(NOT TARGET Folly::folly)
include("${FOLLY_CMAKE_DIR}/folly-targets.cmake")
endif()
# Set FOLLY_LIBRARIES from our Folly::folly target
set(FOLLY_LIBRARIES Folly::folly)
...@@ -285,23 +285,33 @@ auto_install_files(folly ${FOLLY_DIR} ...@@ -285,23 +285,33 @@ auto_install_files(folly ${FOLLY_DIR}
${FOLLY_DIR}/detail/SlowFingerprint.h ${FOLLY_DIR}/detail/SlowFingerprint.h
${FOLLY_DIR}/detail/FingerprintPolynomial.h ${FOLLY_DIR}/detail/FingerprintPolynomial.h
) )
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/folly/folly-config.h DESTINATION include/folly) install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/folly/folly-config.h
DESTINATION include/folly
COMPONENT dev
)
# Generate the folly-config.cmake file for installation so that
# downstream projects that use on folly can easily depend on it in their CMake
# files using "find_package(folly CONFIG)"
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/CMake/folly-config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/folly-config.cmake
@ONLY
)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/folly-config.cmake
DESTINATION share/folly
COMPONENT dev
)
install( install(
EXPORT folly EXPORT folly
DESTINATION share/folly DESTINATION share/folly
NAMESPACE Folly:: NAMESPACE Folly::
FILE folly-targets.cmake FILE folly-targets.cmake
COMPONENT dev
) )
# We need a wrapper config file to do the find_package calls to ensure
# that all our dependencies are available to link against.
file(
COPY ${CMAKE_CURRENT_SOURCE_DIR}/CMake/folly-deps.cmake
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/
)
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/folly-deps.cmake "\ninclude(folly-targets.cmake)\n")
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/folly-deps.cmake DESTINATION share/folly RENAME folly-config.cmake)
option(BUILD_TESTS "If enabled, compile the tests." OFF) option(BUILD_TESTS "If enabled, compile the tests." OFF)
option(BUILD_BROKEN_TESTS "If enabled, compile tests that are known to be broken." OFF) option(BUILD_BROKEN_TESTS "If enabled, compile tests that are known to be broken." OFF)
option(BUILD_HANGING_TESTS "If enabled, compile tests that are known to hang." OFF) option(BUILD_HANGING_TESTS "If enabled, compile tests that are known to hang." OFF)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment