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

fix cmake install subdir #634

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ INCLUDE_DIRECTORIES("${CMAKE_CURRENT_SOURCE_DIR}/torch")
SET(src Storage.c init.c Tensor.c TensorMath.c TensorOperator.c torch/utils.c)
SET(luasrc init.lua Tensor.lua FFI.lua test/test.lua)

set(CMAKE_REQUIRED_INCLUDES ${LUA_INCDIR})
set(CMAKE_REQUIRED_INCLUDES ${LUA_INCDIR})
set(CMAKE_REQUIRED_LIBRARIES ${LUA_LIBDIR}/${LUALIB})
include(CheckCSourceCompiles)
check_c_source_compiles("
#include <lauxlib.h>
Expand Down
5 changes: 5 additions & 0 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
SET(THC_INSTALL_BIN_SUBDIR "${Torch_INSTALL_BIN_SUBDIR}")
SET(THC_INSTALL_LIB_SUBDIR "${Torch_INSTALL_LIB_SUBDIR}")
SET(THC_INSTALL_INCLUDE_SUBDIR "${Torch_INSTALL_INCLUDE_SUBDIR}")
SET(THC_INSTALL_CMAKE_SUBDIR "${Torch_INSTALL_CMAKE_SUBDIR}")

ADD_SUBDIRECTORY(THC)
29 changes: 13 additions & 16 deletions lib/THC/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@ IF(APPLE)
# CUDA 7 supports clang and libc++ so no need to change anything
ENDIF(APPLE)

# When using MSVC
IF(MSVC)
# dll export flag
ADD_DEFINITIONS(-DTHC_EXPORTS=1)
ENDIF(MSVC)

# Detect CUDA architecture and get best NVCC flags
IF(NOT COMMAND CUDA_SELECT_NVCC_ARCH_FLAGS OR MSVC)
INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/cmake/select_compute_arch.cmake)
Expand All @@ -126,24 +132,15 @@ IF(NOT THC_INSTALL_BIN_SUBDIR
OR NOT THC_INSTALL_INCLUDE_SUBDIR
OR NOT THC_INSTALL_CMAKE_SUBDIR)

INCLUDE_DIRECTORIES(${TH_INCLUDE_PATH} ${TH_INCLUDE_PATH}/TH)
LINK_DIRECTORIES(${TH_LIB_PATH})

IF(Torch_INSTALL_BIN_SUBDIR)
SET(THC_INSTALL_BIN_SUBDIR ${Torch_INSTALL_BIN_SUBDIR})
SET(THC_INSTALL_LIB_SUBDIR ${Torch_INSTALL_LIB_SUBDIR})
SET(THC_INSTALL_INCLUDE_SUBDIR ${Torch_INSTALL_INCLUDE_SUBDIR})
SET(THC_INSTALL_CMAKE_SUBDIR ${Torch_INSTALL_CMAKE_SUBDIR})
ELSE(Torch_INSTALL_BIN_SUBDIR)
# not installing in a Torch context, so Torch_INSTALL_BIN_SUBDIR is not available
SET(THC_INSTALL_BIN_SUBDIR "bin" CACHE PATH "THC install binary subdirectory")
SET(THC_INSTALL_LIB_SUBDIR "lib" CACHE PATH "THC install library subdirectory")
SET(THC_INSTALL_INCLUDE_SUBDIR "include" CACHE PATH "THC install include subdirectory")
SET(THC_INSTALL_CMAKE_SUBDIR "share/cmake/THC" CACHE PATH "THC install cmake subdirectory")
ENDIF(Torch_INSTALL_BIN_SUBDIR)

SET(THC_INSTALL_BIN_SUBDIR "bin" CACHE PATH "THC install binary subdirectory")
SET(THC_INSTALL_LIB_SUBDIR "lib" CACHE PATH "THC install library subdirectory")
SET(THC_INSTALL_INCLUDE_SUBDIR "include" CACHE PATH "THC install include subdirectory")
SET(THC_INSTALL_CMAKE_SUBDIR "share/cmake/THC" CACHE PATH "THC install cmake subdirectory")
ENDIF()

INCLUDE_DIRECTORIES(${TH_INCLUDE_PATH} ${TH_INCLUDE_PATH}/TH)
LINK_DIRECTORIES(${TH_LIB_PATH})

INCLUDE_DIRECTORIES("${CMAKE_CURRENT_SOURCE_DIR}")
INCLUDE_DIRECTORIES("${CMAKE_CURRENT_BINARY_DIR}")
CONFIGURE_FILE(THCGeneral.h.in "${CMAKE_CURRENT_BINARY_DIR}/THCGeneral.h")
Expand Down
10 changes: 5 additions & 5 deletions rocks/cutorch-scm-1.rockspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ package = "cutorch"
version = "scm-1"

source = {
url = "git://github.com/torch/cutorch.git",
url = "git://github.com/elikosan/cutorch.git",
}

description = {
summary = "Torch CUDA Implementation",
detailed = [[
]],
homepage = "https://github.com/torch/cutorch",
homepage = "https://github.com/elikosan/cutorch",
license = "BSD"
}

Expand All @@ -23,13 +23,13 @@ build = {

jopts=$(getconf _NPROCESSORS_CONF)

echo "Building on $jopts cores"
cmake -E make_directory build && cd build && cmake .. -DLUALIB=$(LUALIB) -DLUA_INCDIR=$(LUA_INCDIR) -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS} -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="$(LUA_BINDIR)/.." -DCMAKE_INSTALL_PREFIX="$(PREFIX)" && $(MAKE) -j$jopts install
echo "Building on $(jopts) cores"
cmake -E make_directory build && cd build && cmake .. -DLUALIB="$(LUALIB)" -DLUA_INCDIR="$(LUA_INCDIR)" -DCMAKE_CXX_FLAGS="$(CMAKE_CXX_FLAGS)" -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="$(LUA_BINDIR)/.." -DCMAKE_INSTALL_PREFIX="$(PREFIX)" && $(MAKE) -j$jopts install
]],
platforms = {
windows = {
build_command = [[
cmake -E make_directory build && cd build && cmake .. -DLUALIB=$(LUALIB) -DLUA_INCDIR=$(LUA_INCDIR) -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="$(LUA_BINDIR)/.." -DCMAKE_INSTALL_PREFIX="$(PREFIX)" && $(MAKE) install
cmake -E make_directory build && cd build && cmake .. -DLUALIB="" -DLUA_INCDIR="$(LUA_INCDIR)" -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="$(LUA_BINDIR)/.." -DCMAKE_INSTALL_PREFIX="$(PREFIX)" && $(MAKE) install
]]
}
},
Expand Down