From b5e25391beece55da27777af6bb81b877f77da52 Mon Sep 17 00:00:00 2001 From: Xpol Wan Date: Wed, 18 Mar 2015 15:20:37 +0800 Subject: Better cmake support. 1. Let cmake choose the generator. 2. use `cmake --build` to build without needs of make (nmake mingwin-make ...) --- src/luarocks/build/cmake.lua | 14 +++++++------- src/luarocks/cfg.lua | 9 +++------ 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/luarocks/build/cmake.lua b/src/luarocks/build/cmake.lua index ed2af3ff..5891cda9 100644 --- a/src/luarocks/build/cmake.lua +++ b/src/luarocks/build/cmake.lua @@ -15,7 +15,7 @@ function cmake.run(rockspec) assert(type(rockspec) == "table") local build = rockspec.build local variables = build.variables or {} - + -- Pass Env variables variables.CMAKE_MODULE_PATH=os.getenv("CMAKE_MODULE_PATH") variables.CMAKE_LIBRARY_PATH=os.getenv("CMAKE_LIBRARY_PATH") @@ -26,7 +26,7 @@ function cmake.run(rockspec) if not fs.execute_quiet(rockspec.variables.CMAKE, "--help") then return nil, "'"..rockspec.variables.CMAKE.."' program not found. Is cmake installed? You may want to edit variables.CMAKE" end - + -- If inline cmake is present create CMakeLists.txt from it. if type(build.cmake) == "string" then local cmake_handler = assert(io.open(fs.current_dir().."/CMakeLists.txt", "w")) @@ -38,21 +38,21 @@ function cmake.run(rockspec) -- Execute cmake with variables. local args = "" if cfg.cmake_generator then - args = args .. ' -G"'..cfg.cmake_generator.. '"' + --args = args .. ' -G"'..cfg.cmake_generator.. '"' end for k,v in pairs(variables) do args = args .. ' -D' ..k.. '="' ..v.. '"' end - if not fs.execute_string(rockspec.variables.CMAKE.." . " ..args) then + if not fs.execute_string(rockspec.variables.CMAKE.." -H. -Bbuild.luarocks "..args) then return nil, "Failed cmake." end - - if not fs.execute_string(rockspec.variables.MAKE.." -fMakefile") then + + if not fs.execute_string(rockspec.variables.CMAKE.." --build build.luarocks --config Release") then return nil, "Failed building." end - if not fs.execute_string(rockspec.variables.MAKE.." -fMakefile install") then + if not fs.execute_string(rockspec.variables.CMAKE.." --build build.luarocks --target install --config Release") then return nil, "Failed installing." end return true diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua index 50d247b5..ea80e5b5 100644 --- a/src/luarocks/cfg.lua +++ b/src/luarocks/cfg.lua @@ -227,7 +227,7 @@ local defaults = { } }, disabled_servers = {}, - + upload = { server = "https://rocks.moonscript.org", tool_version = "1.0.0", @@ -315,7 +315,7 @@ if detected.windows then defaults.variables.LUA_BINDIR = site_config.LUA_BINDIR and site_config.LUA_BINDIR:gsub("\\", "/") or "c:/lua"..cfg.lua_version.."/bin" defaults.variables.LUA_INCDIR = site_config.LUA_INCDIR and site_config.LUA_INCDIR:gsub("\\", "/") or "c:/lua"..cfg.lua_version.."/include" defaults.variables.LUA_LIBDIR = site_config.LUA_LIBDIR and site_config.LUA_LIBDIR:gsub("\\", "/") or "c:/lua"..cfg.lua_version.."/lib" - defaults.cmake_generator = "MinGW Makefiles" + defaults.makefile = "Makefile.win" defaults.variables.MAKE = "nmake" defaults.variables.CC = "cl" @@ -363,7 +363,6 @@ end if detected.mingw32 then defaults.platforms = { "win32", "mingw32", "windows" } defaults.obj_extension = "o" - defaults.cmake_generator = "MinGW Makefiles" defaults.variables.MAKE = "mingw32-make" defaults.variables.CC = "mingw32-gcc" defaults.variables.RC = "windres" @@ -394,7 +393,6 @@ if detected.unix then defaults.variables.LUA_INCDIR = site_config.LUA_INCDIR or "/usr/local/include" defaults.variables.LUA_LIBDIR = site_config.LUA_LIBDIR or "/usr/local/lib" defaults.variables.CFLAGS = "-O2" - defaults.cmake_generator = "Unix Makefiles" defaults.platforms = { "unix" } defaults.variables.CC = "gcc" defaults.variables.LD = "gcc" @@ -426,7 +424,6 @@ if detected.cygwin then defaults.lib_extension = "so" -- can be overridden in the config file for mingw builds defaults.arch = "cygwin-"..proc defaults.platforms = {"unix", "cygwin"} - defaults.cmake_generator = "Unix Makefiles" defaults.variables.CC = "echo -llua | xargs gcc" defaults.variables.LD = "echo -llua | xargs gcc" defaults.variables.LIBFLAG = "-shared" @@ -569,7 +566,7 @@ function cfg.package_paths() table.insert(new_cpath, lib_path.."/?."..cfg.lib_extension) table.insert(new_bin, bin_path) end - if extra_luarocks_module_dir then + if extra_luarocks_module_dir then table.insert(new_path, extra_luarocks_module_dir) end return table.concat(new_path, ";"), table.concat(new_cpath, ";"), table.concat(new_bin, cfg.export_path_separator) -- cgit v1.2.3-55-g6feb