Kokkos: Trouble with new pure CMake build

Created on 7 Jun 2017  Â·  5Comments  Â·  Source: kokkos/kokkos

I am trying to use the new pure CMake build where Kokkos is a subproject of another application. I tried following the steps in the example in kokkos/example/cmake_build/CMakeLists.txt, and am running into a build error:

mkdir ~/tmp
cd ~/tmp
cmake -D CMAKE_CXX_COMPILER=g++-4.9 ~/project/tensors/genten/genten-kokkos-sandia/kokkos/example/cmake_build
...
make
...
/home/etphipp/project/tensors/genten/genten-kokkos-sandia/kokkos/example/cmake_build/cmake_example.cpp:44:27: fatal error: Kokkos_Core.hpp: No such file or directory
 #include <Kokkos_Core.hpp>

I think the issue is Kokkos_INCLUDE_DIRS in kokkos/cmake/kokkos.cmake needs to be set in PARENT_SCOPE, and

include_directories(${Kokkos_INCLUDE_DIRS})

needs to be added to kokkos/example/cmake_build/CMakeLists.txt.

Without this, I don't see how you can build the example.

InDevelop bug - experimental feature question

All 5 comments

@bjoo @dholladay00 @bartgol

Actually I guess what you need to do is add something like

SET(Kokkos_INCLUDE_DIRS_RET ${Kokkos_INCLUDE_DIRS} PARENT_SCOPE)

to kokkos.cmake and

include_directories(${Kokkos_INCLUDE_DIRS_RET})

to cmake_build/CMakeLists.txt

Additionally, it seems that TPL include paths aren't being set properly. If I enable, e.g., hwloc:

cmake -D CMAKE_CXX_COMPILER=g++-4.9 -D KOKKOS_HOST_ARCH=SNB -D KOKKOS_ENABLE_HWLOC=ON -D KOKKOS_HWLOC_DIR=/usr/local/software/hwloc/current ~/project/tensors/genten/genten-kokkos-sandia/kokkos/example/cmake_build

I get the build error:

/home/etphipp/project/tensors/genten/genten-kokkos-sandia/kokkos/core/src/impl/Kokkos_hwloc.cpp:220:19: fatal error: hwloc.h: No such file or directory
 #include <hwloc.h>
                   ^
compilation terminated.

If I append ${KOKKOS_INCLUDE_DIRS} (which appears to store the TPL includes) to Kokkos_INCLUDE_DIRS in kokkos.cmake:

# set up include-directories
SET (Kokkos_INCLUDE_DIRS
    ${Kokkos_SOURCE_DIR}/core/src
    ${Kokkos_SOURCE_DIR}/containers/src
    ${Kokkos_SOURCE_DIR}/algorithms/src
    ${Kokkos_BINARY_DIR}  # to find KokkosCore_config.h
    ${KOKKOS_INCLUDE_DIRS}
)

it appears to work.

As I said in the other issue, there are relatively few people using standalone cmake and I would not be surprised if there were issues.

If you see a way to improve and/or make it more correct or cmake-y, PRs are welcome.

I would ask that the example in example/cmake_build be updated so that it always "just works". Not all changes to cmake would require changes to the example, but if they do …

OK, I submitted a pull-request for the changes described above, including updates to example/cmake_build. Without these changes, I don't see how the example ever compiled.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vbrunini picture vbrunini  Â·  3Comments

nmhamster picture nmhamster  Â·  4Comments

Char-Aznable picture Char-Aznable  Â·  3Comments

csiefer2 picture csiefer2  Â·  3Comments

crtrott picture crtrott  Â·  3Comments