How add a specific option for msvc in cmake

Hi all,

I try to update my current version of Avogadro, when link
problems occurred during the compilation :
LNK2019: unresolved external symbol … toStdWString …
( - the problem : http://developer.qt.nokia.com/forums/viewthread/3004
- a solution :
http://www.cmake.org/pipermail/cmake/2008-February/019781.html
)

After research, I find that I need to add a flag in cmake to avoid msvc to
compile with “Treat wchar as built-in type” at YES .
But I do not find the cmakeLists to put this command.

My current solution is, in each msvc solution (animationextension, avogadro,
inputfileextension, insertfragmentextension, and insertpeptideextension), to
change C++ -> Language -> Treat wchar_t as Built-in Type -> NO

How can I do to change this option automatically in Avogadro cmake ?

Regards,
Mickaël Gadroy

After research, I find that I need to add a flag in cmake to avoid msvc to compile with “Treat wchar as built-in type” at YES .
But I do not find the cmakeLists to put this command.

You’d do something like this in the appropriate CMakeLists.txt

if (MSVC)
set_target_properties(mytarget1 mytarget2 …
PROPERTIES COMPILE_FLAGS “/Zc:wchar_t-”)
endif()

Hope that helps,
-Geoff

On Wed, Apr 13, 2011 at 10:46 AM, Geoffrey Hutchison
geoff.hutchison@gmail.com wrote:

After research, I find that I need to add a flag in cmake to avoid msvc to compile with “Treat wchar as built-in type” at YES .
But I do not find the cmakeLists to put this command.

You’d do something like this in the appropriate CMakeLists.txt

if (MSVC)
set_target_properties(mytarget1 mytarget2 …
PROPERTIES COMPILE_FLAGS “/Zc:wchar_t-”)
endif()

These changes sound like they are the result of some recent changes
from Konstantin to address file name encoding issues. I thought he had
tested these, and no new compiler flags were necessary. If they are
then we should add them to our build system. I will test this out
later when I get home, and will be adding more dashboards for Windows
soon.

I think you may be seeing this as I cherry picked quite a few fixes
from 1.0 to master yesterday.

Marcus

On Wed, Apr 13, 2011 at 6:00 AM, Mickaël Gadroy
mickael.gadroy@gmail.com wrote:

Hi all,
I try to update my current version of Avogadro, when link
problems occurred during the compilation :
LNK2019: unresolved external symbol … toStdWString …
( - the problem : http://developer.qt.nokia.com/forums/viewthread/3004
- a solution
: http://www.cmake.org/pipermail/cmake/2008-February/019781.html
)
After research, I find that I need to add a flag in cmake to avoid msvc to
compile with “Treat wchar as built-in type” at YES .
But I do not find the cmakeLists to put this command.
My current solution is, in each msvc solution (animationextension,
avogadro, inputfileextension, insertfragmentextension, and
insertpeptideextension), to change C++ -> Language -> Treat wchar_t as
Built-in Type -> NO
How can I do to change this option automatically in Avogadro cmake ?

I spent some of the evening verifying the Avogadro build on Windows
for both 1.0 and master. I have reverted the offending patch for now,
as it was a Windows specific patch that consistently breaks linking
for me using MSVC 2008 on Windows 7, with that in mind it is not clear
it actually fixed the underlying issue.

The Windows machine I was running a dashboard on got old. I have a new
one (which I have been testing stuff on this evening), and will get
automated builds running on it. With my latest pushes Avogadro 1.0 and
master successfully build and link on Windows with Visual Studio 2008
in 32 bit mode at least.

Marcus

Sorry to answer so late.
I have no compilation problem with the latest version of Avogadro available
on Github (26/04).
After research, my problem can be caused by my Qt install. It is a binary
download from Qt website, so I do not know the option about the stl
management on my version.
The Qt doc of the toStdWString() method says :
"This operator is only available if Qt is configured with STL compatibility
enabled."
And I found a post which says :

Qt is compiled with wchar_t as built-in type. Your program is probably
compiled with wchar_t as built-in. This causes linking issues when using
toStdWString. You should either rebuild Qt with wchar_t as built-in type, or
change your project settings to use non built-in (which will require you to
include wchar.h).

If the problem comes back, I will do some test with my Qt install.

Regards,
Mickaël Gadroy

2011/4/14 Marcus D. Hanwell mhanwell@gmail.com

On Wed, Apr 13, 2011 at 6:00 AM, Mickaël Gadroy
mickael.gadroy@gmail.com wrote:

Hi all,
I try to update my current version of Avogadro, when link
problems occurred during the compilation :
LNK2019: unresolved external symbol … toStdWString …
( - the problem : http://developer.qt.nokia.com/forums/viewthread/3004
- a solution
: http://www.cmake.org/pipermail/cmake/2008-February/019781.html
)
After research, I find that I need to add a flag in cmake to avoid msvc
to
compile with “Treat wchar as built-in type” at YES .
But I do not find the cmakeLists to put this command.
My current solution is, in each msvc solution (animationextension,
avogadro, inputfileextension, insertfragmentextension, and
insertpeptideextension), to change C++ -> Language -> Treat wchar_t as
Built-in Type -> NO
How can I do to change this option automatically in Avogadro cmake ?

I spent some of the evening verifying the Avogadro build on Windows
for both 1.0 and master. I have reverted the offending patch for now,
as it was a Windows specific patch that consistently breaks linking
for me using MSVC 2008 on Windows 7, with that in mind it is not clear
it actually fixed the underlying issue.

The Windows machine I was running a dashboard on got old. I have a new
one (which I have been testing stuff on this evening), and will get
automated builds running on it. With my latest pushes Avogadro 1.0 and
master successfully build and link on Windows with Visual Studio 2008
in 32 bit mode at least.

Marcus