[ Return to Bugs & Features | Post Text | Post File | Prev | Next ]
|Status:||5 - New|
|Priority:||3 - Moderate, e.g. unable to compile the software|
|Scope:||2 - Specific to an operating system|
|Summary:||cmake/Visual Studio: control /MT vs /MD compiler flags|
Trouble Report Files:
[ Post File ]
Trouble Report Comments:
[ Post Text ]
10:41 Dec 13, 2017
|Cmake generates /MD by default, but sometimes the user wants to |
build FLTK with /MT.
This should probably be easier to control than to redefine all the
compiler flags (as I described in a workaround posted to fltk.general
on 12/12/2017, Subject: CMAKE + Visual Studio: /MT vs /MD builds)
Essentially, this is a "static" vs "dynamic" build issue, and may
apply to other compilers/platforms as well (e.g. mingw, clang, g++..).
With Visual Studio, it's important that both the user application
and FLTK be compiled with the /same/ flags (either /MD or /MT), else
numerous errors happen at link time, e.g.
MSVCRT.lib(MSVCR90.dll) : error LNK2005: _malloc already defined in LIBCMT.lib ..
MSVCRT.lib(MSVCR90.dll) : error LNK2005: _fwrite already defined in LIBCMT.lib ..
MSVCRT.lib(MSVCR90.dll) : error LNK2005: _getenv already defined in LIBCMT.lib ..
01:33 Jun 20, 2019
|Checking status on this; see thread: |
I'm running into this problem again with latest CMAKE + fltk.git + VS 2017 to build a debug version of fltk, e.g.
cmake -D CMAKE_BUILD_TYPE=Debug ..
..that's apparently building /dynamic/ debug executables (/MDd) and not static debug (/MTd), conflicting with my project.. the VS build logs are showing /MDd for all the CL compiler commands.
I came full circle to my own post in google groups, seeing I've been here before. I think adding a feature that replaces /MD + /MDd with /MT and /MTd is still needed.
I'm trying other random stuff on the web to see if I can lick this with the cmake command line, but if not, I'll have to go search/replacing again..
14:46 Jun 20, 2019
|FWIW, there's a new feature in CMake 3.15 (to be released soon, currently rc2): |
See also release notes:
and CMake policy CMP0091:
The problem with this is however that it's a brand new (not yet released) CMake version and we'd need to check the running CMake version and deal with it dynamically, i.e. *either* use the new feature *or* do string manipulation of CMAKE_*_FLAGS for older CMake versions which is generally discouraged.
I'm not aware of a proper solution - I just wanted to show the current CMake development.
14:51 Jun 20, 2019
|FTR: from the CMake mailing list: |
[CMake] [ANNOUNCE] CMake 3.15.0-rc2 is ready for testing
Wed Jun 19 11:57:00 EDT 2019
There are also changes in default warning switches (/W3) no longer being set, leaving this to the user.
[ Return to Bugs & Features | Post Text | Post File ]