Closed AntumDeluge closed 5 years ago
I see.
The fact is the install instructions are mainly intended for Linux/POSIX systems and package manager of those systems. I don't know how to really fix it for Windows as there is no standard directory where such utilities should be placed into (actually that's also the reason why on Windows we by default build only static lib so there is no dependency on a DLL.)
We could maybe wrap the install commands in CMake by
if(not WIN32)
... # the install commands
endif()
to not cause mess on the filesystem but I am not sure whether it would make life of e.g. MSYS2 users harder.
I just noticed another issue related to this. If I am using the CMake version from MSYS2's package manager, calling
make install
renamesmd2html.exe
executable tomd2html
.
That's bad indeed.
However I tend to say this should be handled by CMake better. I don't think that maintaining extra branch of the install commands for that platform is a scalable solution and it could maybe break if CMake fixes it (it would be even worse to generate md2html.exe.exe
if/when that happens).
Taking these arguments together, maybe the aforementioned disabling of the install command on Windows is the right step.
I wonder if you could do something like:
if(WIN32)
option(MD2HTML_EXE "" "md2html.exe")
else()
option(MD2HTML_EXE "" "md2html")
endif()
I'm not that familiar with CMake, but I'm trying to learn it better because I want to use it in my projects.
I might try some things out tomorrow if I have time. I'll let you know if I find anything that seems like it might be a solution.
...that's also the reason why on Windows we by default build only static lib...
That reminds me of something else I found interesting. When I was using the native Win32 CMake executable downloaded from their site, it would build the static lib by default. But using the one from MSYS2's package manager, it built the dll. So I'm wondering if WIN32 is not defined in theirs. That might be something I need to report to the MSYS2 devs.
I wonder if you could do something like:
if(WIN32) option(MD2HTML_EXE "" "md2html.exe") else() option(MD2HTML_EXE "" "md2html") endif()
I believe CMake tries to do something pretty close to that on its own via CMAKE_EXECUTABLE_SUFFIX. But it can likely fail for the strange MSYS2 platform which is sort of a hybrid between WIN32 and POSIX.
I am not using MSYS2 (I still stick to the pretty old MSYS env. instead). But AFAIK MSYS2 is kind of a "dual" platform. With some gcc toolchain you may build native Windows binaries, and with another one you may build MSYS2 binaries which do all sorts of Windows <--> Unix path translations, supports fork()
etc.
If it is so then it's questionable what CMake can do there because both defining WIN32
as well as not defining it is (partially) wrong there. CMake probably even does not have any knowledge which of the toolchains you are using. Maybe you can even mix building both kinds of binaries in a single CMake recipe file.
Also see this: http://cmake.3232098.n2.nabble.com/CMake-support-for-MYS2-td7596911.html
It seems there are cmake
and mingw-w64-x86_64-cmake
(or i686) packages. If I understand it correctly, the former is for building for the MSYS2 system itself, while the other one should build native Windows binaries.
So I would guess the former does not define WIN32
and the other one does (or should).
Which one do you have installed in your MSYS2 environment?
Currently, I am using the MSYS2 package (cmake
). The mingw-w64-x86_64-cmake
appears to be broken. :-\
I also found this commit message for Cygwin: https://gitlab.kitware.com/cmake/cmake/commit/85c0a69a92e78275ea0b180482bafcdb877b0dc3
I though you told me that MSYS2 is actually a fork of Cygwin, but maybe I read it somewhere else. That would explain the missing WIN32
definition. I'll try to get the mingw-w64-x86_64-cmake
package working & see if behavior is normal.
--- Edit ---
Turns out the cmake build wasn't broken, I just had a dependency version incompatibility. So, using the mingw-w64-x86_64-cmake
version works the same as downloadable executable from CMake's website. I have to use the patch I mentioned about, but it doesn't strip the .exe suffix.
Ok. That sounds better. So we have just one problem.
Wouldn't the following work? Could you please check it in MSYS2?
-install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/md2html DESTINATION ${CMAKE_INSTALL_BINDIR})
+install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/md2html${CMAKE_EXECUTABLE_SUFFIX} DESTINATION ${CMAKE_INSTALL_BINDIR})
Because if yes, then it should work everywhere.
Okay. I will have to wait until tomorrow to try it.
Ohh. Never mind. For some reason it was using INSTALL(PROGRAMS)
instead of INSTALL(TARGETS)
commands. The latter should do all of the required stuff on its own.
Feel free to reopen if you find out it is still not working but I would be really quite surprised.
Sorry I haven't responded, been busy with some things. I'll let you know when I get a chance to try & rebuild again. But, looks like you already fixed it.
Just tested from commit ae5ca89. It's working. Thank you.
Thanks for testing it.
md4c version: 0.3.4 CMake info:
I think this error is more a bug in CMake, but I thought you should be aware.
I use the MSYS2/MinGW environment for building on Win32. If I use MSYS2's CMake package, I have no problems. But, If I use the "native" CMake executable from CMake's website, I get the following error:
CMake's "native" build doesn't recognize the
md2html
executable if the extension.exe
isn't explicitly declared.I use the following patch to get past the issue:
But obviously, that makes building only work on Windows.
Again, this is probably more of a bug with CMake. Not sure if there would be a way to test whether or not the CMake executable needs an explicit
.exe
declaration.--- Edit ---
I just noticed another issue related to this. If I am using the CMake version from MSYS2's package manager, calling
make install
renamesmd2html.exe
executable tomd2html
.