Cmake coding style

129 views
Skip to first unread message

Alexander Sokolov

unread,
Jul 17, 2012, 1:06:15 PM7/17/12
to razo...@googlegroups.com
We have a crazy situation with the cmake files. All files have their own style of naming variables. Here is a variants of the variable names for .h files.
  • razor-appswitcher_HDRS
  • razor-policykit-agent_H
  • ${PROJECT_NAME} _HEADERS
  • H_FILES
  • HEADERS
  • razorqxt_PUBLIC_HDRS and razorqxt_PRIVATE_HDRS
  • QTXDG_PUBLIC_HDRS and QTXDG_PRIVATE_HDRS
  • HW_HEADERS

I suggest to choose one style and describe it in the wiki.

Do we need prefixes? Cmake documentation says: "Each new directory or function creates a new scope." Therefore, the two programs will be have independent variables, but I'm not sure about the nested directory, like:
razorqt-session
    CMakeLists.txt
    /config
        CMakeLists.txt

I like the style of H_FILES (or ${PROJECT_NAME} _H_FILES if prefix is needed)
This allows to have a single style for different files: TS_FILES, QM_FILES, MOC_FILES, QRC_FILES, and so on.

Any Ideas.

Kuzma Shapran

unread,
Jul 17, 2012, 9:40:42 PM7/17/12
to razo...@googlegroups.com
+1 to your suggestion.

So for a dynamic library it can be:

${PROJECT_NAME}_H_FILES
${PROJECT_NAME}_PRIVATE_H_FILES 
${PROJECT_NAME}_PUBLIC_H_FILES 

chri...@surlykke.dk

unread,
Jul 18, 2012, 3:52:46 AM7/18/12
to razo...@googlegroups.com


2012/7/17 Alexander Sokolov <sokol...@gmail.com>
I prefer no prefixes. TS_FILES, QM_FILES,.. as you suggest would be fine with me.

br. Chr. 

Александр Соколов

unread,
Jul 18, 2012, 4:50:09 AM7/18/12
to razo...@googlegroups.com
I made the test (diff in the attach). I added the variable with the same name to the razorqt-session/CMakeLists.txt and razorqt-session/config/CMakeLists.txt. Result:

-- @@@@@ VAR in the razorqt-session/config/CMakeLists.txt: razor-session;razor-sessioncfg                    
-- @@@@@ VAR in the razorqt-session/CMakeLists.txt:  razor-session 

As you can see in razorqt-session/config/CMakeLists.txt variable have cumulative value. This may create errors, which would be difficult to detect. So let's use ${PROJECT_NAME}_XXX_FILES

--
You received this message because you are subscribed to the Google
Groups "Razor-qt" group.
For more options, visit this group at
http://groups.google.com/group/razor-qt?hl=en



--
Best regards,
Alexander.
test.diff

PICCORO McKAY Lenz

unread,
Jul 18, 2012, 9:50:20 AM7/18/12
to razo...@googlegroups.com
On Wed, Jul 18, 2012 at 4:20 AM, Александр Соколов <sokol...@gmail.com> wrote:
As you can see in razorqt-session/config/CMakeLists.txt variable have cumulative value. This may create errors, which would be difficult to detect. So let's use ${PROJECT_NAME}_XXX_FILES
This are better, thant
On Tue, Jul 17, 2012 at 9:10 PM, Kuzma Shapran <leaf.o...@gmail.com> wrote:
So for a dynamic library it can be:
${PROJECT_NAME}_H_FILES
${PROJECT_NAME}_PRIVATE_H_FILES 
${PROJECT_NAME}_PUBLIC_H_FILES
I dont think so that's necesary.. and i think "PROJECT_NAME" must be "MODULE_NAME" due i think the main proyect are RAZORQT, or so MAIN_PROJECT and SUBPROJECT could also.. but directly PROJECT_NAME may be confusing

2012/7/18 chri...@surlykke.dk <chri...@surlykke.dk>

I prefer no prefixes. TS_FILES, QM_FILES,.. as you suggest would be fine with me.
+1 to u, better no prefixes

--
Lenz McKAY Gerardo (PICCORO)
http://qgqlochekone.blogspot.com
Cofundador de Venenux;  debian based multimedia alike free only zealots users (oh well, i try but..too many free guidelines buahhh)
http://shutendouji.net
creador de massenkoh linux; debian enhanchements for better up to date support on stable brand, including non-free soft.

Petr Vanek

unread,
Jul 18, 2012, 1:57:25 PM7/18/12
to razo...@googlegroups.com
prefixes are mandatory. That's what I said - variables are inherited ;)

Also (I think) it's much more readable to have FOO_HEADERS than ${PROJECT}_HEADERS.

That are my 2c...

Александр Соколов

unread,
Jul 18, 2012, 3:31:19 PM7/18/12
to razo...@googlegroups.com


2012/7/18 PICCORO McKAY Lenz <mckayg...@gmail.com>



On Wed, Jul 18, 2012 at 4:20 AM, Александр Соколов <sokol...@gmail.com> wrote:
As you can see in razorqt-session/config/CMakeLists.txt variable have cumulative value. This may create errors, which would be difficult to detect. So let's use ${PROJECT_NAME}_XXX_FILES
This are better, thant
On Tue, Jul 17, 2012 at 9:10 PM, Kuzma Shapran <leaf.o...@gmail.com> wrote:
So for a dynamic library it can be:
${PROJECT_NAME}_H_FILES
${PROJECT_NAME}_PRIVATE_H_FILES 
${PROJECT_NAME}_PUBLIC_H_FILES
I dont think so that's necesary.. and i think "PROJECT_NAME" must be "MODULE_NAME" due i think the main proyect are RAZORQT, or so MAIN_PROJECT and SUBPROJECT could also.. but directly PROJECT_NAME may be confusing
PROJECT_NAME is not normal variable, any cmake file should have the "project(razor-foo)" line. The PROJECT_NAME contains razor-foo in this case. IMHO we no need your own variable instead a standard, well known and the documented in the cmake docs.
 

2012/7/18 chri...@surlykke.dk <chri...@surlykke.dk>

I prefer no prefixes. TS_FILES, QM_FILES,.. as you suggest would be fine with me.
+1 to u, better no prefixes

--
Lenz McKAY Gerardo (PICCORO)
http://qgqlochekone.blogspot.com
Cofundador de Venenux;  debian based multimedia alike free only zealots users (oh well, i try but..too many free guidelines buahhh)
http://shutendouji.net
creador de massenkoh linux; debian enhanchements for better up to date support on stable brand, including non-free soft.

--
You received this message because you are subscribed to the Google
Groups "Razor-qt" group.
For more options, visit this group at
http://groups.google.com/group/razor-qt?hl=en



--
Best regards,
Alexander.

Александр Соколов

unread,
Jul 18, 2012, 3:39:51 PM7/18/12
to razo...@googlegroups.com


2012/7/18 Petr Vanek <pe...@scribus.info>

prefixes are mandatory. That's what I said - variables are inherited ;)
OK we use prefixes. And what about postfixes? 
 
Also (I think) it's much more readable to have FOO_HEADERS than ${PROJECT}_HEADERS.
I can't find now, but I already fixed copy-past errors - one part of the file contains foo_HDRS but another part contains bar_HDRS. With ${PROJECT_NAME}  we can use copy-past without  risk.



That are my 2c...


On Tuesday, July 17, 2012 7:06:15 PM UTC+2, Alexander Sokolov wrote:
We have a crazy situation with the cmake files. All files have their own style of naming variables. Here is a variants of the variable names for .h files.
  • razor-appswitcher_HDRS
  • razor-policykit-agent_H
  • ${PROJECT_NAME} _HEADERS
  • H_FILES
  • HEADERS
  • razorqxt_PUBLIC_HDRS and razorqxt_PRIVATE_HDRS
  • QTXDG_PUBLIC_HDRS and QTXDG_PRIVATE_HDRS
  • HW_HEADERS

I suggest to choose one style and describe it in the wiki.

Do we need prefixes? Cmake documentation says: "Each new directory or function creates a new scope." Therefore, the two programs will be have independent variables, but I'm not sure about the nested directory, like:
razorqt-session
    CMakeLists.txt
    /config
        CMakeLists.txt

I like the style of H_FILES (or ${PROJECT_NAME} _H_FILES if prefix is needed)
This allows to have a single style for different files: TS_FILES, QM_FILES, MOC_FILES, QRC_FILES, and so on.

Any Ideas.

--
You received this message because you are subscribed to the Google
Groups "Razor-qt" group.
For more options, visit this group at
http://groups.google.com/group/razor-qt?hl=en



--
Best regards,
Alexander.

PICCORO McKAY Lenz

unread,
Jul 18, 2012, 4:36:17 PM7/18/12
to razo...@googlegroups.com

umm ok more readable but relationshipt are less readable with razor modules.. 
On Wed, Jul 18, 2012 at 1:27 PM, Petr Vanek <pe...@scribus.info> wrote:
Also (I think) it's much more readable to have FOO_HEADERS than ${PROJECT}_HEADERS.

 
On Wed, Jul 18, 2012 at 3:01 PM, Александр Соколов <sokol...@gmail.com> wrote:

i revised cmake wiki documentation, damn PROJECT_NAME are mandatory for sub-compilation by modular policy, i was taking that razorqt are the PROYECT_NAME and modulesa subprojects, due does not cmake support subprojects! damn well ok
Reply all
Reply to author
Forward
0 new messages