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

g++ -std option doubly set for cmake project #1548

Closed
Char-Aznable opened this issue Apr 9, 2018 · 3 comments
Closed

g++ -std option doubly set for cmake project #1548

Char-Aznable opened this issue Apr 9, 2018 · 3 comments
Assignees
Labels
Bug Broken / incorrect code; it could be Kokkos' responsibility, or others’ (e.g., Trilinos)
Milestone

Comments

@Char-Aznable
Copy link
Contributor

Hi,

Say I have a cmake project that require using c++14 with the following CMakeLists.txt (following the cmake_build example):

cmake_minimum_required(VERSION 3.1)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

project(Testview CXX)

add_subdirectory(${Testview_SOURCE_DIR}/../kokkos ${Testview_BINARY_DIR}/kokkos)

include_directories(${Kokkos_INCLUDE_DIRS_RET})

add_executable(testview testview.cpp)
target_link_libraries(testview kokkos)

and running

cmake . \
-DCMAKE_BUILD_TYPE=Release \
-DKOKKOS_ENABLE_OPENMP=ON
make -j VERBOSE=1

will show the CXX_FLAGS as: -O3 -DNDEBUG --std=c++11 -fopenmp -std=c++14. Even though I believe the later "-std=c++14" will overwrite the earlier one, it would be nice to only set the user-defined standard option instead of whatever Kokkos assumes unless I'm missing something here.

@ibaned ibaned added the Question For Kokkos internal and external contributors and users label Apr 10, 2018
@ibaned
Copy link
Contributor

ibaned commented Apr 10, 2018

I'm not sure yet whether or how we want to support usage of Kokkos from codes that use C++14 or C++17. Maybe we add some kind of KOKKOS_CXX_STANDARD, which derives from CMAKE_CXX_STANDARD if the latter is set...

@crtrott
Copy link
Member

crtrott commented Apr 10, 2018

Hi,

actually that does exist already. We just need to fix the CMake / Make interaction that the standard is correctly set. The reason for us to set the standard on the Make side instead of CMake is btw CUDA and the interaction with some CUDA flags.

There are flags for CUDA such as --expt-extended-lambda which require C++11 or higher to be set. The way cmake tested compiler flags though made it test those user provided flags without adding the C++ standard flag which then would fail configure. So we said in Trilinos land, that we need to add the standard thing explicitly to the CXX flags together with all the other ones. But this is clearly an issue here.

@crtrott crtrott added Bug Broken / incorrect code; it could be Kokkos' responsibility, or others’ (e.g., Trilinos) and removed Question For Kokkos internal and external contributors and users labels Apr 10, 2018
@ibaned
Copy link
Contributor

ibaned commented Apr 10, 2018

I put up a possible fix for this in #1549 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Broken / incorrect code; it could be Kokkos' responsibility, or others’ (e.g., Trilinos)
Projects
None yet
Development

No branches or pull requests

4 participants