Skip to content

Commit

Permalink
Formatting cmake (to lowercase without space for if/elseif/else/endif) (
Browse files Browse the repository at this point in the history
pytorch#35521)

Summary:
Running commands:
```bash
shopt -s globstar

sed -e 's/IF (/if(/g' -e 's/IF(/if(/g' -e 's/if (/if(/g' -e 's/ELSE (/else(/g' -e 's/ELSE(/else(/g' -e 's/else (/else(/g' -e 's/ENDif(/endif(/g' -e 's/ELSEif(/elseif(/g' -i CMakeLists.txt
sed -e 's/IF (/if(/g' -e 's/IF(/if(/g' -e 's/if (/if(/g' -e 's/ELSE (/else(/g' -e 's/ELSE(/else(/g' -e 's/else (/else(/g' -e 's/ENDif(/endif(/g' -e 's/ELSEif(/elseif(/g' -i caffe2/**/CMakeLists.txt
sed -e 's/IF (/if(/g' -e 's/IF(/if(/g' -e 's/if (/if(/g' -e 's/ELSE (/else(/g' -e 's/ELSE(/else(/g' -e 's/else (/else(/g' -e 's/ENDif(/endif(/g' -e 's/ELSEif(/elseif(/g' -i torch/**/CMakeLists.txt
sed -e 's/IF (/if(/g' -e 's/IF(/if(/g' -e 's/if (/if(/g' -e 's/ELSE (/else(/g' -e 's/ELSE(/else(/g' -e 's/else (/else(/g' -e 's/ENDif(/endif(/g' -e 's/ELSEif(/elseif(/g' -i c10/**/CMakeLists.txt
sed -e 's/IF (/if(/g' -e 's/IF(/if(/g' -e 's/if (/if(/g' -e 's/ELSE (/else(/g' -e 's/ELSE(/else(/g' -e 's/else (/else(/g' -e 's/ENDif(/endif(/g' -e 's/ELSEif(/elseif(/g' -i cmake/**/*.cmake
sed -e 's/IF (/if(/g' -e 's/IF(/if(/g' -e 's/if (/if(/g' -e 's/ELSE (/else(/g' -e 's/ELSE(/else(/g' -e 's/else (/else(/g' -e 's/ENDif(/endif(/g' -e 's/ELSEif(/elseif(/g' -i cmake/**/*.cmake.in
```
We may further convert all the commands into lowercase according to the following issue: https://gitlab.kitware.com/cmake/cmake/commit/77543bde41b0e52c3959016698b529835945d62d.
Pull Request resolved: pytorch#35521

Differential Revision: D20704382

Pulled By: malfet

fbshipit-source-id: 42186b9b1660c34428ab7ceb8d3f7a0ced5d2e80
  • Loading branch information
peterjc123 authored and facebook-github-bot committed Mar 27, 2020
1 parent 04a3345 commit 45c9ed8
Show file tree
Hide file tree
Showing 47 changed files with 470 additions and 470 deletions.
12 changes: 6 additions & 6 deletions c10/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,20 @@ add_library(c10 ${C10_SRCS} ${C10_HEADERS})
# If building shared library, set dllimport/dllexport proper.
target_compile_options(c10 PRIVATE "-DC10_BUILD_MAIN_LIB")
# Enable hidden visibility if compiler supports it.
if (${COMPILER_SUPPORTS_HIDDEN_VISIBILITY})
if(${COMPILER_SUPPORTS_HIDDEN_VISIBILITY})
target_compile_options(c10 PRIVATE "-fvisibility=hidden")
endif()

# ---[ Dependency of c10
if (${USE_GFLAGS})
if(${USE_GFLAGS})
target_link_libraries(c10 PUBLIC gflags)
endif()

if (${USE_GLOG})
if(${USE_GLOG})
target_link_libraries(c10 PUBLIC glog::glog)
endif()

if (USE_NUMA)
if(USE_NUMA)
message(STATUS "NUMA paths:")
message(STATUS ${Numa_INCLUDE_DIR})
message(STATUS ${Numa_LIBRARIES})
Expand All @@ -63,7 +63,7 @@ else()
message(STATUS "don't use NUMA")
endif()

if (ANDROID)
if(ANDROID)
target_link_libraries(c10 PRIVATE log)
endif()

Expand Down Expand Up @@ -97,6 +97,6 @@ install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
install(FILES ${CMAKE_BINARY_DIR}/c10/macros/cmake_macros.h
DESTINATION include/c10/macros)

if (MSVC AND C10_BUILD_SHARED_LIBS)
if(MSVC AND C10_BUILD_SHARED_LIBS)
install(FILES $<TARGET_PDB_FILE:c10> DESTINATION lib OPTIONAL)
endif()
4 changes: 2 additions & 2 deletions c10/benchmark/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# ---[ Benchmark binaries.

file(GLOB_RECURSE C10_ALL_BENCH_FILES *.cpp)
if (BUILD_TEST)
if(BUILD_TEST)
foreach(bench_src ${C10_ALL_BENCH_FILES})
get_filename_component(bench_file_name ${bench_src} NAME_WE)
set(bench_name "c10_${bench_file_name}")
add_executable(${bench_name} "${bench_src}")
target_link_libraries(${bench_name} c10 benchmark)
if (INSTALL_TEST)
if(INSTALL_TEST)
install(TARGETS ${bench_name} DESTINATION test)
endif()
endforeach()
Expand Down
4 changes: 2 additions & 2 deletions c10/cuda/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ set(CUDA_LINK_LIBRARIES_KEYWORD)
# If building shared library, set dllimport/dllexport proper.
target_compile_options(c10_cuda PRIVATE "-DC10_CUDA_BUILD_MAIN_LIB")
# Enable hidden visibility if compiler supports it.
if (${COMPILER_SUPPORTS_HIDDEN_VISIBILITY})
if(${COMPILER_SUPPORTS_HIDDEN_VISIBILITY})
target_compile_options(c10_cuda PRIVATE "-fvisibility=hidden")
endif()

Expand Down Expand Up @@ -69,6 +69,6 @@ endforeach()
install(FILES ${CMAKE_BINARY_DIR}/c10/cuda/impl/cuda_cmake_macros.h
DESTINATION include/c10/cuda/impl)

if (MSVC AND C10_CUDA_BUILD_SHARED_LIBS)
if(MSVC AND C10_CUDA_BUILD_SHARED_LIBS)
install(FILES $<TARGET_PDB_FILE:c10_cuda> DESTINATION lib OPTIONAL)
endif()
4 changes: 2 additions & 2 deletions c10/cuda/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
set(C10_CUDA_ALL_TEST_FILES
impl/CUDATest.cpp
)
if (BUILD_TEST)
if(BUILD_TEST)
foreach(test_src ${C10_CUDA_ALL_TEST_FILES})
get_filename_component(test_file_name ${test_src} NAME_WE)
set(test_name "c10_cuda_${test_file_name}")
add_executable(${test_name} "${test_src}")
target_link_libraries(${test_name} c10_cuda gtest_main)
add_test(NAME ${test_name} COMMAND $<TARGET_FILE:${test_name}>)
if (INSTALL_TEST)
if(INSTALL_TEST)
install(TARGETS ${test_name} DESTINATION test)
endif()
endforeach()
Expand Down
2 changes: 1 addition & 1 deletion c10/hip/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ target_compile_options(c10_hip PRIVATE ${HIP_CXX_FLAGS})
# If building shared library, set dllimport/dllexport proper.
target_compile_options(c10_hip PRIVATE "-DC10_HIP_BUILD_MAIN_LIB")
# Enable hidden visibility if compiler supports it.
if (${COMPILER_SUPPORTS_HIDDEN_VISIBILITY})
if(${COMPILER_SUPPORTS_HIDDEN_VISIBILITY})
target_compile_options(c10_hip PRIVATE "-fvisibility=hidden")
endif()

Expand Down
4 changes: 2 additions & 2 deletions c10/test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# ---[ Test binaries.

file(GLOB_RECURSE C10_ALL_TEST_FILES *.cpp)
if (BUILD_TEST)
if(BUILD_TEST)
foreach(test_src ${C10_ALL_TEST_FILES})
get_filename_component(test_file_name ${test_src} NAME_WE)
set(test_name "c10_${test_file_name}")
add_executable(${test_name} "${test_src}")
target_link_libraries(${test_name} c10 gmock gtest gtest_main)
add_test(NAME ${test_name} COMMAND $<TARGET_FILE:${test_name}>)
if (INSTALL_TEST)
if(INSTALL_TEST)
install(TARGETS ${test_name} DESTINATION test)
endif()
endforeach()
Expand Down
2 changes: 1 addition & 1 deletion caffe2/contrib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ add_subdirectory(nccl)
add_subdirectory(opencl)
add_subdirectory(prof)
add_subdirectory(shm_mutex)
if (USE_TENSORRT)
if(USE_TENSORRT)
add_subdirectory(tensorrt)
endif()

Expand Down
2 changes: 1 addition & 1 deletion caffe2/contrib/nccl/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
if(USE_NCCL)
if (USE_CUDA)
if(USE_CUDA)
message(STATUS "Include NCCL operators")
set(Caffe2_CONTRIB_NCCL_GPU_SRC
"${CMAKE_CURRENT_SOURCE_DIR}/cuda_nccl_gpu.cc"
Expand Down
2 changes: 1 addition & 1 deletion caffe2/contrib/prof/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if (USE_PROF)
if(USE_PROF)
set(Caffe2_CONTRIB_PROF_CPU_SRCS
"${CMAKE_CURRENT_SOURCE_DIR}/prof_dag_stats_op.cc"
)
Expand Down
4 changes: 2 additions & 2 deletions caffe2/core/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if (INTERN_BUILD_MOBILE AND NOT BUILD_CAFFE2_MOBILE)
if(INTERN_BUILD_MOBILE AND NOT BUILD_CAFFE2_MOBILE)
list(APPEND Caffe2_CPU_SRCS
"${CMAKE_CURRENT_SOURCE_DIR}/common.cc"
)
Expand All @@ -8,7 +8,7 @@ endif()

# ---[ GPU files
# ------[ cuDNN
if (USE_CUDNN)
if(USE_CUDNN)
file(GLOB tmp *_cudnn.cc)
set(Caffe2_GPU_SRCS ${Caffe2_GPU_SRCS} ${tmp})
endif()
Expand Down
6 changes: 3 additions & 3 deletions caffe2/db/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ list(APPEND Caffe2_GPU_SRCS ${Caffe2_DB_COMMON_GPU_SRC})
list(APPEND Caffe2_HIP_SRCS ${Caffe2_DB_COMMON_HIP_SRC})

# DB specific files
if (USE_LMDB)
if(USE_LMDB)
list(APPEND Caffe2_CPU_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/lmdb.cc")
endif()

if (USE_LEVELDB)
if(USE_LEVELDB)
list(APPEND Caffe2_CPU_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/leveldb.cc")
endif()

if (USE_ZMQ)
if(USE_ZMQ)
list(APPEND Caffe2_CPU_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/zmqdb.cc")
endif()

Expand Down
2 changes: 1 addition & 1 deletion caffe2/distributed/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ set(Caffe2_STORE_REDIS_GPU_SRC
list(APPEND Caffe2_CPU_SRCS ${Caffe2_STORE_COMMON_SRC})
list(APPEND Caffe2_GPU_SRCS ${Caffe2_STORE_COMMON_GPU_SRC})

if (USE_REDIS)
if(USE_REDIS)
list(APPEND Caffe2_CPU_SRCS ${Caffe2_STORE_REDIS_SRC})
list(APPEND Caffe2_GPU_SRCS ${Caffe2_STORE_REDIS_GPU_SRC})
endif()
Expand Down
2 changes: 1 addition & 1 deletion caffe2/mobile/contrib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
add_subdirectory(ios)

if (USE_NNAPI)
if(USE_NNAPI)
add_subdirectory(nnapi)
endif()

Expand Down
2 changes: 1 addition & 1 deletion caffe2/mobile/contrib/ios/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ if(IOS)
)
set(Caffe2_CPU_SRCS ${Caffe2_CPU_SRCS} ${Caffe2_CONTRIB_IOS_SRC})

if (USE_METAL)
if(USE_METAL)
# metal/mpscnn files
add_subdirectory(mpscnn)
endif()
Expand Down
2 changes: 1 addition & 1 deletion caffe2/mobile/contrib/nnapi/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if (USE_NNAPI AND ANDROID)
if(USE_NNAPI AND ANDROID)
set(Caffe2_CONTRIB_NNAPI_CPU_SRC
"${CMAKE_CURRENT_SOURCE_DIR}/dlnnapi.c"
"${CMAKE_CURRENT_SOURCE_DIR}/nnapi.cc"
Expand Down
8 changes: 4 additions & 4 deletions caffe2/operators/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# ---[ GPU files
# ------[ cuDNN
if (USE_CUDNN)
if(USE_CUDNN)
file(GLOB tmp *_cudnn.cc *_cudnn.cu)
set(Caffe2_GPU_SRCS ${Caffe2_GPU_SRCS} ${tmp})
endif()
# ------[ general GPU
file(GLOB tmp *_gpu.cc)
set(Caffe2_GPU_SRCS ${Caffe2_GPU_SRCS} ${tmp})
# ------[ TensorRT
if (USE_TENSORRT)
if(USE_TENSORRT)
file(GLOB tmp *_trt.cc)
set(Caffe2_GPU_SRCS ${Caffe2_GPU_SRCS} ${tmp})
endif()
Expand Down Expand Up @@ -42,7 +42,7 @@ exclude(tmp "${tmp}" ${tmp_cudnn})
set(Caffe2_CPU_SRCS ${Caffe2_CPU_SRCS} ${tmp})

# Add all files in experimental
if (NOT INTERN_BUILD_MOBILE)
if(NOT INTERN_BUILD_MOBILE)
set(Caffe2_CPU_SRCS ${Caffe2_CPU_SRCS} ${CMAKE_CURRENT_LIST_DIR}/experimental/c10/cpu/flatten_cpu.cc)
set(Caffe2_CPU_SRCS ${Caffe2_CPU_SRCS} ${CMAKE_CURRENT_LIST_DIR}/experimental/c10/cpu/averaged_loss_cpu.cc)
set(Caffe2_CPU_SRCS ${Caffe2_CPU_SRCS} ${CMAKE_CURRENT_LIST_DIR}/experimental/c10/cpu/mul_cpu.cc)
Expand Down Expand Up @@ -70,7 +70,7 @@ exclude(Caffe2_CPU_SRCS "${Caffe2_CPU_SRCS}" ${Caffe2_GPU_SRCS} ${Caffe2_HIP_SRC

# ---[ GPU test files
# ------[ cuDNN
if (USE_CUDNN)
if(USE_CUDNN)
file(GLOB tmp *_cudnn_test.cc)
set(Caffe2_GPU_TEST_SRCS ${Caffe2_GPU_TEST_SRCS} ${tmp})
endif()
Expand Down
4 changes: 2 additions & 2 deletions caffe2/operators/rnn/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ---[ GPU files
# ------[ cuDNN
if (USE_CUDNN)
if(USE_CUDNN)
file(GLOB tmp *_cudnn.cc)
set(Caffe2_GPU_SRCS ${Caffe2_GPU_SRCS} ${tmp})
endif()
Expand Down Expand Up @@ -38,7 +38,7 @@ exclude(Caffe2_CPU_SRCS "${Caffe2_CPU_SRCS}" ${Caffe2_GPU_SRCS} ${Caffe2_HIP_SRC

# ---[ GPU test files
# ------[ cuDNN
if (USE_CUDNN)
if(USE_CUDNN)
file(GLOB tmp *_cudnn_test.cc)
set(Caffe2_GPU_TEST_SRCS ${Caffe2_GPU_TEST_SRCS} ${tmp})
endif()
Expand Down
10 changes: 5 additions & 5 deletions caffe2/perfkernels/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if (INTERN_BUILD_MOBILE AND NOT BUILD_CAFFE2_MOBILE)
if(INTERN_BUILD_MOBILE AND NOT BUILD_CAFFE2_MOBILE)
list(APPEND Caffe2_CPU_SRCS
"${CMAKE_CURRENT_SOURCE_DIR}/embedding_lookup_idx.cc"
)
Expand All @@ -21,14 +21,14 @@ set(Caffe2_CPU_SRCS ${Caffe2_CPU_SRCS} ${common_srcs})

# We will only build the perf kernel files if the compiler supports avx2
# extensions.
if (CAFFE2_COMPILER_SUPPORTS_AVX2_EXTENSIONS)
if(CAFFE2_COMPILER_SUPPORTS_AVX2_EXTENSIONS)
add_library(Caffe2_perfkernels_avx STATIC ${avx_srcs})
add_library(Caffe2_perfkernels_avx2 STATIC ${avx2_srcs})
add_dependencies(Caffe2_perfkernels_avx Caffe2_PROTO)
add_dependencies(Caffe2_perfkernels_avx2 Caffe2_PROTO)
target_link_libraries(Caffe2_perfkernels_avx PRIVATE c10)
target_link_libraries(Caffe2_perfkernels_avx2 PRIVATE c10)
if (MSVC)
if(MSVC)
target_compile_options(Caffe2_perfkernels_avx
PRIVATE "/arch:AVX"
PRIVATE "/D__F16C__")
Expand Down Expand Up @@ -57,11 +57,11 @@ if (CAFFE2_COMPILER_SUPPORTS_AVX2_EXTENSIONS)
Caffe2_DEPENDENCY_WHOLE_LINK_LIBS
"Caffe2_perfkernels_avx2_interface")

if (CAFFE2_COMPILER_SUPPORTS_AVX512_EXTENSIONS)
if(CAFFE2_COMPILER_SUPPORTS_AVX512_EXTENSIONS)
add_library(Caffe2_perfkernels_avx512 STATIC ${avx512_srcs})
add_dependencies(Caffe2_perfkernels_avx512 Caffe2_PROTO)
target_link_libraries(Caffe2_perfkernels_avx512 PRIVATE c10)
if (MSVC)
if(MSVC)
target_compile_options(Caffe2_perfkernels_avx512
PRIVATE "/D__AVX512F__"
PRIVATE "/D__AVX512DQ__"
Expand Down
2 changes: 1 addition & 1 deletion caffe2/proto/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ caffe2_protobuf_generate_cpp_py(Caffe2_PROTO_SRCS Caffe2_PROTO_HEADERS Caffe2_PR

add_library(Caffe2_PROTO OBJECT ${Caffe2_PROTO_HEADERS} ${Caffe2_PROTO_SRCS})

if (MSVC)
if(MSVC)
if(BUILD_SHARED_LIBS)
set(Caffe2_API_DEFINE "-DCAFFE2_API=__declspec(dllexport)")
else()
Expand Down
4 changes: 2 additions & 2 deletions caffe2/quantization/server/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ list(APPEND Caffe2_CPU_SRCS
#"${CMAKE_CURRENT_SOURCE_DIR}/sigmoid_test.cc")
#"${CMAKE_CURRENT_SOURCE_DIR}/tanh_test.cc")

if (CAFFE2_COMPILER_SUPPORTS_AVX2_EXTENSIONS)
if(CAFFE2_COMPILER_SUPPORTS_AVX2_EXTENSIONS)
add_library(caffe2_dnnlowp_avx2_ops OBJECT ${caffe2_dnnlowp_avx2_ops_SRCS})
add_dependencies(caffe2_dnnlowp_avx2_ops fbgemm Caffe2_PROTO c10)
target_include_directories(caffe2_dnnlowp_avx2_ops BEFORE
PRIVATE $<BUILD_INTERFACE:${FBGEMM_SOURCE_DIR}/include>)

if (MSVC)
if(MSVC)
set_property(SOURCE ${caffe2_dnnlowp_avx2_ops_SRCS}
APPEND_STRING PROPERTY COMPILE_FLAGS " /arch:AVX2 ")
else()
Expand Down
2 changes: 1 addition & 1 deletion caffe2/share/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# There is a linking issue that happens in some of the Windows builds.
# TODO(Yangqing): after the module redesing, enable this back.
if (NOT MSVC)
if(NOT MSVC)
add_subdirectory(contrib)
endif()

Expand Down
6 changes: 3 additions & 3 deletions caffe2/share/contrib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
if (USE_NNPACK AND BUILD_CAFFE2_OPS)
if(USE_NNPACK AND BUILD_CAFFE2_OPS)
add_subdirectory(nnpack)
endif()
if (USE_ZSTD)
if(USE_ZSTD)
add_subdirectory(zstd)
endif()
if (NOT MSVC)
if(NOT MSVC)
add_subdirectory(depthwise)
endif()

Expand Down
4 changes: 2 additions & 2 deletions caffe2/utils/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# TODO: Add ThreadPoolXNNPACK.cc when XNNPACK integration is updated
# to pass the actual threadpool ptr instead of nullptr.
if (INTERN_BUILD_MOBILE AND NOT BUILD_CAFFE2_MOBILE)
if(INTERN_BUILD_MOBILE AND NOT BUILD_CAFFE2_MOBILE)
add_definitions(-DUSE_INTERNAL_THREADPOOL_IMPL)
list(APPEND Caffe2_CPU_SRCS
utils/string_utils.cc
Expand Down Expand Up @@ -36,7 +36,7 @@ list(APPEND Caffe2_CPU_SRCS
# ---[ threadpool/pthreadpool* is a local modification of the NNPACK
# pthreadpool with a very similar interface. Neither NNPACK, nor this
# thread pool supports Windows.
if (NOT MSVC)
if(NOT MSVC)
add_definitions(-DUSE_INTERNAL_THREADPOOL_IMPL)
set(Caffe2_CPU_SRCS ${Caffe2_CPU_SRCS}
utils/threadpool/pthreadpool.cc
Expand Down
Loading

0 comments on commit 45c9ed8

Please sign in to comment.