Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using CMake to build the rocks #115

Open
Ark-kun opened this issue May 8, 2016 · 5 comments
Open

Using CMake to build the rocks #115

Ark-kun opened this issue May 8, 2016 · 5 comments

Comments

@Ark-kun
Copy link

Ark-kun commented May 8, 2016

CMake is already used by many rocks to generate the Makefile.
I want to modify the rockspec files to also build and install the code via cmake as opposed to make.
CMake already knows how to properly invoke the chosen make program and we should use this ability to improve the cross-platform, compatibility. For example, on Windows with Visual Studio installed, CMake generates msbuild projects by default. luarocks then tries to build them using nmake and fails. CMake on the other hand should handle all builds properly.

What I propose:
In all .rockspec files I want to replace
$(MAKE) => cmake --build . --config release
$(MAKE) install => cmake --build . --config release --target install

What's the best way for me to handle this? Should I go to each rock's repository and submit PR for the .rockspec?

@soumith
Copy link
Member

soumith commented Jun 6, 2016

this sounds okay to me. it's going to be a bit tedious for you to modify each package's rockspec but that's the only way forward, looks like it.

@hishamhm
Copy link

hishamhm commented Jul 9, 2016

Note that LuaRocks includes built-in support for cmake, so it accepts build.type = "cmake" and can construct these commands automatically. So your rockspecs will probably become shorter. :)

@soumith
Copy link
Member

soumith commented Jul 9, 2016

But from the last time I looked (year-ish ago), luarocks-cmake didn't have the ability to do builds in a separate build folder. That's the reason I think we do it this way.

@hishamhm
Copy link

hishamhm commented Jul 9, 2016

You mean passing --build? (I'm not a CMake user myself) It seems to me it currently does:
https://github.com/keplerproject/luarocks/blob/master/src/luarocks/build/cmake.lua

@howard0su
Copy link
Contributor

howard0su commented Nov 1, 2016

Current luarocks didn't do exact same thing as most rockspec is doing. one common example is the below. this is very common pattern in many rocks files. It will be great to replace this with type='cmake'. A big advantage is bringing windows support for those rocks.

type = "command",
build_command = [[
cmake -E make_directory build;
cd build;
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="$(LUA_BINDIR)/.." -DCMAKE_INSTALL_PREFIX="$(PREFIX)";
$(MAKE)
]],
install_command = "cd build && $(MAKE) install"

the above section should be replaced by this:
type = "cmake",
variables = {
CMAKE_BUILD_TYPE="Release",
CMAKE_PREFIX_PATH="$(LUA_BINDIR)/..",
CMAKE_INSTALL_PREFIX="$(PREFIX)"
}

This will touch many many files. are u okay with that? @soumith

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants