CMake file properties per-target

核能气质少年 提交于 2020-01-30 05:44:10

问题


I previously asked: How to compile C++ as CUDA using CMake which was super helpful. But then realised I had a follow-on question.

What I want to do is compile one file twice, using different compilers. eg:

cmake_minimum_required(VERSION 3.9)
project(cuda_test LANGUAGES CUDA CXX)

add_executable(cuda_test_host test.cpp)     # build with GCC for host

set_source_files_properties(test.cpp PROPERTIES LANGUAGE CUDA)
add_executable(cuda_test_cuda test.cpp)     # build with NVCC for CUDA

But of course, the set_source_files_properties is not specific to a particular target, so both cuda_test_host and cuda_test_cuda end up being built by NVCC.

I've seen similar questions on StackOverflow suggesting making sub-directories with different CMake files in, but I'd like to avoid that if at all possible.

来源:https://stackoverflow.com/questions/58862280/cmake-file-properties-per-target

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!