r355253 - lib/Header: Simplify CMakeLists.txt
Tom Stellard via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 1 16:50:13 PST 2019
Author: tstellar
Date: Fri Mar 1 16:50:13 2019
New Revision: 355253
URL: http://llvm.org/viewvc/llvm-project?rev=355253&view=rev
Log:
lib/Header: Simplify CMakeLists.txt
Summary:
Replace cut and pasted code with cmake macros and reduce the number of
install commands. This fixes an issue where the headers were being
installed twice.
This clean up should also make future modifications easier, like
adding a cmake option to install header files into a custom resource
directory.
Reviewers: chandlerc, smeenai, mgorny, beanz, phosek
Reviewed By: smeenai
Subscribers: cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D58537
Modified:
cfe/trunk/lib/Headers/CMakeLists.txt
Modified: cfe/trunk/lib/Headers/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/CMakeLists.txt?rev=355253&r1=355252&r2=355253&view=diff
==============================================================================
--- cfe/trunk/lib/Headers/CMakeLists.txt (original)
+++ cfe/trunk/lib/Headers/CMakeLists.txt Fri Mar 1 16:50:13 2019
@@ -123,60 +123,51 @@ set(cuda_wrapper_files
)
set(output_dir ${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION}/include)
-
-# Generate arm_neon.h
-clang_tablegen(arm_neon.h -gen-arm-neon
- -I ${CLANG_SOURCE_DIR}/include/clang/Basic/
- SOURCE ${CLANG_SOURCE_DIR}/include/clang/Basic/arm_neon.td)
-# Generate arm_fp16.h
-clang_tablegen(arm_fp16.h -gen-arm-fp16
- -I ${CLANG_SOURCE_DIR}/include/clang/Basic/
- SOURCE ${CLANG_SOURCE_DIR}/include/clang/Basic/arm_fp16.td)
-
set(out_files)
-foreach( f ${files} ${cuda_wrapper_files} )
- set( src ${CMAKE_CURRENT_SOURCE_DIR}/${f} )
- set( dst ${output_dir}/${f} )
+
+function(copy_header_to_output_dir src_dir file)
+ set(src ${src_dir}/${file})
+ set(dst ${output_dir}/${file})
add_custom_command(OUTPUT ${dst}
DEPENDS ${src}
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${src} ${dst}
- COMMENT "Copying clang's ${f}...")
+ COMMENT "Copying clang's ${file}...")
list(APPEND out_files ${dst})
+ set(out_files ${out_files} PARENT_SCOPE)
+endfunction(copy_header_to_output_dir)
+
+function(clang_generate_header td_option td_file out_file)
+ clang_tablegen(${out_file} ${td_option}
+ -I ${CLANG_SOURCE_DIR}/include/clang/Basic/
+ SOURCE ${CLANG_SOURCE_DIR}/include/clang/Basic/${td_file})
+
+ copy_header_to_output_dir(${CMAKE_CURRENT_BINARY_DIR} ${out_file})
+ set(out_files ${out_files} PARENT_SCOPE)
+endfunction(clang_generate_header)
+
+
+# Copy header files from the source directory to the build directory
+foreach( f ${files} ${cuda_wrapper_files} )
+ copy_header_to_output_dir(${CMAKE_CURRENT_SOURCE_DIR} ${f})
endforeach( f )
-add_custom_command(OUTPUT ${output_dir}/arm_neon.h
- DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/arm_neon.h
- COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_BINARY_DIR}/arm_neon.h ${output_dir}/arm_neon.h
- COMMENT "Copying clang's arm_neon.h...")
-list(APPEND out_files ${output_dir}/arm_neon.h)
-add_custom_command(OUTPUT ${output_dir}/arm_fp16.h
- DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/arm_fp16.h
- COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_BINARY_DIR}/arm_fp16.h ${output_dir}/arm_fp16.h
- COMMENT "Copying clang's arm_fp16.h...")
-list(APPEND out_files ${output_dir}/arm_fp16.h)
+# Generate header files and copy them to the build directory
+# Generate arm_neon.h
+clang_generate_header(-gen-arm-neon arm_neon.td arm_neon.h)
+# Generate arm_fp16.h
+clang_generate_header(-gen-arm-fp16 arm_fp16.td arm_fp16.h)
add_custom_target(clang-headers ALL DEPENDS ${out_files})
set_target_properties(clang-headers PROPERTIES
FOLDER "Misc"
RUNTIME_OUTPUT_DIRECTORY "${output_dir}")
-install(
- FILES ${files} ${CMAKE_CURRENT_BINARY_DIR}/arm_neon.h
- COMPONENT clang-headers
- PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
- DESTINATION lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/include)
-
-install(
- FILES ${files} ${CMAKE_CURRENT_BINARY_DIR}/arm_fp16.h
- COMPONENT clang-headers
- PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
- DESTINATION lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/include)
+set(header_install_dir lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION})
install(
- FILES ${cuda_wrapper_files}
- COMPONENT clang-headers
- PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
- DESTINATION lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/include/cuda_wrappers)
+ DIRECTORY ${output_dir}
+ DESTINATION ${header_install_dir}
+ COMPONENT clang-headers)
if (NOT LLVM_ENABLE_IDE)
add_llvm_install_targets(install-clang-headers
More information about the cfe-commits
mailing list