From: Alan W. Irwin <email@example.com>
To: phil rosenberg <firstname.lastname@example.org>
Cc: Arjen Markus <email@example.com>;
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?
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
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
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 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).