flavorjones / mini_portile

mini_portile and mini_portile2 - Simple autoconf and cmake builder for developers
MIT License
114 stars 51 forks source link

[cmake] Make it possible to override default cmake options #127

Closed stanhu closed 1 year ago

stanhu commented 1 year ago

While working on https://github.com/mudge/re2/pull/67, I found that the default cmake generator option for Windows builds did not work for the abseil-cpp project:

# docker run -it -v $(pwd):/build ghcr.io/rake-compiler/rake-compiler-dock-image:1.3.0-mri-x64-mingw-ucrt bash
root@2cf282c35cc8:/tmp# git clone --depth 1 https://github.com/abseil/abseil-cpp.git
Cloning into 'abseil-cpp'...
remote: Enumerating objects: 1438, done.
remote: Counting objects: 100% (1438/1438), done.
remote: Compressing objects: 100% (1159/1159), done.
remote: Total 1438 (delta 401), reused 527 (delta 275), pack-reused 0
Receiving objects: 100% (1438/1438), 2.49 MiB | 7.43 MiB/s, done.
Resolving deltas: 100% (401/401), done.
 root@2cf282c35cc8:/tmp# cd abseil-cpp/
root@2cf282c35cc8:/tmp/abseil-cpp# mkdir build
root@2cf282c35cc8:/tmp/abseil-cpp# cd build
root@2cf282c35cc8:/tmp/abseil-cpp/build# cmake .. -G 'MSYS Makefiles'
CMake Error: Could not create named generator MSYS Makefiles

Generators
* Unix Makefiles               = Generates standard UNIX makefiles.
  Green Hills MULTI            = Generates Green Hills MULTI files
                                 (experimental, work-in-progress).
  Ninja                        = Generates build.ninja files.
  Watcom WMake                 = Generates Watcom WMake makefiles.
  CodeBlocks - Ninja           = Generates CodeBlocks project files.
  CodeBlocks - Unix Makefiles  = Generates CodeBlocks project files.
  CodeLite - Ninja             = Generates CodeLite project files.
  CodeLite - Unix Makefiles    = Generates CodeLite project files.
  Sublime Text 2 - Ninja       = Generates Sublime Text 2 project files.
  Sublime Text 2 - Unix Makefiles
                               = Generates Sublime Text 2 project files.
  Kate - Ninja                 = Generates Kate project files.
  Kate - Unix Makefiles        = Generates Kate project files.
  Eclipse CDT4 - Ninja         = Generates Eclipse CDT 4.0 project files.
  Eclipse CDT4 - Unix Makefiles= Generates Eclipse CDT 4.0 project files.

I worked around the problem by pruning the -G option from configure_options, but it'd be nice to make it easier to skip this.

flavorjones commented 1 year ago

Ack. CMake is still "experimental" and you may be the first person to really try to use it for something. Will take a look, but prioritizing it behind some other work at the moment.

stanhu commented 1 year ago

It seems that https://github.com/flavorjones/mini_portile/blob/5084a2aeab12076f534cf0cabc81a4d5f84b5c25/lib/mini_portile2/mini_portile_cmake.rb#L17 isn't needed when cross-compiling in Linux, but the flag is needed in Windows.