Skip to content

Commit

Permalink
made TH standalone installation more flexible
Browse files Browse the repository at this point in the history
  • Loading branch information
andresy committed Apr 11, 2014
1 parent 0cd98d7 commit f4b37a6
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 18 deletions.
2 changes: 1 addition & 1 deletion cmake/TorchExports.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
INSTALL(EXPORT torch-exports
INSTALL(EXPORT TH-exports
DESTINATION "${Torch_INSTALL_CMAKE_SUBDIR}"
FILE "TorchExports.cmake")

Expand Down
5 changes: 5 additions & 0 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
SET(TH_INSTALL_BIN_SUBDIR "${Torch_INSTALL_BIN_SUBDIR}")
SET(TH_INSTALL_LIB_SUBDIR "${Torch_INSTALL_LIB_SUBDIR}")
SET(TH_INSTALL_INCLUDE_SUBDIR "${Torch_INSTALL_INCLUDE_SUBDIR}")
SET(TH_INSTALL_CMAKE_SUBDIR "${Torch_INSTALL_CMAKE_SUBDIR}")

ADD_SUBDIRECTORY(TH)
ADD_SUBDIRECTORY(luaT)
38 changes: 21 additions & 17 deletions lib/TH/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@ cmake_minimum_required(VERSION 2.6)

SET(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})

# Can be compiled without being a torch sub-project
IF(NOT Torch_INSTALL_BIN_SUBDIR)
SET(Torch_INSTALL_BIN_SUBDIR "bin")
SET(Torch_INSTALL_LIB_SUBDIR "lib")
SET(Torch_INSTALL_INCLUDE_SUBDIR "include")
SET(Torch_INSTALL_CMAKE_SUBDIR "share/cmake/torch")
# Can be compiled standalone
IF(NOT TH_INSTALL_BIN_SUBDIR
OR NOT TH_INSTALL_LIB_SUBDIR
OR NOT TH_INSTALL_INCLUDE_SUBDIR
OR NOT TH_INSTALL_CMAKE_SUBDIR)

SET(TH_INSTALL_BIN_SUBDIR "bin" CACHE PATH "TH install binary subdirectory")
SET(TH_INSTALL_LIB_SUBDIR "lib" CACHE PATH "TH install library subdirectory")
SET(TH_INSTALL_INCLUDE_SUBDIR "include" CACHE PATH "TH install include subdirectory")
SET(TH_INSTALL_CMAKE_SUBDIR "share/cmake/TH" CACHE PATH "TH install cmake subdirectory")
ENDIF()

# flags
Expand Down Expand Up @@ -159,10 +163,10 @@ INCLUDE_DIRECTORIES("${CMAKE_CURRENT_BINARY_DIR}")
CONFIGURE_FILE(THGeneral.h.in "${CMAKE_CURRENT_BINARY_DIR}/THGeneral.h")

INSTALL(TARGETS TH
EXPORT torch-exports
RUNTIME DESTINATION "${Torch_INSTALL_BIN_SUBDIR}"
LIBRARY DESTINATION "${Torch_INSTALL_LIB_SUBDIR}"
ARCHIVE DESTINATION "${Torch_INSTALL_LIB_SUBDIR}")
EXPORT TH-exports
RUNTIME DESTINATION "${TH_INSTALL_BIN_SUBDIR}"
LIBRARY DESTINATION "${TH_INSTALL_LIB_SUBDIR}"
ARCHIVE DESTINATION "${TH_INSTALL_LIB_SUBDIR}")

INSTALL(FILES
TH.h
Expand All @@ -185,7 +189,7 @@ INSTALL(FILES
THTensorDimApply.h
THTensorMacros.h
THVector.h
DESTINATION "${Torch_INSTALL_INCLUDE_SUBDIR}/TH")
DESTINATION "${TH_INSTALL_INCLUDE_SUBDIR}/TH")

INSTALL(FILES
generic/THBlas.c
Expand All @@ -209,20 +213,20 @@ INSTALL(FILES
generic/THTensorRandom.c
generic/THTensorRandom.h
generic/THVector.c
DESTINATION "${Torch_INSTALL_INCLUDE_SUBDIR}/TH/generic")
DESTINATION "${TH_INSTALL_INCLUDE_SUBDIR}/TH/generic")


IF (WIN32 AND NOT CYGWIN)
SET(BLAS_INSTALL_LIBRARIES "OFF"
CACHE BOOL "Copy the required BLAS DLLs into the Torch install dirs")
CACHE BOOL "Copy the required BLAS DLLs into the TH install dirs")
ENDIF (WIN32 AND NOT CYGWIN)

MACRO(Install_Required_Library ln)
get_filename_component(libpath ${ln} PATH)
get_filename_component(libname ${ln} NAME_WE)
file(GLOB libdlls "${libpath}/${libname}*.dll")
install(PROGRAMS ${libdlls}
DESTINATION "${Torch_INSTALL_BIN_SUBDIR}")
DESTINATION "${TH_INSTALL_BIN_SUBDIR}")
ENDMACRO(Install_Required_Library libname)

IF (BLAS_FOUND AND BLAS_INSTALL_LIBRARIES)
Expand All @@ -244,8 +248,8 @@ ENDIF()
# Create THConfig.cmake
GET_TARGET_PROPERTY(TH_OUTPUT_NAME TH LOCATION)
GET_FILENAME_COMPONENT(TH_OUTPUT_NAME ${TH_OUTPUT_NAME} NAME)
SET(TH_LIBRARIES "${Torch_INSTALL_LIB}/${TH_OUTPUT_NAME}")
SET(TH_INCLUDE_DIR "${Torch_INSTALL_INCLUDE}/TH")
SET(TH_LIBRARIES "${CMAKE_INSTALL_PREFIX}/${TH_INSTALL_LIB_SUBDIR}/${TH_OUTPUT_NAME}")
SET(TH_INCLUDE_DIR "${CMAKE_INSTALL_PREFIX}/${TH_INSTALL_INCLUDE_SUBDIR}/TH")
CONFIGURE_FILE(THConfig.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/cmake-exports/THConfig.cmake")
INSTALL(FILES "${CMAKE_CURRENT_BINARY_DIR}/cmake-exports/THConfig.cmake"
DESTINATION "${Torch_INSTALL_CMAKE_SUBDIR}")
DESTINATION "${TH_INSTALL_CMAKE_SUBDIR}")

0 comments on commit f4b37a6

Please sign in to comment.