Skip to content

Commit

Permalink
Revert "[GNA] Remove old GNA1 from Cmake scripts (#1686)" (#1864)
Browse files Browse the repository at this point in the history
This reverts commit ffe8599.
  • Loading branch information
pavel-rodionov authored Aug 20, 2020
1 parent f57d612 commit 6d7f2f0
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 17 deletions.
38 changes: 34 additions & 4 deletions inference-engine/cmake/FindlibGNA.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,50 @@ endif ()

set(libGNA_FOUND TRUE)

set(GNA_KERNEL_LIB_NAME gna CACHE STRING "" FORCE)
set(GNA_LIBS_LIST
"libGNA::API"
"libGNA::KERNEL")
set(libGNA_LIBRARIES_BASE_PATH "${GNA}/${GNA_PLATFORM_DIR}/x64" CACHE STRING "" FORCE)

if (GNA_LIBRARY_VERSION STREQUAL "GNA1")
# use old version of GNA Library from gna_20181120
if (WIN32)
set(GNA_LIB_DIR x64 CACHE STRING "" FORCE)
else ()
list(APPEND GNA_LIBS_LIST
"libGNA::OLD_API_LIB")
set(GNA_LIB_DIR lib CACHE STRING "" FORCE)
set(GNA_KERNEL_LIB_NAME gna_kernel CACHE STRING "" FORCE)
endif()
set(libGNA_INCLUDE_DIRS "${GNA}/${GNA_PLATFORM_DIR}/include" CACHE STRING "" FORCE)
else()
# use current version of GNA library
set(GNA_LIB_DIR x64 CACHE STRING "" FORCE)
set(libGNA_INCLUDE_DIRS "${GNA}/include" CACHE STRING "" FORCE)
endif()
set(libGNA_LIBRARIES_BASE_PATH ${GNA}/${GNA_PLATFORM_DIR}/${GNA_LIB_DIR} CACHE STRING "" FORCE)

add_library(libGNA::KERNEL SHARED IMPORTED)
find_library(GNA_KERNEL_LIBRARY
gna
${GNA_KERNEL_LIB_NAME}
HINTS
${libGNA_LIBRARIES_BASE_PATH})
set_target_properties(libGNA::KERNEL PROPERTIES IMPORTED_LOCATION ${GNA_KERNEL_LIBRARY})

if ((GNA_LIBRARY_VERSION STREQUAL "GNA1") AND (NOT WIN32))
add_library(libGNA::OLD_API_LIB SHARED IMPORTED)
find_library(GNA_API_LIBRARY
gna_api
HINTS
${libGNA_LIBRARIES_BASE_PATH})
set_target_properties(libGNA::OLD_API_LIB PROPERTIES IMPORTED_LOCATION ${GNA_API_LIBRARY})
target_link_libraries(libGNA::OLD_API_LIB INTERFACE libGNA::KERNEL)
set_target_properties(libGNA::OLD_API_LIB PROPERTIES IMPORTED_NO_SONAME TRUE)
set_target_properties(libGNA::KERNEL PROPERTIES IMPORTED_NO_SONAME TRUE)
endif()

add_library(libGNA::API INTERFACE IMPORTED)
set_property(TARGET libGNA::API PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${GNA}/include")
set_property(TARGET libGNA::API PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${libGNA_INCLUDE_DIRS})

add_library(libGNA INTERFACE IMPORTED)
foreach(_lib_name ${GNA_LIBS_LIST})
Expand All @@ -45,6 +75,6 @@ endforeach(_lib_name)
if (WIN32)
set_target_properties(libGNA::KERNEL PROPERTIES
IMPORTED_IMPLIB ${GNA_KERNEL_LIBRARY})
else()
elseif(NOT GNA_LIBRARY_VERSION STREQUAL "GNA1")
set_target_properties(libGNA PROPERTIES INTERFACE_LINK_OPTIONS "-Wl,-rpath-link,${libGNA_LIBRARIES_BASE_PATH}")
endif ()
5 changes: 5 additions & 0 deletions inference-engine/cmake/check_features_ie.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ endif()

if (ENABLE_GNA)
add_definitions(-DENABLE_GNA)

if (UNIX AND NOT APPLE AND CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.4)
message(WARNING "${GNA_LIBRARY_VERSION} is not supported on GCC version ${CMAKE_CXX_COMPILER_VERSION}. Fallback to GNA1")
set(GNA_LIBRARY_VERSION GNA1)
endif()
endif()

if (ENABLE_SPEECH_DEMO)
Expand Down
24 changes: 15 additions & 9 deletions inference-engine/cmake/dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -274,16 +274,22 @@ if (ENABLE_GNA)
GNA_LIB_DIR
libGNA_INCLUDE_DIRS
libGNA_LIBRARIES_BASE_PATH)
if(GNA_LIBRARY_VERSION STREQUAL "GNA1_1401")
set(GNA_VERSION "01.00.00.1401")
endif()
if(GNA_LIBRARY_VERSION STREQUAL "GNA2")
set(GNA_VERSION "02.00.00.1047")
if (GNA_LIBRARY_VERSION STREQUAL "GNA1")
RESOLVE_DEPENDENCY(GNA
ARCHIVE_UNIFIED "GNA/gna_20181120.zip"
TARGET_PATH "${TEMP}/gna")
else()
if(GNA_LIBRARY_VERSION STREQUAL "GNA1_1401")
set(GNA_VERSION "01.00.00.1401")
endif()
if(GNA_LIBRARY_VERSION STREQUAL "GNA2")
set(GNA_VERSION "02.00.00.1047")
endif()
RESOLVE_DEPENDENCY(GNA
ARCHIVE_UNIFIED "GNA/GNA_${GNA_VERSION}.zip"
TARGET_PATH "${TEMP}/gna_${GNA_VERSION}"
VERSION_REGEX ".*_([0-9]+.[0-9]+.[0-9]+.[0-9]+).*")
endif()
RESOLVE_DEPENDENCY(GNA
ARCHIVE_UNIFIED "GNA/GNA_${GNA_VERSION}.zip"
TARGET_PATH "${TEMP}/gna_${GNA_VERSION}"
VERSION_REGEX ".*_([0-9]+.[0-9]+.[0-9]+.[0-9]+).*")
update_deps_cache(GNA "${GNA}" "Path to GNA root folder")
debug_message(STATUS "gna=" ${GNA})
endif()
Expand Down
13 changes: 9 additions & 4 deletions inference-engine/cmake/features_ie.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,18 @@ if (NOT THREADING STREQUAL "TBB" AND
endif()

if (ENABLE_GNA)
set (DEFAULT_GNA_LIB GNA2)
if (UNIX AND NOT APPLE AND CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.4)
set (DEFAULT_GNA_LIB GNA1)
else()
set (DEFAULT_GNA_LIB GNA2)
endif()
set(GNA_LIBRARY_VERSION "${DEFAULT_GNA_LIB}" CACHE STRING "GNAVersion")
set_property(CACHE GNA_LIBRARY_VERSION PROPERTY STRINGS "GNA1_1401" "GNA2")
set_property(CACHE GNA_LIBRARY_VERSION PROPERTY STRINGS "GNA1" "GNA1_1401" "GNA2")
list (APPEND IE_OPTIONS GNA_LIBRARY_VERSION)
if (NOT GNA_LIBRARY_VERSION STREQUAL "GNA1_1401" AND
if (NOT GNA_LIBRARY_VERSION STREQUAL "GNA1" AND
NOT GNA_LIBRARY_VERSION STREQUAL "GNA1_1401" AND
NOT GNA_LIBRARY_VERSION STREQUAL "GNA2")
message(FATAL_ERROR "GNA_LIBRARY_VERSION should be set to GNA1_1401 or GNA2. Default option is ${DEFAULT_GNA_LIB}")
message(FATAL_ERROR "GNA_LIBRARY_VERSION should be set to GNA1, GNA1_1401 or GNA2. Default option is ${DEFAULT_GNA_LIB}")
endif()
endif()

Expand Down

0 comments on commit 6d7f2f0

Please sign in to comment.