From 5f84ea865875752ecb7f74dcd50d49e5ac535071 Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Wed, 7 Apr 2021 08:48:16 -0400 Subject: [PATCH] CMake jit_preprocess_files function only runs when needed (#7872) This correct a couple of issues with the `jit_preprocess_files` function. 1. It now always makes sure that the output directory that the jit headers are going into will exist before executing. So if a user deletes `/include` everything will work as expected 2. The output of the jitify tool are files that end in `.jit.hpp` not `.jit`. This is required to allow generators to build the minimal incremental compilation graph 3. Mark the input source files as a dependency so when that file is modified, the build-system knows to recompile the jit file. Authors: - Robert Maynard (https://github.com/robertmaynard) Approvers: - Christopher Harris (https://github.com/cwharris) - Nghia Truong (https://github.com/ttnghia) - Jason Lowe (https://github.com/jlowe) - Keith Kraus (https://github.com/kkraus14) URL: https://github.com/rapidsai/cudf/pull/7872 --- cpp/cmake/Modules/JitifyPreprocessKernels.cmake | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/cpp/cmake/Modules/JitifyPreprocessKernels.cmake b/cpp/cmake/Modules/JitifyPreprocessKernels.cmake index 7bb5b1d0a14..a4e827dc26f 100644 --- a/cpp/cmake/Modules/JitifyPreprocessKernels.cmake +++ b/cpp/cmake/Modules/JitifyPreprocessKernels.cmake @@ -14,12 +14,7 @@ # limitations under the License. #============================================================================= -cmake_minimum_required(VERSION 3.18) - -file(MAKE_DIRECTORY "${CUDF_GENERATED_INCLUDE_DIR}/include/jit_preprocessed_files") - # Create `jitify_preprocess` executable -project(jitify_preprocess VERSION 2.0 LANGUAGES CXX CUDA) add_executable(jitify_preprocess "${JITIFY_INCLUDE_DIR}/jitify2_preprocess.cpp") target_link_libraries(jitify_preprocess CUDA::cudart ${CMAKE_DL_LIBS}) @@ -33,12 +28,14 @@ function(jit_preprocess_files) ) foreach(ARG_FILE ${ARG_FILES}) - set(ARG_OUTPUT ${CUDF_GENERATED_INCLUDE_DIR}/include/jit_preprocessed_files/${ARG_FILE}.jit) + set(ARG_OUTPUT ${CUDF_GENERATED_INCLUDE_DIR}/include/jit_preprocessed_files/${ARG_FILE}.jit.hpp) + get_filename_component(jit_output_directory "${ARG_OUTPUT}" DIRECTORY ) list(APPEND JIT_PREPROCESSED_FILES "${ARG_OUTPUT}") add_custom_command(WORKING_DIRECTORY ${ARG_SOURCE_DIRECTORY} - DEPENDS jitify_preprocess + DEPENDS jitify_preprocess "${ARG_SOURCE_DIRECTORY}/${ARG_FILE}" OUTPUT ${ARG_OUTPUT} VERBATIM + COMMAND ${CMAKE_COMMAND} -E make_directory "${jit_output_directory}" COMMAND jitify_preprocess ${ARG_FILE} -o ${CUDF_GENERATED_INCLUDE_DIR}/include/jit_preprocessed_files -v