[cmake-developers] CheckStructHasMember does not support C++ only structs

Daniele E. Domenichelli daniele.domenichelli at gmail.com
Tue Sep 24 17:28:30 EDT 2013


On 24/09/13 16:44, Brad King wrote:
> On 09/24/2013 09:46 AM, Daniele E. Domenichelli wrote:
>> I pushed a commit to the CheckStructHasMember_CXX topic, can you review
>> it?
> You can simplify the implementation using ${ARGN} to get the arguments
> beyond those explicitly named in the signature.

You mean something like this?

   if("${ARGN}" STREQUAL "")
      set(_lang C)
   elseif("${ARGN}" MATCHES "^LANGUAGE;([a-zA-Z]+)$")
      set(_lang "${CMAKE_MATCH_1}")
   else()
      message(FATAL_ERROR "Unknown arguments:\n  ${ARGN}\n")
   endif()

   [...]

   if("${_lang}" STREQUAL "C")
      [...]
   elseif("${_lang}" STREQUAL "CXX")
      [...]
   else()
      message(FATAL_ERROR "Unknown language:\n  ${_lang}\nSupported languages: C, CXX.\n")
   endif()



Is the "MATCHES" using a list as a string "safe"? Or is there another way to
simplify it?
Otherwise I can do the same using list(LENGTH) and list(GET) instead of ARGC
and ARGV4/5, but it looks more complicated.


Cheers,
 Daniele



More information about the cmake-developers mailing list