Here's an example. It first checks if CMAKE_C_BYTE_ORDER is defined, which is 
available in recent versions of cmake. If it isn't, cmake's own macro 
TestBigEndian is invoked (deprecated, but still available). It would normally 
compile an executable, but we change the compile target to a static library 
(the test for endianness works anyway).

if(DEFINED CMAKE_C_BYTE_ORDER)
  if(CMAKE_C_BYTE_ORDER STREQUAL "BIG_ENDIAN")
    set(WORDS_BIGENDIAN 1)
  else()
    set(WORDS_BIGENDIAN 0)
  endif()
else()
  # From cmake docs: If CMAKE_OSX_ARCHITECTURES specifies multiple 
architectures, the value
  # of CMAKE_<LANG>_BYTE_ORDER is non-empty only if all architectures share the 
same byte
  # order.
  include(TestBigEndian)
  SET(CMAKE_TRY_COMPILE_TARGET_TYPE_SAVE ${CMAKE_TRY_COMPILE_TARGET_TYPE})
  SET(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
  TEST_BIG_ENDIAN(WORDS_BIGENDIAN)
  SET(CMAKE_TRY_COMPILE_TARGET_TYPE ${CMAKE_TRY_COMPILE_TARGET_TYPE_SAVE})
endif()



> Gesendet: Mittwoch, 17. Januar 2024 um 16:52 Uhr
> Von: "Uwe Ligges" <lig...@statistik.tu-dortmund.de>
> An: "Matthias Gondan" <matthias-gon...@gmx.de>, "Sameh Abdulah" 
> <sameh.abdu...@kaust.edu.sa>
> Cc: "R Package Development" <r-package-devel@r-project.org>
> Betreff: Re: [R-pkg-devel] CMake on CRAN Systems
>
>
>
> On 17.01.2024 08:59, Matthias Gondan wrote:
> > For package rswipl, cmake still seems to work, but
> >
> > * one has to search for it on MacOS, see the src/Makevars, as well as the 
> > relevant sections in Writing R extensions
> > * Windows Defender (also on CRAN) complains about dubious exe-files when 
> > checking the "endianness" of the target system. That can be circumvented by 
> > telling cmake to compile static libraries instead of executables.
>
> Indeed, currently Windows Defender gives false positives for some
> temprary .exe files that CMake creates. As thge filenames and locations
> are random, there is no straightforward way to tell the defender about
> exceptions. Hence please follow the advice and  tell cmake to compile
> static libraries instead of executables (an excellent idea, thanks!).
> [Microsoft knows about this for several weeks now without action.]
>
> Best,
> Uwe Ligges
>
>
>
> >
> > I am unsure if my response is specific to your problem, but the links below 
> > do not seem to work.
> >
> >> Gesendet: Mittwoch, den 17.01.2024 um 08:37 Uhr
> >> Von: "Sameh Abdulah" <sameh.abdu...@kaust.edu.sa>
> >> An: "R Package Development" <r-package-devel@r-project.org>
> >> Betreff: [R-pkg-devel] CMake on CRAN Systems
> >>
> >> Hi All,
> >>
> >> We recently encountered an installation issue with our package on CRAN. 
> >> We've been depending on CMake, assuming it is readily available by 
> >> default, but it appears to be only available on the M1mac system but not 
> >> on the others. Should we include the CMake installation within our package?
> >>
> >> We encountered another issue with OpenMP, but we managed to resolve it by 
> >> consulting the manual.
> >>
> >> https://urldefense.com/v3/__https://cran-archive.r-project.org/web/checks/2024/2024-01-12_check_results_MPCR.html__;!!Nmw4Hv0!1cg5mCeLOB9fBslqbEGB1S0_MEcOLMjk6m4hpfWDyXErAlWtm82xz9ZUU3aQ3q6jkXZBM2tNhUp3EI3JmigE4EvCLlrC$<https://urldefense.com/v3/__https:/cran-archive.r-project.org/web/checks/2024/2024-01-12_check_results_MPCR.html__;!!Nmw4Hv0!1cg5mCeLOB9fBslqbEGB1S0_MEcOLMjk6m4hpfWDyXErAlWtm82xz9ZUU3aQ3q6jkXZBM2tNhUp3EI3JmigE4EvCLlrC$>
> >>
> >>
> >>
> >> Best,
> >> --Sameh
> >>
> >> --
> >>
> >> This message and its contents, including attachments are intended solely
> >> for the original recipient. If you are not the intended recipient or have
> >> received this message in error, please notify me immediately and delete
> >> this message from your computer system. Any unauthorized use or
> >> distribution is prohibited. Please consider the environment before printing
> >> this email.
> >>
> >>    [[alternative HTML version deleted]]
> >>
> >> ______________________________________________
> >> R-package-devel@r-project.org mailing list
> >> https://stat.ethz.ch/mailman/listinfo/r-package-devel
> >
> > ______________________________________________
> > R-package-devel@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-package-devel
>

______________________________________________
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel

Reply via email to