CUDA: CXX flags are not propagated to host compiler
Hi,
I try to build a CUDA+MPI project using CMakes first-level support for CUDA and not the findCuda module. The problem is that I cannot set host flags. Actually, I expected the CXX_Flags to be propagated to the host compiler, which does not seem to be the case.
CMakeLists.txt:
cmake_minimum_required(VERSION 3.10)
project(helloworld VERSION 1.0.0 LANGUAGES CXX CUDA)
SET( CMAKE_CXX_FLAGS_DEV "-O0 -g -march=native -Wall -Wextra -Wpedantic -DMPICH_IGNORE_CXX_SEEK -std=c++14")
SET( CMAKE_CUDA_FLAGS_DEV "-O0 -g -G -m64")
find_package(MPI REQUIRED COMPONENTS CXX)
# workaround -pthread bug
string(REPLACE "-pthread" "-Xcompiler;-pthread" MPI_CUDA_COMPILE_OPTIONS ${MPI_CXX_COMPILE_OPTIONS})
add_executable(hello ${PROJECT_SOURCE_DIR}/src/HelloWorld.cu)
target_compile_features(hello PRIVATE cxx_std_14)
target_include_directories(hello PRIVATE ${PROJECT_SOURCE_DIR}/include ${MPI_CXX_INCLUDE_DIRS} ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES})
target_compile_options(hello PRIVATE ${MPI_CUDA_COMPILE_OPTIONS})
target_compile_definitions(hello PRIVATE ${MPI_CXX_COMPILE_DEFINITIONS})
target_link_libraries(hello PRIVATE ${MPI_CXX_LINK_FLAGS} ${MPI_CXX_LIBRARIES})
And I run CMake like this:
cmake -G "Unix Makefiles" -D CMAKE_BUILD_TYPE=Dev ../path/to/source
My questions:
- Is this the expected behavior? (for the findCUDA module: CUDA_PROPAGATE_HOST_FLAGS (Default ON))
- Do I have to manually construct the -xCompiler "..." flag or is there a better way?
Thank you!
Edited by Fabian Wrede