From 3d9eb7ffc32c2f5f878bb4aee61d30cb8c62a146 Mon Sep 17 00:00:00 2001 From: Adam Simpkins Date: Fri, 12 Jan 2018 16:02:57 -0800 Subject: [PATCH 1/1] cmake: support using a separate build directory Summary: Fix rules in the CMakeLists.txt file that generate source files to first create their output directory if necessary. This allows the build to succeed when building with a separate build output directory, rather than placing build artifacts in the source tree itself. Reviewed By: meyering Differential Revision: D6710436 fbshipit-source-id: 786a65a37a70833e7e4a5affe4df292626dbb591 --- CMakeLists.txt | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a5dcf63c..f1446753 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -48,23 +48,32 @@ set(FOLLY_DIR "${CMAKE_CURRENT_SOURCE_DIR}/folly") find_package(PythonInterp REQUIRED) add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/folly/build/EscapeTables.cpp - COMMAND ${PYTHON_EXECUTABLE} "${FOLLY_DIR}/build/generate_escape_tables.py" + COMMAND + ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/folly/build + COMMAND + ${PYTHON_EXECUTABLE} "${FOLLY_DIR}/build/generate_escape_tables.py" + --install_dir ${CMAKE_CURRENT_BINARY_DIR}/folly/build DEPENDS ${FOLLY_DIR}/build/generate_escape_tables.py - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/folly/build/ COMMENT "Generating the escape tables..." VERBATIM ) add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/folly/build/FormatTables.cpp - COMMAND ${PYTHON_EXECUTABLE} "${FOLLY_DIR}/build/generate_format_tables.py" + COMMAND + ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/folly/build + COMMAND + ${PYTHON_EXECUTABLE} "${FOLLY_DIR}/build/generate_format_tables.py" + --install_dir ${CMAKE_CURRENT_BINARY_DIR}/folly/build DEPENDS ${FOLLY_DIR}/build/generate_format_tables.py - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/folly/build/ COMMENT "Generating the format tables..." VERBATIM ) add_custom_command( OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/folly/build/GroupVarintTables.cpp" - COMMAND ${PYTHON_EXECUTABLE} "${FOLLY_DIR}/build/generate_varint_tables.py" + COMMAND + ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/folly/build + COMMAND + ${PYTHON_EXECUTABLE} "${FOLLY_DIR}/build/generate_varint_tables.py" + --install_dir ${CMAKE_CURRENT_BINARY_DIR}/folly/build DEPENDS ${FOLLY_DIR}/build/generate_varint_tables.py - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/folly/build/ COMMENT "Generating the group varint tables..." VERBATIM ) @@ -226,9 +235,12 @@ source_group("" FILES ${FOLLY_DIR}/build/GenerateFingerprintTables.cpp) # Compile the fingerprint tables. add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/folly/build/FingerprintTables.cpp - COMMAND GenerateFingerprintTables + COMMAND + ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/folly/build + COMMAND + GenerateFingerprintTables + --install_dir ${CMAKE_CURRENT_BINARY_DIR}/folly/build DEPENDS GenerateFingerprintTables - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/folly/build/ COMMENT "Generating the fingerprint tables..." ) add_library(folly_fingerprint STATIC -- 2.34.1