Skip to content

Commit

Permalink
[Windows] use find_package() for Eigen and frugally-deep (#2574)
Browse files Browse the repository at this point in the history
  • Loading branch information
apwojcik authored Dec 14, 2023
1 parent 1a1a4dd commit 4150134
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 36 deletions.
52 changes: 18 additions & 34 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -719,42 +719,26 @@ target_link_libraries(MIOpen PRIVATE ${CMAKE_DL_LIBS} Threads::Threads ${BZIP2_L
miopen_generate_export_header(MIOpen)

if(MIOPEN_ENABLE_AI_KERNEL_TUNING OR MIOPEN_ENABLE_AI_IMMED_MODE_FALLBACK)
find_path(FDEEP_INCLUDE_DIR "fdeep/fdeep.hpp")
if(${FDEEP_INCLUDE_DIR} STREQUAL "FDEEP_INCLUDE_DIR-NOTFOUND")
if(MIOPEN_ENABLE_AI_KERNEL_TUNING)
message(FATAL_ERROR "MIOPEN_ENABLE_AI_KERNEL_TUNING requirement frugally-deep not found")
endif()
if(MIOPEN_ENABLE_AI_IMMED_MODE_FALLBACK)
message(FATAL_ERROR "MIOPEN_ENABLE_AI_IMMED_MODE_FALLBACK requirement frugally-deep not found")
endif()
endif()

find_path(EIGEN_INCLUDE_DIR "eigen3/Eigen/Core")
if(${EIGEN_INCLUDE_DIR} STREQUAL "EIGEN_INCLUDE_DIR-NOTFOUND")
if(MIOPEN_ENABLE_AI_KERNEL_TUNING)
message(FATAL_ERROR "MIOPEN_ENABLE_AI_KERNEL_TUNING requirement Eigen not found")
endif()
if(MIOPEN_ENABLE_AI_IMMED_MODE_FALLBACK)
message(FATAL_ERROR "MIOPEN_ENABLE_AI_IMMED_MODE_FALLBACK requirement frugally-deep not found")
endif()
endif()

target_include_directories(MIOpen SYSTEM PRIVATE $<BUILD_INTERFACE:${FDEEP_INCLUDE_DIR}>)
target_include_directories(MIOpen SYSTEM PRIVATE $<BUILD_INTERFACE:${EIGEN_INCLUDE_DIR}/eigen3>)
if(NOT BUILD_DEV)
file(GLOB MODEL_FILES kernels/*.model)
if( NOT ENABLE_ASAN_PACKAGING )
install(FILES ${MODEL_FILES} DESTINATION ${DATA_INSTALL_DIR}/db)
endif ()
foreach(MODEL_FILE ${MODEL_FILES})
get_filename_component(MODEL_FILE_FILENAME "${MODEL_FILE}" NAME)
configure_file("${MODEL_FILE}" "${PROJECT_BINARY_DIR}/share/miopen/db/${MODEL_FILE_FILENAME}" COPYONLY)
endforeach()
endif()
find_package(frugally-deep CONFIG REQUIRED GLOBAL)
find_package(Eigen3 REQUIRED GLOBAL)
target_link_libraries(MIOpen PRIVATE frugally-deep::fdeep Eigen3::Eigen)
if(NOT TARGET nlohmann_json)
# frugally-deep has broken linking to nlohmann_json
add_library(nlohmann_json INTERFACE IMPORTED GLOBAL)
target_link_libraries(nlohmann_json INTERFACE nlohmann_json::nlohmann_json)
endif()
if(NOT BUILD_DEV)
file(GLOB MODEL_FILES kernels/*.model)
if( NOT ENABLE_ASAN_PACKAGING )
install(FILES ${MODEL_FILES} DESTINATION ${DATA_INSTALL_DIR}/db)
endif ()
foreach(MODEL_FILE ${MODEL_FILES})
get_filename_component(MODEL_FILE_FILENAME "${MODEL_FILE}" NAME)
configure_file("${MODEL_FILE}" "${PROJECT_BINARY_DIR}/share/miopen/db/${MODEL_FILE_FILENAME}" COPYONLY)
endforeach()
endif()
endif()

set(PACKAGE_DEPENDS)
set(PACKAGE_STATIC_DEPENDS)
############################################################
# MIOpen depends on OpenCL
if( MIOPEN_BACKEND STREQUAL "OpenCL")
Expand Down
3 changes: 1 addition & 2 deletions test/gtest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ function(add_gtest TEST_NAME)
target_compile_options(test_${TEST_NAME} PRIVATE -Wno-global-constructors -Wno-undef)
target_include_directories(test_${TEST_NAME} PRIVATE ../ ../../src/kernels)
if(MIOPEN_ENABLE_AI_KERNEL_TUNING)
target_include_directories(test_${TEST_NAME} SYSTEM PRIVATE $<BUILD_INTERFACE:${FDEEP_INCLUDE_DIR}>)
target_include_directories(test_${TEST_NAME} SYSTEM PRIVATE $<BUILD_INTERFACE:${EIGEN_INCLUDE_DIR}/eigen3>)
target_link_libraries(test_${TEST_NAME} frugally-deep::fdeep Eigen3::Eigen)
endif()
target_link_libraries(test_${TEST_NAME} GTest::gtest GTest::gtest_main MIOpen ${Boost_LIBRARIES} hip::host $<BUILD_INTERFACE:roc::rocblas>)
if(NOT MIOPEN_EMBED_DB STREQUAL "")
Expand Down

0 comments on commit 4150134

Please sign in to comment.