Re: [CMake] CMake+QT always failed for the first build, and succeeded for second build or later.

2016-06-01 Thread Konstantin Tokarev


01.06.2016, 14:09, "Jakob van Bethlehem" :
>> Hey, that was the LTS release until 1 or 2 month ago!
>
> Oops, you're right, my mistake. Somewhere in the back of my head was that the 
> 4-series was in the 4.12.x or so version, not sure where that came from.

KDE 4 I guess (it went up to 4.14)

> I haven't worked with Qt4 ever, but have become extremely experienced with 
> Qt5 from Qt 5.4 onwards. Nevertheless, I should've checked before mentioning 
> it :P.
>
> Sincerely,
> Jakob van Bethlehem
>
> On Wed, Jun 1, 2016 at 10:47 AM, Hendrik Sattler  
> wrote:
>> Am 1. Juni 2016 09:26:18 MESZ, schrieb Jakob van Bethlehem 
>> :
>>>That is what he said, but it seems to be a typo, because the
>>>CMakeLists.txt
>>>file clearly states 'set(QT_DIR
>>>${CMAKE_CURRENT_SOURCE_DIR}/ThirdParty/Qt/4.8.6)'
>>
>> Ok, I overlooked that one...
>>
>>>- still a stone-age version of Qt actually :(
>>
>> Hey, that was the LTS release until 1 or 2 month ago!
>> And they made Qt 5.6 an LTS release also to quieten people that complain 
>> about dropping modules without proper replacement (means feature parity) and 
>> dropping compiler support.
>> You will see users of Qt 5.6 for a loong time.
>>
>>>On Wed, Jun 1, 2016 at 9:09 AM, Hendrik Sattler
>>>
>>>wrote:
>>>


 Am 1. Juni 2016 09:02:41 MESZ, schrieb Jakob van Bethlehem <
 jsvanbethle...@gmail.com>:
 >Hej,
 >
 >Some things that come to mind:
 >* You're generating files *inside* the source tree - you're not
 >supposed to
 >do that
 >* Why do you want to have a special Qt_tmp directory? I don't see
>>>the
 >benefit, and without that requirement you can simply use the
 >qt4_wrap_cpp
 >macro explicitly and you still are not forced to use the automoc
 >feature
 >
 >And now for what is probably wrong in your CMakeLists.txt:
 >* It seems you made an important mistake regarding the behaviour of
 >'file(GLOB)'. That function will do the expansion *while running
 >CMake*.
 >But at that time the moc_* files *don't exist!* (as a matter of
>>>fact,
 >the
 >tmp directory doesn't even exist). In other words, your
>>>${Moc_SOURCES}
 >will
 >be empty, and hence they are not compiled, and hence you get
>>>precisely
 >the
 >linker errors you see (because these sources implement the functions
 >that
 >are listed as missing by the linker)
 >
 >If you would use the qt4_wrap_cpp() macro you don't run into this
 >problem,
 >so I'd strongly suggest using it.

 Except that he is using Qt3.

 >Sincerely,
 >Jakob van Bethlehem
 >
 >
 >
 >
 >On Tue, May 31, 2016 at 4:52 PM, irene w 
>>>wrote:
 >
 >> It seems CMakw could not find the generated moc_xxx files.  I
 >modified the
 >> scripts to specify moc_xxx files is generated, but it still has
>>>same
 >errors.
 >>
 >> ADD_CUSTOM_COMMAND ( OUTPUT ${Qt_tmp}/moc_GMWindow.cpp
 >>                      COMMAND ${QT_MOC_CMD} ${GM_DIR}/GMWindow.h -o
 >> ${Qt_tmp}/moc_GMWindow.cpp
 >>                      DEPENDS ${GM_DIR}/GMWindow.h
 >>                    )
 >> ADD_CUSTOM_TARGET(generate_foo DEPENDS ${Qt_tmp}/moc_GMWindow.cpp)
 >> SET_SOURCE_FILES_PROPERTIES(${Qt_tmp}/moc_GMWindow.cpp PROPERTIES
 >> GENERATED 1)
 >> SET_PROPERTY(SOURCE ${GM_DIR}/GMWindow.cpp APPEND PROPERTY
 >OBJECT_DEPENDS
 >> ${Qt_tmp}/moc_GMWindow.cpp)
 >>
 >> .
 >> add_dependencies (GM generate_foo)
 >>
 >>
 >> Does the Macro  "SET_SOURCE_FILES_PROPERTIES" with "GENERATED"
 >> setting work for this purposes?  Any help would be greatly
 >appreciated !
 >>
 >>
 >> On Wed, May 25, 2016 at 12:48 PM, irene w 
 >wrote:
 >>
 >>> Hi,
 >>>
 >>> I am compiling a simple Qt3 application on Linux using CMake. In
>>>my
 >case,
 >>> I need to build moc_xxx files with custom options and output to a
 >specified
 >>> directory, So, I was not using CAMKE_AUTO macros. My cmake
>>>scripts
 >create a
 >>> "Qt_tmp" directory and output moc_xxx there.
 >>>
 >>> It looked it always failed to link the moc_xxx files for the
>>>first
 >time
 >>> build when there is no "Qt_tmp" directory, and succeeded if I ran
 >build
 >>> again if the "Qt_tmp" directory and moc_xxx files created by the
 >failed
 >>> build were kept without removing.  However, it'll fail if I
>>>delete
 >>> the "Qt_tmp" directory.
 >>>
 >>> Even it failed at the first build, the moc_xxx files were
 >>> successfully created in the "Qt_tmp" directory.
 >>>
 >>> Here is my cmake scripts and the errors I got.  Can anyone help
>>>me
 >to
 >>> figure out the issues? Any help would be greatly appreciated.
 >Thanks.
 

Re: [CMake] CMake+QT always failed for the first build, and succeeded for second build or later.

2016-06-01 Thread Jakob van Bethlehem
> Hey, that was the LTS release until 1 or 2 month ago!

Oops, you're right, my mistake. Somewhere in the back of my head was that
the 4-series was in the 4.12.x or so version, not sure where that came
from. I haven't worked with Qt4 ever, but have become extremely experienced
with Qt5 from Qt 5.4 onwards. Nevertheless, I should've checked before
mentioning it :P.

Sincerely,
Jakob van Bethlehem

On Wed, Jun 1, 2016 at 10:47 AM, Hendrik Sattler 
wrote:

>
>
> Am 1. Juni 2016 09:26:18 MESZ, schrieb Jakob van Bethlehem <
> jsvanbethle...@gmail.com>:
> >That is what he said, but it seems to be a typo, because the
> >CMakeLists.txt
> >file clearly states 'set(QT_DIR
> >${CMAKE_CURRENT_SOURCE_DIR}/ThirdParty/Qt/4.8.6)'
>
> Ok, I overlooked that one...
>
> >- still a stone-age version of Qt actually :(
>
> Hey, that was the LTS release until 1 or 2 month ago!
> And they made Qt 5.6 an LTS release also to quieten people that complain
> about dropping modules without proper replacement (means feature parity)
> and dropping compiler support.
> You will see users of Qt 5.6 for a loong time.
>
> >On Wed, Jun 1, 2016 at 9:09 AM, Hendrik Sattler
> >
> >wrote:
> >
> >>
> >>
> >> Am 1. Juni 2016 09:02:41 MESZ, schrieb Jakob van Bethlehem <
> >> jsvanbethle...@gmail.com>:
> >> >Hej,
> >> >
> >> >Some things that come to mind:
> >> >* You're generating files *inside* the source tree - you're not
> >> >supposed to
> >> >do that
> >> >* Why do you want to have a special Qt_tmp directory? I don't see
> >the
> >> >benefit, and without that requirement you can simply use the
> >> >qt4_wrap_cpp
> >> >macro explicitly and you still are not forced to use the automoc
> >> >feature
> >> >
> >> >And now for what is probably wrong in your CMakeLists.txt:
> >> >* It seems you made an important mistake regarding the behaviour of
> >> >'file(GLOB)'. That function will do the expansion *while running
> >> >CMake*.
> >> >But at that time the moc_* files *don't exist!* (as a matter of
> >fact,
> >> >the
> >> >tmp directory doesn't even exist). In other words, your
> >${Moc_SOURCES}
> >> >will
> >> >be empty, and hence they are not compiled, and hence you get
> >precisely
> >> >the
> >> >linker errors you see (because these sources implement the functions
> >> >that
> >> >are listed as missing by the linker)
> >> >
> >> >If you would use the qt4_wrap_cpp() macro you don't run into this
> >> >problem,
> >> >so I'd strongly suggest using it.
> >>
> >> Except that he is using Qt3.
> >>
> >> >Sincerely,
> >> >Jakob van Bethlehem
> >> >
> >> >
> >> >
> >> >
> >> >On Tue, May 31, 2016 at 4:52 PM, irene w 
> >wrote:
> >> >
> >> >> It seems CMakw could not find the generated moc_xxx files.  I
> >> >modified the
> >> >> scripts to specify moc_xxx files is generated, but it still has
> >same
> >> >errors.
> >> >>
> >> >> ADD_CUSTOM_COMMAND ( OUTPUT ${Qt_tmp}/moc_GMWindow.cpp
> >> >>  COMMAND ${QT_MOC_CMD} ${GM_DIR}/GMWindow.h -o
> >> >> ${Qt_tmp}/moc_GMWindow.cpp
> >> >>  DEPENDS ${GM_DIR}/GMWindow.h
> >> >>)
> >> >> ADD_CUSTOM_TARGET(generate_foo DEPENDS ${Qt_tmp}/moc_GMWindow.cpp)
> >> >> SET_SOURCE_FILES_PROPERTIES(${Qt_tmp}/moc_GMWindow.cpp PROPERTIES
> >> >> GENERATED 1)
> >> >> SET_PROPERTY(SOURCE ${GM_DIR}/GMWindow.cpp APPEND PROPERTY
> >> >OBJECT_DEPENDS
> >> >> ${Qt_tmp}/moc_GMWindow.cpp)
> >> >>
> >> >> .
> >> >> add_dependencies (GM generate_foo)
> >> >>
> >> >>
> >> >> Does the Macro  "SET_SOURCE_FILES_PROPERTIES" with "GENERATED"
> >> >> setting work for this purposes?  Any help would be greatly
> >> >appreciated !
> >> >>
> >> >>
> >> >> On Wed, May 25, 2016 at 12:48 PM, irene w 
> >> >wrote:
> >> >>
> >> >>> Hi,
> >> >>>
> >> >>> I am compiling a simple Qt3 application on Linux using CMake. In
> >my
> >> >case,
> >> >>> I need to build moc_xxx files with custom options and output to a
> >> >specified
> >> >>> directory, So, I was not using CAMKE_AUTO macros. My cmake
> >scripts
> >> >create a
> >> >>> "Qt_tmp" directory and output moc_xxx there.
> >> >>>
> >> >>> It looked it always failed to link the moc_xxx files for the
> >first
> >> >time
> >> >>> build when there is no "Qt_tmp" directory, and succeeded if I ran
> >> >build
> >> >>> again if the "Qt_tmp" directory and moc_xxx files created by the
> >> >failed
> >> >>> build were kept without removing.  However, it'll fail if I
> >delete
> >> >>> the "Qt_tmp" directory.
> >> >>>
> >> >>> Even it failed at the first build, the moc_xxx files were
> >> >>> successfully created in the "Qt_tmp" directory.
> >> >>>
> >> >>> Here is my cmake scripts and the errors I got.  Can anyone help
> >me
> >> >to
> >> >>> figure out the issues? Any help would be greatly appreciated.
> >> >Thanks.
> >> >>>
> >> >>> CMakeLists.txt
> >> >>>
> >> >>>
> >>
> >>
>
> 

Re: [CMake] CMake+QT always failed for the first build, and succeeded for second build or later.

2016-06-01 Thread Hendrik Sattler


Am 1. Juni 2016 09:26:18 MESZ, schrieb Jakob van Bethlehem 
:
>That is what he said, but it seems to be a typo, because the
>CMakeLists.txt
>file clearly states 'set(QT_DIR
>${CMAKE_CURRENT_SOURCE_DIR}/ThirdParty/Qt/4.8.6)'

Ok, I overlooked that one...

>- still a stone-age version of Qt actually :(

Hey, that was the LTS release until 1 or 2 month ago!
And they made Qt 5.6 an LTS release also to quieten people that complain about 
dropping modules without proper replacement (means feature parity) and dropping 
compiler support.
You will see users of Qt 5.6 for a loong time.

>On Wed, Jun 1, 2016 at 9:09 AM, Hendrik Sattler
>
>wrote:
>
>>
>>
>> Am 1. Juni 2016 09:02:41 MESZ, schrieb Jakob van Bethlehem <
>> jsvanbethle...@gmail.com>:
>> >Hej,
>> >
>> >Some things that come to mind:
>> >* You're generating files *inside* the source tree - you're not
>> >supposed to
>> >do that
>> >* Why do you want to have a special Qt_tmp directory? I don't see
>the
>> >benefit, and without that requirement you can simply use the
>> >qt4_wrap_cpp
>> >macro explicitly and you still are not forced to use the automoc
>> >feature
>> >
>> >And now for what is probably wrong in your CMakeLists.txt:
>> >* It seems you made an important mistake regarding the behaviour of
>> >'file(GLOB)'. That function will do the expansion *while running
>> >CMake*.
>> >But at that time the moc_* files *don't exist!* (as a matter of
>fact,
>> >the
>> >tmp directory doesn't even exist). In other words, your
>${Moc_SOURCES}
>> >will
>> >be empty, and hence they are not compiled, and hence you get
>precisely
>> >the
>> >linker errors you see (because these sources implement the functions
>> >that
>> >are listed as missing by the linker)
>> >
>> >If you would use the qt4_wrap_cpp() macro you don't run into this
>> >problem,
>> >so I'd strongly suggest using it.
>>
>> Except that he is using Qt3.
>>
>> >Sincerely,
>> >Jakob van Bethlehem
>> >
>> >
>> >
>> >
>> >On Tue, May 31, 2016 at 4:52 PM, irene w 
>wrote:
>> >
>> >> It seems CMakw could not find the generated moc_xxx files.  I
>> >modified the
>> >> scripts to specify moc_xxx files is generated, but it still has
>same
>> >errors.
>> >>
>> >> ADD_CUSTOM_COMMAND ( OUTPUT ${Qt_tmp}/moc_GMWindow.cpp
>> >>  COMMAND ${QT_MOC_CMD} ${GM_DIR}/GMWindow.h -o
>> >> ${Qt_tmp}/moc_GMWindow.cpp
>> >>  DEPENDS ${GM_DIR}/GMWindow.h
>> >>)
>> >> ADD_CUSTOM_TARGET(generate_foo DEPENDS ${Qt_tmp}/moc_GMWindow.cpp)
>> >> SET_SOURCE_FILES_PROPERTIES(${Qt_tmp}/moc_GMWindow.cpp PROPERTIES
>> >> GENERATED 1)
>> >> SET_PROPERTY(SOURCE ${GM_DIR}/GMWindow.cpp APPEND PROPERTY
>> >OBJECT_DEPENDS
>> >> ${Qt_tmp}/moc_GMWindow.cpp)
>> >>
>> >> .
>> >> add_dependencies (GM generate_foo)
>> >>
>> >>
>> >> Does the Macro  "SET_SOURCE_FILES_PROPERTIES" with "GENERATED"
>> >> setting work for this purposes?  Any help would be greatly
>> >appreciated !
>> >>
>> >>
>> >> On Wed, May 25, 2016 at 12:48 PM, irene w 
>> >wrote:
>> >>
>> >>> Hi,
>> >>>
>> >>> I am compiling a simple Qt3 application on Linux using CMake. In
>my
>> >case,
>> >>> I need to build moc_xxx files with custom options and output to a
>> >specified
>> >>> directory, So, I was not using CAMKE_AUTO macros. My cmake
>scripts
>> >create a
>> >>> "Qt_tmp" directory and output moc_xxx there.
>> >>>
>> >>> It looked it always failed to link the moc_xxx files for the
>first
>> >time
>> >>> build when there is no "Qt_tmp" directory, and succeeded if I ran
>> >build
>> >>> again if the "Qt_tmp" directory and moc_xxx files created by the
>> >failed
>> >>> build were kept without removing.  However, it'll fail if I
>delete
>> >>> the "Qt_tmp" directory.
>> >>>
>> >>> Even it failed at the first build, the moc_xxx files were
>> >>> successfully created in the "Qt_tmp" directory.
>> >>>
>> >>> Here is my cmake scripts and the errors I got.  Can anyone help
>me
>> >to
>> >>> figure out the issues? Any help would be greatly appreciated.
>> >Thanks.
>> >>>
>> >>> CMakeLists.txt
>> >>>
>> >>>
>>
>>
>>-
>> >>> cmake_minimum_required(VERSION 3.4.1)
>> >>> project (GM_Application CXX)
>> >>> SET (CMAKE_SYSTEM_NAME Linux)
>> >>> SET (CMAKE_CXX_COMPILER ${COMPILER_PATH}${CROSS_COMPILE}g++)
>> >>> set (GM_DIR ${CMAKE_CURRENT_SOURCE_DIR})
>> >>> set (QT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/ThirdParty/Qt/4.8.6)
>> >>> LINK_DIRECTORIES (${QT_DIR}/lib)
>> >>> INCLUDE_DIRECTORIES ("${QT_DIR}/include"
>> >>>  "${GM_DIR}"
>> >>> )
>> >>> # Compiling QT moc and ui  #
>> >>> set (QT_MOC_CMD ${QT_DIR}/bin/moc -I$(QT_DIR)/mkspecs/linux-g++
>> >>> -I${QT_DIR}/include -I${QT_DIR}/include/QtGui)
>> >>> file (MAKE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Qt_tmp)
>> >>> set (Qt_tmp ${CMAKE_CURRENT_SOURCE_DIR}/Qt_tmp)
>> >>> 

Re: [CMake] CMake+QT always failed for the first build, and succeeded for second build or later.

2016-06-01 Thread Jakob van Bethlehem
That is what he said, but it seems to be a typo, because the CMakeLists.txt
file clearly states 'set(QT_DIR
${CMAKE_CURRENT_SOURCE_DIR}/ThirdParty/Qt/4.8.6)'
- still a stone-age version of Qt actually :(

Sincerely,
Jakob van Bethlehem


On Wed, Jun 1, 2016 at 9:09 AM, Hendrik Sattler 
wrote:

>
>
> Am 1. Juni 2016 09:02:41 MESZ, schrieb Jakob van Bethlehem <
> jsvanbethle...@gmail.com>:
> >Hej,
> >
> >Some things that come to mind:
> >* You're generating files *inside* the source tree - you're not
> >supposed to
> >do that
> >* Why do you want to have a special Qt_tmp directory? I don't see the
> >benefit, and without that requirement you can simply use the
> >qt4_wrap_cpp
> >macro explicitly and you still are not forced to use the automoc
> >feature
> >
> >And now for what is probably wrong in your CMakeLists.txt:
> >* It seems you made an important mistake regarding the behaviour of
> >'file(GLOB)'. That function will do the expansion *while running
> >CMake*.
> >But at that time the moc_* files *don't exist!* (as a matter of fact,
> >the
> >tmp directory doesn't even exist). In other words, your ${Moc_SOURCES}
> >will
> >be empty, and hence they are not compiled, and hence you get precisely
> >the
> >linker errors you see (because these sources implement the functions
> >that
> >are listed as missing by the linker)
> >
> >If you would use the qt4_wrap_cpp() macro you don't run into this
> >problem,
> >so I'd strongly suggest using it.
>
> Except that he is using Qt3.
>
> >Sincerely,
> >Jakob van Bethlehem
> >
> >
> >
> >
> >On Tue, May 31, 2016 at 4:52 PM, irene w  wrote:
> >
> >> It seems CMakw could not find the generated moc_xxx files.  I
> >modified the
> >> scripts to specify moc_xxx files is generated, but it still has same
> >errors.
> >>
> >> ADD_CUSTOM_COMMAND ( OUTPUT ${Qt_tmp}/moc_GMWindow.cpp
> >>  COMMAND ${QT_MOC_CMD} ${GM_DIR}/GMWindow.h -o
> >> ${Qt_tmp}/moc_GMWindow.cpp
> >>  DEPENDS ${GM_DIR}/GMWindow.h
> >>)
> >> ADD_CUSTOM_TARGET(generate_foo DEPENDS ${Qt_tmp}/moc_GMWindow.cpp)
> >> SET_SOURCE_FILES_PROPERTIES(${Qt_tmp}/moc_GMWindow.cpp PROPERTIES
> >> GENERATED 1)
> >> SET_PROPERTY(SOURCE ${GM_DIR}/GMWindow.cpp APPEND PROPERTY
> >OBJECT_DEPENDS
> >> ${Qt_tmp}/moc_GMWindow.cpp)
> >>
> >> .
> >> add_dependencies (GM generate_foo)
> >>
> >>
> >> Does the Macro  "SET_SOURCE_FILES_PROPERTIES" with "GENERATED"
> >> setting work for this purposes?  Any help would be greatly
> >appreciated !
> >>
> >>
> >> On Wed, May 25, 2016 at 12:48 PM, irene w 
> >wrote:
> >>
> >>> Hi,
> >>>
> >>> I am compiling a simple Qt3 application on Linux using CMake. In my
> >case,
> >>> I need to build moc_xxx files with custom options and output to a
> >specified
> >>> directory, So, I was not using CAMKE_AUTO macros. My cmake scripts
> >create a
> >>> "Qt_tmp" directory and output moc_xxx there.
> >>>
> >>> It looked it always failed to link the moc_xxx files for the first
> >time
> >>> build when there is no "Qt_tmp" directory, and succeeded if I ran
> >build
> >>> again if the "Qt_tmp" directory and moc_xxx files created by the
> >failed
> >>> build were kept without removing.  However, it'll fail if I delete
> >>> the "Qt_tmp" directory.
> >>>
> >>> Even it failed at the first build, the moc_xxx files were
> >>> successfully created in the "Qt_tmp" directory.
> >>>
> >>> Here is my cmake scripts and the errors I got.  Can anyone help me
> >to
> >>> figure out the issues? Any help would be greatly appreciated.
> >Thanks.
> >>>
> >>> CMakeLists.txt
> >>>
> >>>
>
> >-
> >>> cmake_minimum_required(VERSION 3.4.1)
> >>> project (GM_Application CXX)
> >>> SET (CMAKE_SYSTEM_NAME Linux)
> >>> SET (CMAKE_CXX_COMPILER ${COMPILER_PATH}${CROSS_COMPILE}g++)
> >>> set (GM_DIR ${CMAKE_CURRENT_SOURCE_DIR})
> >>> set (QT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/ThirdParty/Qt/4.8.6)
> >>> LINK_DIRECTORIES (${QT_DIR}/lib)
> >>> INCLUDE_DIRECTORIES ("${QT_DIR}/include"
> >>>  "${GM_DIR}"
> >>> )
> >>> # Compiling QT moc and ui  #
> >>> set (QT_MOC_CMD ${QT_DIR}/bin/moc -I$(QT_DIR)/mkspecs/linux-g++
> >>> -I${QT_DIR}/include -I${QT_DIR}/include/QtGui)
> >>> file (MAKE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Qt_tmp)
> >>> set (Qt_tmp ${CMAKE_CURRENT_SOURCE_DIR}/Qt_tmp)
> >>> add_custom_target (Moc_GMWindows
> >>>COMMAND ${QT_MOC_CMD} ${GM_DIR}/GMWindow.h -o
> >>> ${Qt_tmp}/moc_GMWindow.cpp
> >>>   )
> >>>
> >>> # Compiling application  #
> >>> file (GLOB GM_SOURCES ${GM_DIR}/*.h ${GM_DIR}/*.cpp)
> >>> file (GLOB Moc_SOURCES ${Qt_tmp}/*.h ${Qt_tmp}/*.cpp)
> >>> add_executable (GM ${GM_SOURCES} ${Moc_SOURCES})
> >>> target_include_directories (GM PRIVATE ${Qt_tmp})
> >>> add_dependencies (GM Moc_GMWindows)
> >>> target_link_libraries (GM QtGui)
> >>>

Re: [CMake] CMake+QT always failed for the first build, and succeeded for second build or later.

2016-06-01 Thread Hendrik Sattler


Am 1. Juni 2016 09:02:41 MESZ, schrieb Jakob van Bethlehem 
:
>Hej,
>
>Some things that come to mind:
>* You're generating files *inside* the source tree - you're not
>supposed to
>do that
>* Why do you want to have a special Qt_tmp directory? I don't see the
>benefit, and without that requirement you can simply use the
>qt4_wrap_cpp
>macro explicitly and you still are not forced to use the automoc
>feature
>
>And now for what is probably wrong in your CMakeLists.txt:
>* It seems you made an important mistake regarding the behaviour of
>'file(GLOB)'. That function will do the expansion *while running
>CMake*.
>But at that time the moc_* files *don't exist!* (as a matter of fact,
>the
>tmp directory doesn't even exist). In other words, your ${Moc_SOURCES}
>will
>be empty, and hence they are not compiled, and hence you get precisely
>the
>linker errors you see (because these sources implement the functions
>that
>are listed as missing by the linker)
>
>If you would use the qt4_wrap_cpp() macro you don't run into this
>problem,
>so I'd strongly suggest using it.

Except that he is using Qt3.

>Sincerely,
>Jakob van Bethlehem
>
>
>
>
>On Tue, May 31, 2016 at 4:52 PM, irene w  wrote:
>
>> It seems CMakw could not find the generated moc_xxx files.  I
>modified the
>> scripts to specify moc_xxx files is generated, but it still has same
>errors.
>>
>> ADD_CUSTOM_COMMAND ( OUTPUT ${Qt_tmp}/moc_GMWindow.cpp
>>  COMMAND ${QT_MOC_CMD} ${GM_DIR}/GMWindow.h -o
>> ${Qt_tmp}/moc_GMWindow.cpp
>>  DEPENDS ${GM_DIR}/GMWindow.h
>>)
>> ADD_CUSTOM_TARGET(generate_foo DEPENDS ${Qt_tmp}/moc_GMWindow.cpp)
>> SET_SOURCE_FILES_PROPERTIES(${Qt_tmp}/moc_GMWindow.cpp PROPERTIES
>> GENERATED 1)
>> SET_PROPERTY(SOURCE ${GM_DIR}/GMWindow.cpp APPEND PROPERTY
>OBJECT_DEPENDS
>> ${Qt_tmp}/moc_GMWindow.cpp)
>>
>> .
>> add_dependencies (GM generate_foo)
>>
>>
>> Does the Macro  "SET_SOURCE_FILES_PROPERTIES" with "GENERATED"
>> setting work for this purposes?  Any help would be greatly
>appreciated !
>>
>>
>> On Wed, May 25, 2016 at 12:48 PM, irene w 
>wrote:
>>
>>> Hi,
>>>
>>> I am compiling a simple Qt3 application on Linux using CMake. In my
>case,
>>> I need to build moc_xxx files with custom options and output to a
>specified
>>> directory, So, I was not using CAMKE_AUTO macros. My cmake scripts
>create a
>>> "Qt_tmp" directory and output moc_xxx there.
>>>
>>> It looked it always failed to link the moc_xxx files for the first
>time
>>> build when there is no "Qt_tmp" directory, and succeeded if I ran
>build
>>> again if the "Qt_tmp" directory and moc_xxx files created by the
>failed
>>> build were kept without removing.  However, it'll fail if I delete
>>> the "Qt_tmp" directory.
>>>
>>> Even it failed at the first build, the moc_xxx files were
>>> successfully created in the "Qt_tmp" directory.
>>>
>>> Here is my cmake scripts and the errors I got.  Can anyone help me
>to
>>> figure out the issues? Any help would be greatly appreciated. 
>Thanks.
>>>
>>> CMakeLists.txt
>>>
>>>
>-
>>> cmake_minimum_required(VERSION 3.4.1)
>>> project (GM_Application CXX)
>>> SET (CMAKE_SYSTEM_NAME Linux)
>>> SET (CMAKE_CXX_COMPILER ${COMPILER_PATH}${CROSS_COMPILE}g++)
>>> set (GM_DIR ${CMAKE_CURRENT_SOURCE_DIR})
>>> set (QT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/ThirdParty/Qt/4.8.6)
>>> LINK_DIRECTORIES (${QT_DIR}/lib)
>>> INCLUDE_DIRECTORIES ("${QT_DIR}/include"
>>>  "${GM_DIR}"
>>> )
>>> # Compiling QT moc and ui  #
>>> set (QT_MOC_CMD ${QT_DIR}/bin/moc -I$(QT_DIR)/mkspecs/linux-g++
>>> -I${QT_DIR}/include -I${QT_DIR}/include/QtGui)
>>> file (MAKE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Qt_tmp)
>>> set (Qt_tmp ${CMAKE_CURRENT_SOURCE_DIR}/Qt_tmp)
>>> add_custom_target (Moc_GMWindows
>>>COMMAND ${QT_MOC_CMD} ${GM_DIR}/GMWindow.h -o
>>> ${Qt_tmp}/moc_GMWindow.cpp
>>>   )
>>>
>>> # Compiling application  #
>>> file (GLOB GM_SOURCES ${GM_DIR}/*.h ${GM_DIR}/*.cpp)
>>> file (GLOB Moc_SOURCES ${Qt_tmp}/*.h ${Qt_tmp}/*.cpp)
>>> add_executable (GM ${GM_SOURCES} ${Moc_SOURCES})
>>> target_include_directories (GM PRIVATE ${Qt_tmp})
>>> add_dependencies (GM Moc_GMWindows)
>>> target_link_libraries (GM QtGui)
>>>
>>>
>>>
>---
>>> Errors:
>>>
>>> Scanning dependencies of target Moc_GMWindows
>>> [  0%] Built target Moc_GMWindows
>>> Scanning dependencies of target GM
>>> [ 14%] Building CXX object GM/CMakeFiles/GM.dir/GM/GM.cpp.o
>>> [ 42%] Building CXX object GM/CMakeFiles/GM.dir/GM/GMService.cpp.o
>>> [ 67%] Building CXX object GM/CMakeFiles/GM.dir/GM/GMWindow.cpp.o
>>> [ 85%] Building CXX object GM/CMakeFiles/GM.dir/GM/main.cpp.o
>>> [100%] Linking CXX executable ../bin/GM
>>> 

Re: [CMake] CMake+QT always failed for the first build, and succeeded for second build or later.

2016-06-01 Thread Jakob van Bethlehem
Hej,

Some things that come to mind:
* You're generating files *inside* the source tree - you're not supposed to
do that
* Why do you want to have a special Qt_tmp directory? I don't see the
benefit, and without that requirement you can simply use the qt4_wrap_cpp
macro explicitly and you still are not forced to use the automoc feature

And now for what is probably wrong in your CMakeLists.txt:
* It seems you made an important mistake regarding the behaviour of
'file(GLOB)'. That function will do the expansion *while running CMake*.
But at that time the moc_* files *don't exist!* (as a matter of fact, the
tmp directory doesn't even exist). In other words, your ${Moc_SOURCES} will
be empty, and hence they are not compiled, and hence you get precisely the
linker errors you see (because these sources implement the functions that
are listed as missing by the linker)

If you would use the qt4_wrap_cpp() macro you don't run into this problem,
so I'd strongly suggest using it.

Sincerely,
Jakob van Bethlehem




On Tue, May 31, 2016 at 4:52 PM, irene w  wrote:

> It seems CMakw could not find the generated moc_xxx files.  I modified the
> scripts to specify moc_xxx files is generated, but it still has same errors.
>
> ADD_CUSTOM_COMMAND ( OUTPUT ${Qt_tmp}/moc_GMWindow.cpp
>  COMMAND ${QT_MOC_CMD} ${GM_DIR}/GMWindow.h -o
> ${Qt_tmp}/moc_GMWindow.cpp
>  DEPENDS ${GM_DIR}/GMWindow.h
>)
> ADD_CUSTOM_TARGET(generate_foo DEPENDS ${Qt_tmp}/moc_GMWindow.cpp)
> SET_SOURCE_FILES_PROPERTIES(${Qt_tmp}/moc_GMWindow.cpp PROPERTIES
> GENERATED 1)
> SET_PROPERTY(SOURCE ${GM_DIR}/GMWindow.cpp APPEND PROPERTY OBJECT_DEPENDS
> ${Qt_tmp}/moc_GMWindow.cpp)
>
> .
> add_dependencies (GM generate_foo)
>
>
> Does the Macro  "SET_SOURCE_FILES_PROPERTIES" with "GENERATED"
> setting work for this purposes?  Any help would be greatly appreciated !
>
>
> On Wed, May 25, 2016 at 12:48 PM, irene w  wrote:
>
>> Hi,
>>
>> I am compiling a simple Qt3 application on Linux using CMake. In my case,
>> I need to build moc_xxx files with custom options and output to a specified
>> directory, So, I was not using CAMKE_AUTO macros. My cmake scripts create a
>> "Qt_tmp" directory and output moc_xxx there.
>>
>> It looked it always failed to link the moc_xxx files for the first time
>> build when there is no "Qt_tmp" directory, and succeeded if I ran build
>> again if the "Qt_tmp" directory and moc_xxx files created by the failed
>> build were kept without removing.  However, it'll fail if I delete
>> the "Qt_tmp" directory.
>>
>> Even it failed at the first build, the moc_xxx files were
>> successfully created in the "Qt_tmp" directory.
>>
>> Here is my cmake scripts and the errors I got.  Can anyone help me to
>> figure out the issues? Any help would be greatly appreciated.  Thanks.
>>
>> CMakeLists.txt
>>
>> -
>> cmake_minimum_required(VERSION 3.4.1)
>> project (GM_Application CXX)
>> SET (CMAKE_SYSTEM_NAME Linux)
>> SET (CMAKE_CXX_COMPILER ${COMPILER_PATH}${CROSS_COMPILE}g++)
>> set (GM_DIR ${CMAKE_CURRENT_SOURCE_DIR})
>> set (QT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/ThirdParty/Qt/4.8.6)
>> LINK_DIRECTORIES (${QT_DIR}/lib)
>> INCLUDE_DIRECTORIES ("${QT_DIR}/include"
>>  "${GM_DIR}"
>> )
>> # Compiling QT moc and ui  #
>> set (QT_MOC_CMD ${QT_DIR}/bin/moc -I$(QT_DIR)/mkspecs/linux-g++
>> -I${QT_DIR}/include -I${QT_DIR}/include/QtGui)
>> file (MAKE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Qt_tmp)
>> set (Qt_tmp ${CMAKE_CURRENT_SOURCE_DIR}/Qt_tmp)
>> add_custom_target (Moc_GMWindows
>>COMMAND ${QT_MOC_CMD} ${GM_DIR}/GMWindow.h -o
>> ${Qt_tmp}/moc_GMWindow.cpp
>>   )
>>
>> # Compiling application  #
>> file (GLOB GM_SOURCES ${GM_DIR}/*.h ${GM_DIR}/*.cpp)
>> file (GLOB Moc_SOURCES ${Qt_tmp}/*.h ${Qt_tmp}/*.cpp)
>> add_executable (GM ${GM_SOURCES} ${Moc_SOURCES})
>> target_include_directories (GM PRIVATE ${Qt_tmp})
>> add_dependencies (GM Moc_GMWindows)
>> target_link_libraries (GM QtGui)
>>
>>
>> ---
>> Errors:
>>
>> Scanning dependencies of target Moc_GMWindows
>> [  0%] Built target Moc_GMWindows
>> Scanning dependencies of target GM
>> [ 14%] Building CXX object GM/CMakeFiles/GM.dir/GM/GM.cpp.o
>> [ 42%] Building CXX object GM/CMakeFiles/GM.dir/GM/GMService.cpp.o
>> [ 67%] Building CXX object GM/CMakeFiles/GM.dir/GM/GMWindow.cpp.o
>> [ 85%] Building CXX object GM/CMakeFiles/GM.dir/GM/main.cpp.o
>> [100%] Linking CXX executable ../bin/GM
>> CMakeFiles/GM.dir/GM/GMWindow.cpp.o: In function
>> `GM::GMWindow::emitAppendMessage(QStrin
>> g)':
>> /GM/GMWindow.cpp:217: undefined reference to
>> `GM::GMWindow::appendMessage(QString)'
>> CMakeFiles/GM.dir/GM/GMWindow.cpp.o:(.rodata._ZTVN2GM8GMWindowE[vtable
>> for 

Re: [CMake] CMake+QT always failed for the first build, and succeeded for second build or later.

2016-05-31 Thread irene w
It seems CMakw could not find the generated moc_xxx files.  I modified the
scripts to specify moc_xxx files is generated, but it still has same errors.

ADD_CUSTOM_COMMAND ( OUTPUT ${Qt_tmp}/moc_GMWindow.cpp
 COMMAND ${QT_MOC_CMD} ${GM_DIR}/GMWindow.h -o
${Qt_tmp}/moc_GMWindow.cpp
 DEPENDS ${GM_DIR}/GMWindow.h
   )
ADD_CUSTOM_TARGET(generate_foo DEPENDS ${Qt_tmp}/moc_GMWindow.cpp)
SET_SOURCE_FILES_PROPERTIES(${Qt_tmp}/moc_GMWindow.cpp PROPERTIES GENERATED
1)
SET_PROPERTY(SOURCE ${GM_DIR}/GMWindow.cpp APPEND PROPERTY OBJECT_DEPENDS
${Qt_tmp}/moc_GMWindow.cpp)

.
add_dependencies (GM generate_foo)


Does the Macro  "SET_SOURCE_FILES_PROPERTIES" with "GENERATED" setting work
for this purposes?  Any help would be greatly appreciated !


On Wed, May 25, 2016 at 12:48 PM, irene w  wrote:

> Hi,
>
> I am compiling a simple Qt3 application on Linux using CMake. In my case,
> I need to build moc_xxx files with custom options and output to a specified
> directory, So, I was not using CAMKE_AUTO macros. My cmake scripts create a
> "Qt_tmp" directory and output moc_xxx there.
>
> It looked it always failed to link the moc_xxx files for the first time
> build when there is no "Qt_tmp" directory, and succeeded if I ran build
> again if the "Qt_tmp" directory and moc_xxx files created by the failed
> build were kept without removing.  However, it'll fail if I delete
> the "Qt_tmp" directory.
>
> Even it failed at the first build, the moc_xxx files were
> successfully created in the "Qt_tmp" directory.
>
> Here is my cmake scripts and the errors I got.  Can anyone help me to
> figure out the issues? Any help would be greatly appreciated.  Thanks.
>
> CMakeLists.txt
>
> -
> cmake_minimum_required(VERSION 3.4.1)
> project (GM_Application CXX)
> SET (CMAKE_SYSTEM_NAME Linux)
> SET (CMAKE_CXX_COMPILER ${COMPILER_PATH}${CROSS_COMPILE}g++)
> set (GM_DIR ${CMAKE_CURRENT_SOURCE_DIR})
> set (QT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/ThirdParty/Qt/4.8.6)
> LINK_DIRECTORIES (${QT_DIR}/lib)
> INCLUDE_DIRECTORIES ("${QT_DIR}/include"
>  "${GM_DIR}"
> )
> # Compiling QT moc and ui  #
> set (QT_MOC_CMD ${QT_DIR}/bin/moc -I$(QT_DIR)/mkspecs/linux-g++
> -I${QT_DIR}/include -I${QT_DIR}/include/QtGui)
> file (MAKE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Qt_tmp)
> set (Qt_tmp ${CMAKE_CURRENT_SOURCE_DIR}/Qt_tmp)
> add_custom_target (Moc_GMWindows
>COMMAND ${QT_MOC_CMD} ${GM_DIR}/GMWindow.h -o
> ${Qt_tmp}/moc_GMWindow.cpp
>   )
>
> # Compiling application  #
> file (GLOB GM_SOURCES ${GM_DIR}/*.h ${GM_DIR}/*.cpp)
> file (GLOB Moc_SOURCES ${Qt_tmp}/*.h ${Qt_tmp}/*.cpp)
> add_executable (GM ${GM_SOURCES} ${Moc_SOURCES})
> target_include_directories (GM PRIVATE ${Qt_tmp})
> add_dependencies (GM Moc_GMWindows)
> target_link_libraries (GM QtGui)
>
>
> ---
> Errors:
>
> Scanning dependencies of target Moc_GMWindows
> [  0%] Built target Moc_GMWindows
> Scanning dependencies of target GM
> [ 14%] Building CXX object GM/CMakeFiles/GM.dir/GM/GM.cpp.o
> [ 42%] Building CXX object GM/CMakeFiles/GM.dir/GM/GMService.cpp.o
> [ 67%] Building CXX object GM/CMakeFiles/GM.dir/GM/GMWindow.cpp.o
> [ 85%] Building CXX object GM/CMakeFiles/GM.dir/GM/main.cpp.o
> [100%] Linking CXX executable ../bin/GM
> CMakeFiles/GM.dir/GM/GMWindow.cpp.o: In function
> `GM::GMWindow::emitAppendMessage(QStrin
> g)':
> /GM/GMWindow.cpp:217: undefined reference to
> `GM::GMWindow::appendMessage(QString)'
> CMakeFiles/GM.dir/GM/GMWindow.cpp.o:(.rodata._ZTVN2GM8GMWindowE[vtable for
> GM::GMWindow]
> +0x8): undefined reference to `GM::GMWindow::metaObject() const'
> CMakeFiles/GM.dir/GM/GMWindow.cpp.o:(.rodata._ZTVN2GM8GMWindowE[vtable for
> GM::GMWindow]
> +0xc): undefined reference to `GM::GMWindow::qt_metacast(char const*)'
> CMakeFiles/GM.dir/GM/GMWindow.cpp.o:(.rodata._ZTVN2GM8GMWindowE[vtable for
> GM::GMWindow]
> +0x10): undefined reference to
> `GM::GMWindow::qt_metacall(QMetaObject::Call, int, void**)'
> collect2: ld returned 1 exit status
> make[2]: *** [bin/GM] Error 1
> make[1]: *** [GM/CMakeFiles/GM.dir/all] Error 2
> make: *** [all] Error 2
>
>
>
> 
>  Virus-free.
> www.avast.com
> 
> <#m_6400203814648417669_DDB4FAA8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: