From f61e5a22d7d76561cfb10a8d83e14e324d2a772a Mon Sep 17 00:00:00 2001 From: Ignacio Burgueño Date: Mon, 8 Jun 2015 12:19:11 -0300 Subject: cmake backend: Generate 64 bits build when appropiate Adds -DCMAKE_GENERATOR_PLATFORM=x64 when needed. It seems that CMake does not do that by default (although I might be wrong on that). fixes #382 --- src/luarocks/build/cmake.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/luarocks/build/cmake.lua b/src/luarocks/build/cmake.lua index c8f5a669..a1c08dfa 100644 --- a/src/luarocks/build/cmake.lua +++ b/src/luarocks/build/cmake.lua @@ -35,7 +35,6 @@ function cmake.run(rockspec) cmake_handler:close() end - -- Execute cmake with variables. local args = "" if cfg.cmake_generator then @@ -45,6 +44,11 @@ function cmake.run(rockspec) args = args .. ' -D' ..k.. '="' ..v.. '"' end + -- Generate 64 bit build if appropiate. + if not not cfg.arch:match("%-x86_64$") then + args = args .. " -DCMAKE_GENERATOR_PLATFORM=x64" + end + if not fs.execute_string(rockspec.variables.CMAKE.." -H. -Bbuild.luarocks "..args) then return nil, "Failed cmake." end -- cgit v1.2.3-55-g6feb From b3a4e889dc3f06e83a299096710406920f18cd51 Mon Sep 17 00:00:00 2001 From: Ignacio Burgue o Date: Wed, 17 Jun 2015 09:54:07 -0300 Subject: CMake needs a hint to use 64 bit target with msvc. Only when using Windows 64 bits and the msvc compiler. CMake uses the x86 generator by default. We need to tell it explicitly that we wan't to use the x64 generator. refs #382 --- src/luarocks/build/cmake.lua | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/luarocks/build/cmake.lua b/src/luarocks/build/cmake.lua index a1c08dfa..3d0f22a2 100644 --- a/src/luarocks/build/cmake.lua +++ b/src/luarocks/build/cmake.lua @@ -37,16 +37,16 @@ function cmake.run(rockspec) -- Execute cmake with variables. local args = "" - if cfg.cmake_generator then + + -- Try to pick the best generator. With msvc and x64, CMake does not select it by default so we need to be explicit. + if cfg.is_platform("mingw32") and cfg.cmake_generator then args = args .. ' -G"'..cfg.cmake_generator.. '"' - end - for k,v in pairs(variables) do - args = args .. ' -D' ..k.. '="' ..v.. '"' + elseif cfg.is_platform("windows") and cfg.arch:match("%-x86_64$") then + args = args .. " -DCMAKE_GENERATOR_PLATFORM=x64" end - -- Generate 64 bit build if appropiate. - if not not cfg.arch:match("%-x86_64$") then - args = args .. " -DCMAKE_GENERATOR_PLATFORM=x64" + for k,v in pairs(variables) do + args = args .. ' -D' ..k.. '="' ..tostring(v).. '"' end if not fs.execute_string(rockspec.variables.CMAKE.." -H. -Bbuild.luarocks "..args) then -- cgit v1.2.3-55-g6feb From 797b95f830c7a2fbd886e74ff7b441fbc41b0701 Mon Sep 17 00:00:00 2001 From: Ignacio Burgueño Date: Wed, 24 Jun 2015 15:44:52 -0300 Subject: Use new key target_cpu --- src/luarocks/build/cmake.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/luarocks/build/cmake.lua b/src/luarocks/build/cmake.lua index 3d0f22a2..22ee2cde 100644 --- a/src/luarocks/build/cmake.lua +++ b/src/luarocks/build/cmake.lua @@ -41,7 +41,7 @@ function cmake.run(rockspec) -- Try to pick the best generator. With msvc and x64, CMake does not select it by default so we need to be explicit. if cfg.is_platform("mingw32") and cfg.cmake_generator then args = args .. ' -G"'..cfg.cmake_generator.. '"' - elseif cfg.is_platform("windows") and cfg.arch:match("%-x86_64$") then + elseif cfg.is_platform("windows") and cfg.target_cpu:match("x86_64$") then args = args .. " -DCMAKE_GENERATOR_PLATFORM=x64" end -- cgit v1.2.3-55-g6feb From 79ffabfb806ff608db0cb9356627c61889b73284 Mon Sep 17 00:00:00 2001 From: Ignacio Burgueño Date: Thu, 25 Jun 2015 11:22:34 -0300 Subject: Don't restrict the generator override to mingw --- src/luarocks/build/cmake.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/luarocks/build/cmake.lua b/src/luarocks/build/cmake.lua index 22ee2cde..7b16fa51 100644 --- a/src/luarocks/build/cmake.lua +++ b/src/luarocks/build/cmake.lua @@ -39,7 +39,7 @@ function cmake.run(rockspec) local args = "" -- Try to pick the best generator. With msvc and x64, CMake does not select it by default so we need to be explicit. - if cfg.is_platform("mingw32") and cfg.cmake_generator then + if cfg.cmake_generator then args = args .. ' -G"'..cfg.cmake_generator.. '"' elseif cfg.is_platform("windows") and cfg.target_cpu:match("x86_64$") then args = args .. " -DCMAKE_GENERATOR_PLATFORM=x64" -- cgit v1.2.3-55-g6feb