sunCC on debian
Hello,
I am using oracle developer studio 12.6 beta on a debian testing x86_64 system. I added cc.defaults and CC.defaults files in $studio/lib/compilers/etc/config which contain -Wp,-I/usr/include/x86_64-linux-gnu, and the compiler seems to work on a few simple tests (in particular it can find headers in /usr/include/x86_64-linux-gnu when I compile without any specific flags, suncc -c test.c). cmake does identify the compiler as SunPro 5.15.0. However, cmake fails to search for headers in that directory (it searches in many places that do not exist like /usr/include/w32api, /usr/pkg/include, /opt/csw/include, /usr/openwin/include, etc).
I tested with a 1-line CMakeLists.txt: find_path(FOO gmp.h) and then, from different subdirectories, compared CC=gcc cmake .. and CC=suncc cmake .., and gmp.h was only found in the first case.
I tried using
list(APPEND CMAKE_SYSTEM_INCLUDE_PATH /usr/include/x86_64-linux-gnu)
list(APPEND CMAKE_SYSTEM_LIBRARY_PATH /usr/lib/x86_64-linux-gnu)
but that is not just used for searching files, cmake also passes corresponding -I and -L flags to the compiler, which breaks things (the order in which system paths are searched is very sensitive).
I believe that cmake should know that on debian, whatever the compiler, those 2 paths exist and contain important stuff... (the compiler is still relevant in that it determines the target, and thus which triplet to append to /usr/{include,lib})
An alternative would be to stop looking for files all over the place, trying to duplicate compiler logic, and rely on something like try_compile (like autoconf).