Skip to content

Commit

Permalink
Merge pull request torch#245 from zakattacktwitter/ztaylor/static_lib
Browse files Browse the repository at this point in the history
Adding support for a static build of torch.
  • Loading branch information
soumith committed May 27, 2015
2 parents 4af3663 + 9f3f709 commit 0656455
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion cmake/TorchPackage.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ MACRO(ADD_TORCH_PACKAGE package src luasrc)
IF(src)

ADD_LIBRARY(${package} MODULE ${src})

ADD_LIBRARY(${package}_static STATIC ${src})

### Torch packages supposes libraries prefix is "lib"
SET_TARGET_PROPERTIES(${package} PROPERTIES
PREFIX "lib"
Expand Down
1 change: 1 addition & 0 deletions lib/TH/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ SET(src

SET(src ${src} ${hdr})
ADD_LIBRARY(TH SHARED ${src})
ADD_LIBRARY(TH_static STATIC ${src})

CHECK_C_SOURCE_RUNS("
#include <stdatomic.h>
Expand Down
1 change: 1 addition & 0 deletions lib/luaT/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ IF(LUALIB)
ENDIF()

ADD_LIBRARY(luaT SHARED luaT.h luaT.c)
ADD_LIBRARY(luaT_static STATIC luaT.h luaT.c)

IF(APPLE)
SET_TARGET_PROPERTIES(luaT PROPERTIES
Expand Down
2 changes: 1 addition & 1 deletion rocks/torch-scm-1.rockspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ dependencies = {
build = {
type = "command",
build_command = [[
cmake -E make_directory build && cd build && cmake .. -DCMAKE_BUILD_TYPE=Release -DLUA=$(LUA) -DLUALIB=$(LUALIB) -DLUA_BINDIR="$(LUA_BINDIR)" -DLUA_INCDIR="$(LUA_INCDIR)" -DLUA_LIBDIR="$(LUA_LIBDIR)" -DLUADIR="$(LUADIR)" -DLIBDIR="$(LIBDIR)" -DCMAKE_INSTALL_PREFIX="$(PREFIX)" && $(MAKE)
cmake -E make_directory build && cd build && cmake .. -DCMAKE_BUILD_TYPE=Release -DLUA=$(LUA) -DLUALIB=$(LUALIB) -DLUA_BINDIR="$(LUA_BINDIR)" -DLUA_INCDIR="$(LUA_INCDIR)" -DLUA_LIBDIR="$(LUA_LIBDIR)" -DLUADIR="$(LUADIR)" -DLIBDIR="$(LIBDIR)" -DCMAKE_INSTALL_PREFIX="$(PREFIX)" -DCMAKE_C_FLAGS=-fPIC -DCMAKE_CXX_FLAGS=-fPIC && $(MAKE)
]],
install_command = "cd build && $(MAKE) install"
}

0 comments on commit 0656455

Please sign in to comment.