Alpaka: CMake Option: Alpaka CXX Standard

Created on 4 Mar 2019  路  6Comments  路  Source: alpaka-group/alpaka

I have a problem to compile a module in c++14 with ALPAKA.

I have an ALPAKA class that is compiled into a library, "AlpakaLibrary".

Now I would like to have my executable, "MAIN", compiled in c++14 and link AlpakaLibrary and another c++14 host-library, "c++14HostLibrary", to it. Something like this :

SET(_TARGET_NAME "MAIN")

ALPAKA_ADD_EXECUTABLE(
${_TARGET_NAME}
${_FILES_SOURCE})
TARGET_LINK_LIBRARIES(
${_TARGET_NAME}
PUBLIC "AlpakaLibrary" "c++14HostLibrary")

I have two questions:

1) When I replace ALPAKA_ADD_EXECUTABLE --> ADD_EXECUTABLE I have many ALPAKA compilation errors and I don't understand why. Should I use always ALPAKA_ADD_EXECUTABLE ?

2) I want to compile MAIN in c++14 but If I set the CMAKE flags manually, i.e.:

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14)

I have plenty of compilation errors for ALPAKA.

So what is that right way to link an ALPAKA library with a c++14 module?

Install

All 6 comments

Hi,

Should I use always ALPAKA_ADD_EXECUTABLE

yes, that's the current wrapper we deploy since CMake's CUDA language does not yet support clang -x cuda as a CUDA compiler: https://gitlab.kitware.com/cmake/cmake/issues/16586

For that reason, we manually add -std=c++11 instead of using a "C++11 or newer" target_compile_feature(s).

compile MAIN in c++14

We probably have to expose a CMake control variable to allow setting another C++ standard for the time being, which can be set from apps.

These are the locations you could change already to C++14:

Thanks a lot!

@ivandrodri allow me to keep this issue open so we implement a control var in CMake and document how to use it :)

Hi, sorry to open up an old issue, but setting the C++ version to 14 still doesn't work for me.

I tried setting the CMAKE_CXX_STANDARD variable and the ALPAKA_CXX_STANDARD, both before and after find_alpaka(), but make VERBOSE=1 still showed the -std=c++11 flag.

A current snapshot of the software can be found here.

I've just tried to reproduce with the latest alpaka develop on hemera. It does not have cmake 3.11.4 that alpaka now requires, changed the requirements to 3.11.3. Adding -DALPAKA_CXX_STANDARD=14 to the command line seems to work for me.

Thanks, this solved the issue for me. Additionally, it seemed that somehow my alpaka version was not updated correctly after a git pull, but I could fix this by removing and redownloading the repository.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

BenjaminW3 picture BenjaminW3  路  3Comments

ax3l picture ax3l  路  3Comments

BenjaminW3 picture BenjaminW3  路  5Comments

tdd11235813 picture tdd11235813  路  4Comments

kloppstock picture kloppstock  路  3Comments