I’m using OpenACC on a simple example. If I understand well the FindOpenACC machinery one should be able to pass to CMake the target architecture with the OpenACC_ACCEL_TARGET. I issue the following command
which seems not to work for me for a very simple reason. In the flags.cmake file for the ex7 target generated by cmake I find:
compile C with /mnt/data/pgi_compiler/linux86-64/19.10/bin/pgcc
C_FLAGS = “-acc -ta=tesla:cc60”
which results in this command that the pgi compiler cannot process because of the double quotes:
[ 50%] Building C object CMakeFiles/ex7.dir/example7.c.o
/mnt/data/pgi_compiler/linux86-64/19.10/bin/pgcc -DCOLS=3000 -DROWS=3000 "-acc -ta=tesla:cc60" -o CMakeFiles/ex7.dir/example7.c.o -c /home/edo/GitHub/acceleration/OpenACC/example7.c
pgcc-Error-Unknown switch: -acc -ta=tesla:cc60
One workaround that I found was to pass the same target information in the CMAKE_C_FLAGS, but that’s not right as the flag is passed to every target of a project.
I may be wrong but it seems to me that line 16 is incorrect and line 15 should be used instead. With line 16 you’re adding all the flags as one string and, since it contains spaces, CMake quotes them.
OpenACC compiler flags for <lang> , separated by spaces.
This means that you can’t pass OpenACC_C_FLAGS as-is to target_compile_options, unless it contains a single flag. You first need to replace spaces by semicolons (to convert it to a list).