1
# Try to find IntelIPP
# Once done, this will define
#
#  Ipp_FOUND - system has IntelIPP
#  Ipp_INCLUDE_DIR - the IntelIPP include directories
#  Ipp_LIBRARY - link these to use IntelIPP

include(LibFindMacros)

set(IPP_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../libs/intel/linux/intel_ipp)
# Include dir
find_path(Ipp_INCLUDE_DIR
  NAMES ipp.h
  PATHS ${IPP_ROOT_DIR}/include
)

find_library(Ipp_IRC_LIB
  NAMES irc
  PATHS ${IPP_ROOT_DIR}/lib/ia32
)


find_library(Ipp_MAT_LIB
  NAMES ippm
  PATHS ${IPP_ROOT_DIR}/lib/ia32
)

list(APPEND Ipp_LIBRARY ${Ipp_IRC_LIB} ${Ipp_MAT_LIB} )

include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set Ipp_FOUND to TRUE
# if all listed variables are TRUE
find_package_handle_standard_args(Ipp DEFAULT_MSG 
                                    Ipp_LIBRARY Ipp_INCLUDE_DIR)

# Set the include dir variables and the libraries and let libfind_process do the rest.
# NOTE: Singular variables for this library
set(Ipp_INCLUDE_DIRS ${Ipp_INCLUDE_DIR})
set(Ipp_LIBRARIES ${Ipp_LIBRARY})

My FindIpp.cmake script is shown above. On windows, I get -- Could NOT find IPP (missing: IPP_INCLUDE_DIR IPP_LIBRARY). I've tested this under Linux and it works without any issues. In both cases, I'm trying to cross-compile using the QNX Momentics toolchain.

  • The ${CMAKE_CURRENT_SOURCE_DIR} is the location of the 'root' script which does include(FindIpp).
  • I've looked at the output of ${CMAKE_CURRENT_SOURCE_DIR} and the output of the relative paths to make sure that the files and folders exist in the reported paths. ${CMAKE_CURRENT_SOURCE_DIR}/../libs/intel shows up as C:/../libs/intel.
  • I use CMake 3.5 on Linux and CMake 3.6.1 on Windows 7.
  • From a cmd prompt, I could type in 'cd c:/libs/intel' without any issues.
  • I tried hardcoding the IPP_ROOT_DIR path to set(IPP_ROOT_DIR C:/libs/intel/linux/intel_ipp), tried adding quotes around the path, appended CACHE PATH "Description" to the set call. None of these worked.
  • I tried -GNinja, -G "MinGW Makefiles" and -G "Unix Makefiles". Still came up with:

    -- Could NOT find IPP (missing:  IPP_INCLUDE_DIR IPP_LIBRARY) 
    -- Could NOT find Mkl (missing:  Mkl_LIBRARY Mkl_INCLUDE_DIR) 
    -- Could NOT find Boost (missing:  Boost_LIBRARY Boost_INCLUDE_DIR) 
    -- Could NOT find GTest (missing:  GTEST_LIBRARY GTEST_MAIN_LIBRARY) 
    
  • Copying and pasting contents from individual files like FindIpp.cmake into the main CMakeLists.txt file finds the libraries, but not the path to includes. Now I've also added list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SRC_DIR}/CMake/Modules) to find my module files. If I remove that line, cmake throws an error at include(FindIpp). Is there anything obvious that I'm doing wrong? Also, is this the way to write a find_library or find_path? Thanks

Sriram
  • 345
  • 2
  • 14
  • 1
    If you have a problem with `find_library` call, test this call **directly** with hardcoded values. No needs to debug whole `Find*.cmake` script in that case. As for crosscompiling, check which paths toolchain allows to search: host ones, target ones or both. See description of variable [CMAKE_FIND_ROOT_PATH_MODE_LIBRARY](https://cmake.org/cmake/help/v3.0/variable/CMAKE_FIND_ROOT_PATH_MODE_LIBRARY.html). – Tsyvarev Aug 02 '16 at 17:46
  • Tried calling this directly. No luck. Also, `set(IPP_ROOT_DIR "C:/libs/intel/linux/intel_ipp") message(STATUS "IPP_ROOT_DIR: " ${IPP_ROOT_DIR})` does not print IPP_ROOT_DIR anywhere in my output. – Sriram Aug 02 '16 at 21:34
  • So, what is about *toolchain*, which could possibly affect on `find_*` commands? Try to build project natively (e.g., with Visual Studio compiler, or with gcc under MinGW). If `find_path` works in such build, then your toolchain definitely affects on it. – Tsyvarev Aug 03 '16 at 17:57
  • Building natively using Visual Studio compiler and Ninja works fine. It is something to do with the toolchain. – Sriram Aug 03 '16 at 23:44

1 Answers1

3

So the correct way to cross-compile to QNX from Windows and Linux:

cmake -DCMAKE_SYSTEM_NAME="QNX" -DCMAKE_SYSTEM_VERSION="660" -DCMAKE_SYSTEM_PROCESSOR="x86" -GNinja path_to_project

Where 660 is QNX version 6.6.0. I was using my own Toolchain file for QNX. This is not necessary. There is one already provided under share/cmake-/Modules/Platform. So as long as we define the above CMAKE variable somewhere, you should be good to go.

Sriram
  • 345
  • 2
  • 14