Skip to content

Commit

Permalink
make cmake less verbose (pytorch#308)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: pytorch#308

As title

Reviewed By: dskhudia

Differential Revision: D20157789

fbshipit-source-id: 0842579aa6537b3bd848a9ae7d709336346adfe2
  • Loading branch information
jspark1105 authored and facebook-github-bot committed Feb 28, 2020
1 parent 967d4bc commit b990727
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 9 deletions.
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ set(FBGEMM_THIRDPARTY_DIR ${FBGEMM_BINARY_DIR}/third_party)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

#add address sanitizer
set(USE_SANITIZER "" CACHE string "options include address, leak, ...")
set(USE_SANITIZER "" CACHE STRING "options include address, leak, ...")

#All the source files that either use avx2 instructions statically or JIT
#avx2/avx512 instructions.
Expand Down Expand Up @@ -238,9 +238,9 @@ if(NOT TARGET cpuinfo)
set(CPUINFO_BUILD_UNIT_TESTS OFF CACHE BOOL "Do not build cpuinfo unit tests")
set(CPUINFO_BUILD_MOCK_TESTS OFF CACHE BOOL "Do not build cpuinfo mock tests")
set(CPUINFO_BUILD_BENCHMARKS OFF CACHE BOOL "Do not build cpuinfo benchmarks")
set(CPUINFO_LIBRARY_TYPE static CACHE string "Set lib type to static")
set(CPUINFO_LIBRARY_TYPE static CACHE STRING "Set lib type to static")
#Select static runtime, needed for static build for MSVC
set(CPUINFO_RUNTIME_TYPE static CACHE string "Set runtime to static")
set(CPUINFO_RUNTIME_TYPE static CACHE STRING "Set runtime to static")
add_subdirectory("${CPUINFO_SOURCE_DIR}" "${FBGEMM_BINARY_DIR}/cpuinfo")
set_property(TARGET cpuinfo PROPERTY POSITION_INDEPENDENT_CODE ON)
endif()
Expand Down
20 changes: 16 additions & 4 deletions bench/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,22 @@ if (NOT ${MKL_FOUND})
find_package(BLAS)
endif()

if (USE_SANITIZER)
message(WARNING "USING SANITIZER IN TEST")
endif()

if (${OpenMP_FOUND})
message(STATUS "OpenMP_LIBRARIES= ${OpenMP_CXX_LIBRARIES}")
endif()

if (${MKL_FOUND})
message(STATUS "MKL_LIBRARIES= ${MKL_LIBRARIES}")
endif()

if (${BLAS_FOUND})
message(STATUS "BLAS_LIBRARIES= ${BLAS_LIBRARIES}")
endif()

#benchmarks
macro(add_benchmark BENCHNAME)
add_executable(${BENCHNAME} ${ARGN}
Expand All @@ -18,26 +34,22 @@ macro(add_benchmark BENCHNAME)
add_dependencies(${BENCHNAME} fbgemm)

if (USE_SANITIZER)
message(WARNING "USING SANITIZER IN TEST")
target_compile_options(${BENCHNAME} PRIVATE
"-fsanitize=${USE_SANITIZER}" "-fno-omit-frame-pointer")
target_link_options(${BENCHNAME} PRIVATE "-fsanitize=${USE_SANITIZER}")
endif()

if(${OpenMP_FOUND})
message(STATUS "OpenMP_LIBRARIES= ${OpenMP_CXX_LIBRARIES}")
target_link_libraries(${BENCHNAME} "${OpenMP_CXX_LIBRARIES}")
endif()

if(${MKL_FOUND})
message(STATUS "MKL_LIBRARIES= ${MKL_LIBRARIES}")
target_include_directories(${BENCHNAME} PRIVATE "${MKL_INCLUDE_DIR}")
target_link_libraries(${BENCHNAME} "${MKL_LIBRARIES}")
target_compile_options(${BENCHNAME} PRIVATE
"-DUSE_MKL")
endif()
if (${BLAS_FOUND})
message(STATUS "BLAS_LIBRARIES= ${BLAS_LIBRARIES}")
target_compile_options(${BENCHNAME} PRIVATE "-DUSE_BLAS")
target_link_libraries(${BENCHNAME} "${BLAS_LIBRARIES}")
endif()
Expand Down
10 changes: 8 additions & 2 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ if(FBGEMM_BUILD_TESTS AND NOT TARGET gtest)
add_subdirectory("${GOOGLETEST_SOURCE_DIR}" "${FBGEMM_BINARY_DIR}/googletest")
endif()

if (USE_SANITIZER)
message(WARNING "USING SANITIZER IN TEST")
endif()

if(${OpenMP_FOUND})
message(STATUS "OpenMP_LIBRARIES= ${OpenMP_CXX_LIBRARIES}")
endif()

macro(add_gtest TESTNAME)
add_executable(${TESTNAME} ${ARGN}
../bench/BenchUtils.cc
Expand All @@ -41,7 +49,6 @@ macro(add_gtest TESTNAME)
"-m64" "-mavx2" "-mfma" "-masm=intel")
endif(MSVC)
if (USE_SANITIZER)
message(WARNING "USING SANITIZER IN TEST")
target_compile_options(${TESTNAME} PRIVATE
"-fsanitize=${USE_SANITIZER}" "-fno-omit-frame-pointer")
target_link_options(${TESTNAME} PRIVATE "-fsanitize=${USE_SANITIZER}")
Expand All @@ -50,7 +57,6 @@ macro(add_gtest TESTNAME)
target_link_libraries(${TESTNAME} gtest gmock gtest_main fbgemm)

if(${OpenMP_FOUND})
message(STATUS "OpenMP_LIBRARIES= ${OpenMP_CXX_LIBRARIES}")
target_link_libraries(${TESTNAME} ${OpenMP_CXX_LIBRARIES})
endif()

Expand Down

0 comments on commit b990727

Please sign in to comment.