<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
        {mso-style-priority:34;
        margin-top:0cm;
        margin-right:0cm;
        margin-bottom:0cm;
        margin-left:36.0pt;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.WordSection1
        {page:WordSection1;}
/* List Definitions */
@list l0
        {mso-list-id:1275480891;
        mso-list-type:hybrid;
        mso-list-template-ids:-1641484826 -1 68026371 68026373 68026369 68026371 68026373 68026369 68026371 68026373;}
@list l0:level1
        {mso-level-start-at:0;
        mso-level-number-format:bullet;
        mso-level-text:-;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:"Calibri",sans-serif;
        mso-fareast-font-family:"Times New Roman";}
@list l0:level2
        {mso-level-number-format:bullet;
        mso-level-text:o;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:"Courier New";}
@list l0:level3
        {mso-level-number-format:bullet;
        mso-level-text:\F0A7;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:Wingdings;}
@list l0:level4
        {mso-level-number-format:bullet;
        mso-level-text:\F0B7;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:Symbol;}
@list l0:level5
        {mso-level-number-format:bullet;
        mso-level-text:o;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:"Courier New";}
@list l0:level6
        {mso-level-number-format:bullet;
        mso-level-text:\F0A7;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:Wingdings;}
@list l0:level7
        {mso-level-number-format:bullet;
        mso-level-text:\F0B7;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:Symbol;}
@list l0:level8
        {mso-level-number-format:bullet;
        mso-level-text:o;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:"Courier New";}
@list l0:level9
        {mso-level-number-format:bullet;
        mso-level-text:\F0A7;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:Wingdings;}
ol
        {margin-bottom:0cm;}
ul
        {margin-bottom:0cm;}
--></style></head><body lang=HU link="#0563C1" vlink="#954F72"><div class=WordSection1><p class=MsoNormal>Hi!</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>I am trying to improve the developer experience of <a href="https://www.khronos.org/sycl">SYCL</a> users for both those using <a href="https://github.com/triSYCL/triSYCL">triSYCL</a> and <a href="https://www.codeplay.com/products/computesuite/computecpp">ComputeCpp</a> alike. <i>(TL;DR: SYCL is CUDA of OpenCL, triSYCL being a non-conforming playground implementation built atop OpenMP, while ComputeCpp is the first (and only) conforming GPU-accelerated implementation.) </i>Although they are two wildly different implementations, it would come in handy to mix the two, having Debug builds rely on triSYCL (for the usual breakpoint-style debugging inside kernels) and Release builds using ComputeCpp, as well as generally allowing any implementation to be detected and used (much like find_package(MPI) can find MPI-CH, MS-MPI as well as OpenMPI).</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>My problem is that even if I have the nicest imported target set up in a FindModule.cmake script with components pointing to the various implementations (my initial take on the problem), there is no way for me to call the ComputeCpp compiler just by linking to an imported library target. This was the reason CUDA up until CMake 3.9 used add_cuda_executable() function and is the same reason why ComputeCpp uses the <a href="https://github.com/codeplaysoftware/computecpp-sdk/blob/master/cmake/Modules/FindComputeCpp.cmake#L303">add_sycl_to_target()</a> function.</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>If I would like to raise the bar to the level of CUDA in terms of UX, I’d need to patch CMake to being SYCL-aware. It would be much simpler however if imported targets had the ability to invoke user-defined scripts (defined in the FindModule.cmake script) that is invoked with the supplied parameters. Something like:</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><span style='font-family:Consolas'># FindLibrary.cmake<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:Consolas'>set(important „something important”)<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:Consolas'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-family:Consolas'>function(add_stuff_to_target TARGET target<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:Consolas'>                             IMPORTANT_VAR var)<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:Consolas'>  …<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:Consolas'>endfunction(add_stuff_to_target)<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:Consolas'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-family:Consolas'>add_library(Vendor::Library INTERFACE IMPORTED)<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:Consolas'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-family:Consolas'># NOTE: TARGET <name> is always added as a param to SCRIPT when linked to.<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:Consolas'># NOTE 2: SCRIPT is only valid for IMPORTED libraries.<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:Consolas'>set_target_properties(Vendor::Library PROPERTIES SCRIPT add_stuff_to_target<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:Consolas'>                                                 SCRIPT_PARAMS IMPORTANT_VAR ${important})<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:Consolas'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-family:Consolas'># CMakeLists.txt<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:Consolas'>find_package(Vendor REQUIRED COMPONENTS Library)<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:Consolas'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-family:Consolas'>add_executable(MyProg main.cpp)<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:Consolas'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-family:Consolas'>target_link_libraries(MyProg PRIVATE Vendor::Library)<o:p></o:p></span></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>This (or some similar way) libraries need not necessarily have to patch CMake in order to implement features such as:</p><ul style='margin-top:0cm' type=disc><li class=MsoListParagraph style='margin-left:0cm;mso-list:l0 level1 lfo1'>Qt MOC-ing files</li><li class=MsoListParagraph style='margin-left:0cm;mso-list:l0 level1 lfo1'>CUDA ptx compilation</li><li class=MsoListParagraph style='margin-left:0cm;mso-list:l0 level1 lfo1'>HLSL/GLSL compilation (this could be an object library that is linked to a CUSTOM_SCRIPT enhanced imported library</li><li class=MsoListParagraph style='margin-left:0cm;mso-list:l0 level1 lfo1'>XAML compiler invocation</li><li class=MsoListParagraph style='margin-left:0cm;mso-list:l0 level1 lfo1'>SYCL force include file generation</li><li class=MsoListParagraph style='margin-left:0cm;mso-list:l0 level1 lfo1'>I’m sure there are many more similar use cases</li></ul><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>The function would always receive the target name, from where just about everything can be queried, things originating from the FindModule.cmake script (counterparts to vars like CMAKE_AUTOMOC) could be passed in as well.</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>To sum it up: do you see value in lowering the bar to this level in adding significant facilities to CMake independently of CMake itself? This way, these facilities would be much more agile if updates to them need not wait for a new CMake version.</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Cheers,</p><p class=MsoNormal>Máté</p></div></body></html>