[PROJ] 9.6.0 sharp embed compiler test on gcc7

Greg Troxel gdt at lexort.com
Sat May 3 05:48:44 PDT 2025


I updated proj to 9.6.0 and on NetBSD 10 with gcc 10 it seems fine.
The build fails on NetBSD 9 with gcc 7, I think due to gcc 7 not
supporting C23 (which is spelled --std=c2x in gcc10).

http://www.ki.nu/pkgsrc/reports/current/NetBSD-9.0/20250429.1321/proj-9.6.0/configure.log

The issue is not old cmake; I have 3.31.7 which is >> 3.21.


As I read CMakeLists.txt:

  function (is_sharp_embed_available res)
      if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.21 AND
          ((CMAKE_C_COMPILER_ID STREQUAL "GNU") OR (CMAKE_C_COMPILER_ID STREQUAL "Clang")))
          # CMAKE_C_STANDARD=23 only supported since CMake 3.21
          set(TEST_SHARP_EMBED
            "static const unsigned char embedded[] = {\n#embed __FILE__\n};\nint main() { (void)embedded; return 0;}"
          )
          set(CMAKE_C_STANDARD_BACKUP "${CMAKE_C_STANDARD}")
          set(CMAKE_C_STANDARD "23")
          check_c_source_compiles("${TEST_SHARP_EMBED}" _TEST_SHARP_EMBED)
          set(CMAKE_C_STANDARD "${CMAKE_C_STANDARD_BACKUP}")
          if (_TEST_SHARP_EMBED)
              set(${res} ON PARENT_SCOPE)
          else()
              set(${res} OFF PARENT_SCOPE)
          endif()
      else()
          set(${res} OFF PARENT_SCOPE)
      endif()
  endfunction()

I think the intent is to try to enable C23 and then try to build, and if
that succeeds, turn on sharp embedding.   But I think what's happening
is that cmake is erroring out trying to enable c23 instead of just
having the build fail.

I also don't understand how C23 is handled if sharp embedding is turned
on.  It would seem one has to end up passing --std for it, because a
compiler that can compile C23 does not necessarily default to it.

Does this work for others on compilers that don't support C23?


More information about the PROJ mailing list