Content-Type: multipart/alternative; boundary="-748019302-643223600-1346455392=:91814" ---748019302-643223600-1346455392=:91814 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Hi Alan=0AThanks for the suggestions. Using the environment variables seems= to work for unicode, but not for the static linkage. When I refer to stati= c linkage I mean linkage with the static/dynamic linked runtime library, ra= ther than internal static linkage to generate a .lib rather than a .dll.=0A= A bit more googling actually found this item=0Ahttp://www.cmake.org/Wiki/CM= ake_FAQ#How_can_I_build_my_MSVC_application_with_a_static_runtime.3F=0AI've= basically taken that code snippet and added it to the cmakelists.txt file = for the c/c++=A0examples, 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 ca= ses - 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.=0A=A0=0AI've attach= ed a patch so you can see exactly what I've done. Unfortunately I have no e= xperience with writing CMAKE files so I'm not sure if I've added the code i= n a sensible place - but it works.=0A=A0=0AOne other item I noticed. the qs= astime and csa libraries don't get the tag appended. Is this by design?=A0= =0A=A0=0APhil=0A =0A=0A________________________________=0A From: Alan W. Ir= win =0ATo: phil rosenberg =0ACc: Arjen Markus ; "plplot-devel@lists.= sourceforge.net" =0ASent: Friday, 31 A= ugust 2012, 19:47=0ASubject: Re: [Plplot-devel] Building examples on Window= s=0A =0AOn 2012-08-31 07:04-0700 phil rosenberg wrote:=0A=0A> I think I've= found the problem, but haven't properly solved it.=0A> =A0=0A> I am using = -DCMAKE_CXX_FLAGS_RELEASE=3D"/MT" and -DCMAKE_CXX_FLAGS_DEBUG=3D"/MTd" and = the=A0C versions of these flags to specify static linkage. I found that add= ing /DNDEBUG to the release versions of the flags cured my problem.=0A> =A0= =0A> However I've also recently tried building with unicode enabled, but=A0= using -DCMAKE_CXX_FLAGS=3D"/D UNICODE /D _UNICODE". this caused me build er= rors that I narrowed down to not having WIN32 defined!=0A> =A0=0A> It seems= that defining these flags on the command line is overriding the "normal" l= inker flags rather than adding to them. am I doing something wrong and is t= here a better way to do this?=0A=0AHi Phil:=0A=0AI never bother with the CM= ake CMAKE_BUILD_TYPE flag or set=0ACMAKE__FLAGS_ CMake option= s, where CONFIG is RELEASE,=0ADEBUG, etc.=A0 But perhaps the problem is you= should be using=0ACMAKE_EXE_LINKER_FLAGS_[CMAKE_BUILD_TYPE] (see documenta= tion) to=0Aspecify linker flags?=A0 Or you may have found a CMake bug=0Ain = how one (or some) of the CMAKE__FLAGS_ are implemented=0Aso t= here is inappropriate leakage of the flag to the link step?=0A=0AWhat alway= s works for me is to use the default CMAKE_BUILD_TYPE and=0Asimply set the = environment variables CFLAGS, CXXFLAGS, and FFLAGS to=0Awhatever I like for= the current build=0A=0AI am currently using=0A=0ACXXFLAGS=3D-O3 -fvisibili= ty=3Dhidden=0ACFLAGS=3D-O3 -fvisibility=3Dhidden=0AFFLAGS=3D-O3=0A=0Awith n= o problems.=A0 But I often use something much more complicated or=0Asomethi= ng very simple.=A0 However, I don't know how to set linker flags=0Awith thi= s environment variable approach.=0A=0AWith regard to your use case, if all = you are concerned about is static=0Alinking of the internal PLplot librarie= s and executables amongst=0Athemselves, then setting -DBUILD_SHARED_LIBS=3D= OFF will do the trick.=0ABut that doesn't deal with the case of how PLplot = libraries and=0Aexecutables are linked with external libraries, and if you = want that=0Alinking to be static as well then you should look at the docume= ntation=0Aof the CMake target property LINK_SEARCH_START_STATIC.=A0 You can= not set=0Atarget properties directly from the cmake command line, but if yo= u=0Amodify src/CMakeLists.txt files to set that target property for, say,= =0Athe plplotd library, and it works for you, then we could set up a=0Acomm= and-line option (called, say, EXTERNAL_STATIC_LINKING).=A0 If the=0Auser sp= ecifies that option as ON then we could change our current=0Abuild system s= o that wherever that system creates libraries or=0Aexecutables, the CMake l= ogic to set the corresponding target property=0ALINK_SEARCH_START_STATIC wo= uld also be executed.=0A=0AAlan=0A__________________________=0AAlan W. Irwi= n=0A=0AAstronomical research affiliation with Department of Physics and Ast= ronomy,=0AUniversity of Victoria (astrowww.phys.uvic.ca).=0A=0AProgramming = affiliations with the FreeEOS equation-of-state=0Aimplementation for stella= r interiors (freeeos.sf.net); the Time=0AEphemerides project (timeephem.sf.= net); PLplot scientific plotting=0Asoftware package (plplot.sf.net); the li= bLASi project=0A(unifont.org/lasi); the Loads of Linux Links project (loll.= sf.net);=0Aand the Linux Brochure Project (lbproject.sf.net).=0A___________= _______________=0A=0ALinux-powered Science=0A__________________________ ---748019302-643223600-1346455392=:91814 Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable
Hi Alan
<= div style=3D"color: rgb(0, 0, 0); font-family: arial, helvetica, sans-serif= ; font-size: 16px; font-style: normal; background-color: transparent;">Thanks for the suggestions. Using the environment variables seems to work= for unicode, but not for the static linkage. When I refer to static linkag= e I mean linkage with the static/dynamic linked runtime library, rather tha= n internal static linkage to generate a .lib rather than a .dll.
<= span>A bit more googling actually found this item
I'= ve basically taken that code snippet and added it to the cmakelists.txt fil= e for the c/c++ examples, src, c++, wxwidgets, csa and qsastime direct= ories. 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 the= se cases - I'm not sure why. I've wrapped the changes in an if(STATIC_RUNTI= ME). 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 writin= g 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 des= ign? 
 
Phil

From: Alan W. Irwin <irwin@beluga.phys.uvic.c= a>
To: phil rosenbe= rg <philip_rosenberg@yahoo.com>
Cc: Arjen Markus <arjen.markus@deltares.nl>; "plplot-devel@lists.sourceforge.net" <plplot-devel@lists.sourceforge.ne= t>
Sent: Friday, 3= 1 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=3D"/MT" and -DCMAKE_CXX_FLAGS_DEBUG=3D= "/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 pr= oblem.
>  
> However I've also recently tried building wit= h unicode enabled, but using -DCMAKE_CXX_FLAGS=3D"/D UNICODE /D _UNICO= DE". this caused me build errors that I narrowed down to not having WIN32 d= efined!
>  
> 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 u= sing
CMAKE_EXE_LINKER_FLAGS_[CMAKE_BUILD_TYPE] (see documentation) tospecify linker flags?  Or you may have found a CMake bug
in how on= e (or some) of the CMAKE_<LANG>_FLAGS_<CONFIG> are implemented<= br>so there is inappropriate leakage of the flag to the link step?

W= hat always works for me is to use the default CMAKE_BUILD_TYPE and
simpl= y set the environment variables CFLAGS, CXXFLAGS, and FFLAGS to
whatever= I like for the current build

I am currently using

CXXFLAGS= =3D-O3 -fvisibility=3Dhidden
CFLAGS=3D-O3 -fvisibility=3Dhidden
FFLAGS=3D-O3

with no problems.  But I= often use something much more complicated or
something very simple.&nbs= p; However, I don't know how to set linker flags
with this environment v= ariable approach.

With regard to your use case, if all you are conce= rned about is static
linking of the internal PLplot libraries and execut= ables amongst
themselves, then setting -DBUILD_SHARED_LIBS=3DOFF 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<= br>of the CMake target property LINK_SEARCH_START_STATIC.  You cannot = set
target properties directly from the cmake command line, but if youmodify 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 currentbuild system so that wherever that system creates libraries or
executab= les, the CMake logic to set the corresponding target property
LINK_SEARC= H_START_STATIC would also be executed.

Alan
_____________________= _____
Alan W. Irwin

Astronomical research affiliation with Depart= ment of Physics and Astronomy,
University of Victoria (astrowww.phys.uvi= c.ca).

Programming affiliations with the FreeEOS equation-of-stateimplementation for stellar interiors (freeeos.sf.net); the Time
Epheme= rides project (timeephem.sf.net); PLplot scientific plotting
software pa= ckage (plplot.sf.net); the libLASi project
(unifont.org/lasi); the Loads= of Linux Links project (loll.sf.net);
and the Linux Brochure Project (l= bproject.sf.net).
__________________________

Linux-powered Science
__________________________


---748019302-643223600-1346455392=:91814--