Hi Alan Thanks for the suggestions. Using the environment variables seems to work for unicode, but not for the static linkage. When I refer to static linkage I mean linkage with the static/dynamic linked runtime library, rather than internal static linkage to generate a .lib rather than a .dll. A bit more googling actually found this item http://www.cmake.org/Wiki/CMake_FAQ#How_can_I_build_my_MSVC_application_with_a_static_runtime.3F I've basically taken that code snippet and added it to the cmakelists.txt file for the c/c++ examples, src, c++, wxwidgets, csa and qsastime directories. For csa and qsastime I had to change CXX_FLAGS to C_FLAGS, but doing this for the src and c examples actually stopped the change working in these cases - I'm not sure why. I've wrapped the changes in an if(STATIC_RUNTIME). I'm not sure if the code should be added anywhere else. I've attached a patch so you can see exactly what I've done. Unfortunately I have no experience with writing CMAKE files so I'm not sure if I've added the code in a sensible place - but it works. One other item I noticed. the qsastime and csa libraries don't get the tag appended. Is this by design? Phil
________________________________ From: Alan W. Irwin <ir...@beluga.phys.uvic.ca> To: phil rosenberg <philip_rosenb...@yahoo.com> Cc: Arjen Markus <arjen.mar...@deltares.nl>; "plplot-devel@lists.sourceforge.net" <plplot-devel@lists.sourceforge.net> Sent: Friday, 31 August 2012, 19:47 Subject: Re: [Plplot-devel] Building examples on Windows On 2012-08-31 07:04-0700 phil rosenberg wrote: > I think I've found the problem, but haven't properly solved it. > > I am using -DCMAKE_CXX_FLAGS_RELEASE="/MT" and -DCMAKE_CXX_FLAGS_DEBUG="/MTd" > and the C versions of these flags to specify static linkage. I found that > adding /DNDEBUG to the release versions of the flags cured my problem. > > However I've also recently tried building with unicode enabled, but using > -DCMAKE_CXX_FLAGS="/D UNICODE /D _UNICODE". this caused me build errors that > I narrowed down to not having WIN32 defined! > > It seems that defining these flags on the command line is overriding the > "normal" linker flags rather than adding to them. am I doing something wrong > and is there a better way to do this? Hi Phil: I never bother with the CMake CMAKE_BUILD_TYPE flag or set CMAKE_<LANG>_FLAGS_<CONFIG> CMake options, where CONFIG is RELEASE, DEBUG, etc. But perhaps the problem is you should be using CMAKE_EXE_LINKER_FLAGS_[CMAKE_BUILD_TYPE] (see documentation) to specify linker flags? Or you may have found a CMake bug in how one (or some) of the CMAKE_<LANG>_FLAGS_<CONFIG> are implemented so there is inappropriate leakage of the flag to the link step? What always works for me is to use the default CMAKE_BUILD_TYPE and simply set the environment variables CFLAGS, CXXFLAGS, and FFLAGS to whatever I like for the current build I am currently using CXXFLAGS=-O3 -fvisibility=hidden CFLAGS=-O3 -fvisibility=hidden FFLAGS=-O3 with no problems. But I often use something much more complicated or something very simple. However, I don't know how to set linker flags with this environment variable approach. With regard to your use case, if all you are concerned about is static linking of the internal PLplot libraries and executables amongst themselves, then setting -DBUILD_SHARED_LIBS=OFF will do the trick. But that doesn't deal with the case of how PLplot libraries and executables are linked with external libraries, and if you want that linking to be static as well then you should look at the documentation of the CMake target property LINK_SEARCH_START_STATIC. You cannot set target properties directly from the cmake command line, but if you modify src/CMakeLists.txt files to set that target property for, say, the plplotd library, and it works for you, then we could set up a command-line option (called, say, EXTERNAL_STATIC_LINKING). If the user specifies that option as ON then we could change our current build system so that wherever that system creates libraries or executables, the CMake logic to set the corresponding target property LINK_SEARCH_START_STATIC would also be executed. Alan __________________________ Alan W. Irwin Astronomical research affiliation with Department of Physics and Astronomy, University of Victoria (astrowww.phys.uvic.ca). Programming affiliations with the FreeEOS equation-of-state implementation for stellar interiors (freeeos.sf.net); the Time Ephemerides project (timeephem.sf.net); PLplot scientific plotting software package (plplot.sf.net); the libLASi project (unifont.org/lasi); the Loads of Linux Links project (loll.sf.net); and the Linux Brochure Project (lbproject.sf.net). __________________________ Linux-powered Science __________________________
cmake static runtime.patch
Description: Binary data
------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________ Plplot-devel mailing list Plplot-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/plplot-devel