[CMake] Some suggestions to TestForPosix module I wrote

Rolf Eike Beer eike at sf-mail.de
Thu Dec 15 03:23:24 EST 2011


> I wrote a TestForPosix module for looking if the system supports a POSIX /
> XPG / SUS standard and I wanted for you experts to look and criticize if
> you find anything wrong. I would also ask how can I make a request for it
> to be included in CMake 2.8.7, because it is (in my opinion) a very good
> contribution to the CMakeModules...
>
> Well, here is the download link (unix line feeds):
>
> http://ge.tt/8CVeNDB
>
> Only put it in the Modules folder of CMake if you want to test (otherwise
> you'll have to configure the path to the .in file...)

This looks like a good idea, however I found it to duplicate much code.

Here are some suggestions:

-make the thing a function, not a macro. You need to set the result
variable using set(... PARENT_SCOPE) then.

-use RETURN() in the else() to get out of the function when the user
requests a bad standard.

-I would use a SEND_ERROR in this case since the CMakeLists.txt is clearly
broken and needs to be fixed.

-now move the message() and configure_file() from each if() behind the
whole if() so it is shared by all valid standards.

Greetings,

Eike


More information about the CMake mailing list