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
__________________________

------------------------------------------------------------------------------
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

Reply via email to