lexxmark / winflexbison

Main winflexbision repository
GNU General Public License v3.0
412 stars 119 forks source link

Add option to use Win STATIC runtime #52

Closed geoffmcl closed 4 years ago

geoffmcl commented 4 years ago

Suggested CMake OPTION, to build with the Windows STATIC runtime libs... see #39

GitMensch commented 4 years ago

Thank you for the PR, the old variant seems to work fine ;-) [just with the reasonable additional note that dynamic was used].

Any idea how to add this as a new "configuration" "release/static" via https://github.com/lexxmark/winflexbison/blob/master/.appveyor.yml ? This should provide static release versions along to the existing ones.

geoffmcl commented 4 years ago

Hmmm, just a quick glance at .appveyor.yml... your using it to build the ZIP, I guess...

I can perhaps see why the CMAKE_BUILD_TYPE is fiddled with in the CMakeLists.txt...

Normally, in multiconfig build systems, like MSVC is, as opposed to unix or mingw, you should add the config to the cmake build line(s)...

You can add it to the cmake config and generation run, but it does not have much meaning there... by default, the solution should support at least 4 configs...

But it should be there in the cmake build action lines, like -

after_build:
  - cmake --build . --config Debug --target package
  - cmake --build . --config Release --target package

And if you want to distribute the STATIC version, then you need to add -DUSE_STATIC_RUNTIME:BOOL=YES to a cmake generation run... this can be distributed to people who do NOT have the MSVC runtime installed... and do not want to add it...

You could also distribute the DYNAMIC version... but that requires some sort of naming convention be employed... to separate the ZIPs...

A person downloading this repo, and building their own, have MSVC runtimes installed, so they should be happy with the extra dependencies of the DYNAMIC version... no problem...

HTH

geoffmcl commented 4 years ago

@Croydon agreed, of course it should be OFF, by default...

Just an option, most user probably do not need to know about... unless they are distributing WIN32 EXE binaries... and take care of dependencies...

I think you will find the cmake MSVC generator default is /MD /MDd, unless you instruct otherwise... like explicitly setting CMAKE_C_FLAGS in the CMakeLists.txt... and there are probably other ways... this seems unchanged for years, and years...

Maybe I am missing something... ;=))

lexxmark commented 4 years ago

@GitMensch , Sorry I'm not tracking this PR, do you think it is ready to merge?