SFML community forums

Help => General => Topic started by: Nexus on July 06, 2012, 09:24:51 pm

Title: CMake variable name conventions
Post by: Nexus on July 06, 2012, 09:24:51 pm
Hi

I know that consistency is really a huge pain in CMake, one always has to know many special cases. SFML mainly uses the following variables:
I guess you didn't name it SFML_BUILD_SHARED_LIBS because BUILD_SHARED_LIBS seems to be common variable name (http://www.cmake.org/Wiki/CMake_Useful_Variables). But is this really important enough to injure the SFML_ prefix convention?

And doesn't the CMake community rather use XY_BUILD_DOCS instead of XY_BUILD_DOC?

By the way, the GLEW variables are not marked as advanced, although the other ones are (OpenGL, OpenAL, FreeType, jpeg, sndfile).
Title: Re: CMake variable name conventions
Post by: Laurent on July 06, 2012, 10:42:15 pm
Quote
BUILD_SHARED_LIBS
CMAKE_BUILD_TYPE
CMAKE_INSTALL_PREFIX
Although BUILD_SHARED_LIBS doesn't start with "CMAKE", it is much more than a standard convention: it is defined and used by CMake (it decides the type of libraries to build in add_library). I don't use it myself directly.
Regarding the two others, there's nothing I can do, they are also defined and used by CMake.

Quote
And doesn't the CMake community rather use XY_BUILD_DOCS instead of XY_BUILD_DOC?
I don't know (in french, a plural wouldn't make sense here). What's the best?

Quote
By the way, the GLEW variables are not marked as advanced, although the other ones are (OpenGL, OpenAL, FreeType, jpeg, sndfile).
I have no idea how to handle that in FindGLEW.cmake. I should probably read some doc :)
Title: Re: CMake variable name conventions
Post by: Celtic Minstrel on July 07, 2012, 04:54:19 am
It's kinda odd; in English, a plural doesn't really make sense there either, since it's a shortened form of "Build Documentation"; yet, somehow, pluralizing the shortened form ("Build Docs") seems to be a fairly common convention and, to me, doesn't sound odd.
Title: Re: CMake variable name conventions
Post by: Nexus on July 07, 2012, 08:33:46 am
Although BUILD_SHARED_LIBS doesn't start with "CMAKE", it is much more than a standard convention: it is defined and used by CMake (it decides the type of libraries to build in add_library).
The only thing you could do is to have a SFML_BUILD_SHARED_LIBS in the cache, and then a local variable BUILD_SHARED_LIBS which is assigned to the other. But I don't think it's worth doing that just for the variable name.

I still wonder why the CMakers couldn't just let it begin with CMAKE_ ::)


What's the best?
No idea. I'm fine with SFML_BUILD_DOC, but I don't know what the big part of the libraries used.


I have no idea how to handle that in FindGLEW.cmake.
Can't you call mark_as_advanced() outside FindGLEW?


And another question: Wouldn't it be better to rename the text files (e.g. "license-sfml.txt" or "readme-sfml.txt") or to move them into some folder? Because I have Windows and a directory C:/C++Libs for all C++ libraries, which contains include, bin, lib folders, so the txt files are just in the top level directory and multiple libraries might overwrite each other's files.

What's the best practice to handle this on Windows? I use one common folder to avoid the specification of include and lib directories for each new library.
Title: Re: CMake variable name conventions
Post by: Laurent on July 07, 2012, 09:04:56 am
Quote
The only thing you could do is to have a SFML_BUILD_SHARED_LIBS in the cache, and then a local variable BUILD_SHARED_LIBS which is assigned to the other. But I don't think it's worth doing that just for the variable name.
Indeed. And people are used to BUILD_SHARED_LIBS, it wouldn't help to hide it behind a new variable.

Quote
It's kinda odd; in English, a plural doesn't really make sense there either, since it's a shortened form of "Build Documentation"; yet, somehow, pluralizing the shortened form ("Build Docs") seems to be a fairly common convention and, to me, doesn't sound odd.
Weird ???

Quote
Can't you call mark_as_advanced() outside FindGLEW?
I could even do it inside, I just have to see how it works :)

Quote
And another question: Wouldn't it be better to rename the text files (e.g. "license-sfml.txt" or "readme-sfml.txt") or to move them into some folder?
I don't think so. Everything under the SFML install dir is supposed to be related to SFML, it wouldn't make sense to rename everything that might be "too common" with a "sfml" prefix.

Quote
What's the best practice to handle this on Windows? I use one common folder to avoid the specification of include and lib directories for each new library.
I personally put each library in its own folder. When I create a project, I add the include/lib path of each library that it uses. It avoids conflicts when using several versions of a library and/or several compilers; for example at work I have Qt 4.7 vc2008, Qt 4.7 vc2010, Qt 4.7 gcc4, Qt 4.8 vc2008, etc. It would be a big mess if all the .lib/.a/.dll files were in the same directory :)
Title: Re: CMake variable name conventions
Post by: Nexus on July 07, 2012, 11:45:55 am
I could even do it inside, I just have to see how it works :)
Okay, I thought you didn't want to change the original file.

It avoids conflicts when using several versions of a library and/or several compilers
That's a good point, even though I don't really use multiple versions at the moment.