Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMake add subdirectory call fails #802

Closed
cartoonist opened this issue Sep 3, 2020 · 8 comments
Closed

CMake add subdirectory call fails #802

cartoonist opened this issue Sep 3, 2020 · 8 comments

Comments

@cartoonist
Copy link

cartoonist commented Sep 3, 2020

I followed the provided CMake example (in-tree) to include kokkos-kernel into my project but it fails:

-- The CXX compiler identification is GNU 8.3.0
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Protobuf: /usr/lib/x86_64-linux-gnu/libprotobuf.so;-lpthread (found version "3.6.1")
-- Using bundled Kokkos library
-- Setting default Kokkos CXX standard to 11
-- Setting policy CMP0074 to use <Package>_ROOT variables
-- The project name is: Kokkos
-- Using -std=gnu++11 for C++11 extensions as feature
-- Execution Spaces:
--     Device Parallel: NONE
--     Host Parallel: OPENMP
--       Host Serial: NONE
--
-- Architectures:
-- Found TPLLIBDL: /usr/lib/x86_64-linux-gnu/libdl.so
-- Using bundled kokkos-kernels library
-- Setting policy CMP0074 to use <Package>_ROOT variables
-- The project name is: KokkosKernels
CMake Error at ext/kokkos-kernels/CMakeLists.txt:87 (FIND_PACKAGE):
  By not providing "FindKokkos.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "Kokkos", but
  CMake did not find one.

  Could not find a package configuration file provided by "Kokkos" with any
  of the following names:

    KokkosConfig.cmake
    kokkos-config.cmake

  Add the installation prefix of "Kokkos" to CMAKE_PREFIX_PATH or set
  "Kokkos_DIR" to a directory containing one of the above files.  If "Kokkos"
  provides a separate development package or SDK, be sure it has been
  installed.


-- Configuring incomplete, errors occurred!

As it can be seen above, adding Kokkos subdirectory works fine. However, adding kokkos-kernel subdirectory hits this line (CMakeLists.txt:87):

find_package(Kokkos REQUIRED)

Which makes sense since there is no config file installed (Kokkos is added by a add_subdirectory call).

I installed Kokkos library to see if installing fixes the issue. But it failed again because of uknown KOKKOS_CHECK command:

-- Found Kokkos at /usr/lib/x86_64-linux-gnu/cmake/Kokkos
CMake Error at ext/kokkos-kernels/CMakeLists.txt:89 (KOKKOS_CHECK):
  Unknown CMake command "KOKKOS_CHECK".

My CMake file looks like this:

find_package(Kokkos QUIET)
find_package(KokkosKernels QUIET)

# If Kokkos not installed
if(NOT TARGET Kokkos::kokkos)
  message(STATUS "Using bundled Kokkos library")
  set(Kokkos_SOURCE_DIR ${PROJECT_SOURCE_DIR}/ext/kokkos)
  execute_process(
    COMMAND git submodule update --init --recursive -- ${Kokkos_SOURCE_DIR}
    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
  add_subdirectory(${Kokkos_SOURCE_DIR})
endif()

# If KokkosKernels not installed
if(NOT TARGET Kokkos::kokkoskernels)
  message(STATUS "Using bundled kokkos-kernels library")
  set(KokkosKernels_SOURCE_DIR ${PROJECT_SOURCE_DIR}/ext/kokkos-kernels)
  execute_process(
    COMMAND git submodule update --init --recursive -- ${KokkosKernels_SOURCE_DIR}
    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
  set(KokkosKernels_INSTALL_TESTING OFF)
  add_subdirectory(${KokkosKernels_SOURCE_DIR})
endif()

add_subdirectory(my_program)

and I am using CMake 3.13.4 and working with develop branch.

@e10harvey
Copy link
Contributor

@cartoonist, what version of kokkos is being used? What is the HEAD SHA of kokkos-kernels:develop?

@cartoonist
Copy link
Author

@e10harvey I tested on kokkos/kokkos@53adf133 and kokkos-kernels b95d6783.

@e10harvey
Copy link
Contributor

@cartoonist: Thanks, can you confirm that /usr/lib/x86_64-linux-gnu/cmake/Kokkos/KokkosConfigCommon.cmake contains function(kokkos_check)?

@cartoonist
Copy link
Author

cartoonist commented Sep 6, 2020

Thanks @e10harvey,

I presumed that Debian package libtrilinos-kokkos-dev installs Kokkos on the system. Apparently, this package does not install file /usr/lib/x86_64-linux-gnu/cmake/Kokkos/KokkosConfigCommon.cmake at all. I also got a little bit confused since the package versioning differs from the release tags here.

So, I removed the package and installed Kokkos from the source. Then, add_subdirectory(/path/to/kokkos-kernels) works fine. But, I still cannot include Kokkos and KokkosKernels in tree together without installing Kokkos. I get the error I described in the first message.

@e10harvey
Copy link
Contributor

But, I still cannot include Kokkos and KokkosKernels in tree together without installing Kokkos. I get the error I described in the first message.

@cartoonist, Please try running make install in your kokkos build directory and then setting either Kokkos_DIR or CMAKE_PREFIX_PATH to /path/to/kokkos/install when configuring kokkos-kernels.

@cartoonist
Copy link
Author

Sorry, I might be a bit unclear in my first message. I have a program which uses Kokkos and kokkos-kernels and my main goal is to include both Kokkos and kokkos-kernels without requiring to install them; i.e. include them both in my source tree as git submodules and call add_subdirectory in my CMakeLists.txt file as it was explained in your example.

Adding kokkos-kernels subdirectory only works when Kokkos is already installed on the system since apparently kokkos-kernels' CMakeLists.txt calls find_package(Kokkos REQUIRED) here. When Kokkos is not installed, adding kokkos-kernels by add_subdirectory fails as I mentioned in my first message:

-- The CXX compiler identification is GNU 8.3.0
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Protobuf: /usr/lib/x86_64-linux-gnu/libprotobuf.so;-lpthread (found version "3.6.1")
-- Using bundled Kokkos library
-- Setting default Kokkos CXX standard to 11
-- Setting policy CMP0074 to use <Package>_ROOT variables
-- The project name is: Kokkos
-- Using -std=gnu++11 for C++11 extensions as feature
-- Execution Spaces:
--     Device Parallel: NONE
--     Host Parallel: OPENMP
--       Host Serial: NONE
--
-- Architectures:
-- Found TPLLIBDL: /usr/lib/x86_64-linux-gnu/libdl.so
-- Using bundled kokkos-kernels library
-- Setting policy CMP0074 to use <Package>_ROOT variables
-- The project name is: KokkosKernels
CMake Error at ext/kokkos-kernels/CMakeLists.txt:87 (FIND_PACKAGE):
  By not providing "FindKokkos.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "Kokkos", but
  CMake did not find one.

  Could not find a package configuration file provided by "Kokkos" with any
  of the following names:

    KokkosConfig.cmake
    kokkos-config.cmake

  Add the installation prefix of "Kokkos" to CMAKE_PREFIX_PATH or set
  "Kokkos_DIR" to a directory containing one of the above files.  If "Kokkos"
  provides a separate development package or SDK, be sure it has been
  installed.


-- Configuring incomplete, errors occurred!

@e10harvey
Copy link
Contributor

e10harvey commented Sep 14, 2020

@cartoonist, Please try again once #811 is merged.

@cartoonist
Copy link
Author

#811 fixed the issue. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants