Skip to content

Commit

Permalink
Add building and installation configurations
Browse files Browse the repository at this point in the history
  • Loading branch information
shehzan10 committed Dec 23, 2015
1 parent 47be094 commit 4779dc6
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 33 deletions.
19 changes: 17 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(ArrayFire-Lua-Wrapper)
PROJECT(ArrayFire-Lua)

SET_PROPERTY(GLOBAL PROPERTY USE_FOLDERS ON)

OPTION(USE_LOCAL_LUA "Build Lua as external project" OFF)

SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules")

INCLUDE(${CMAKE_MODULE_PATH}/build_lua.cmake)
ADD_SUBDIRECTORY(wrapper/Lua)

########################################
# Installation
########################################
INSTALL(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/examples/"
DESTINATION "examples"
COMPONENT examples)

INSTALL(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/wrapper/arrayfire/"
DESTINATION "arrayfire"
COMPONENT scripts)
20 changes: 19 additions & 1 deletion CMakeModules/build_lua.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ ExternalProject_Add(
-DCMAKE_SOURCE_DIR:PATH=<SOURCE_DIR>
-DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER}
-DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER}
-DCMAKE_CXX_FLAGS:STRING=${CMAKE_CXX_FLAGS}
-DCMAKE_C_FLAGS:STRING=${CMAKE_C_FLAGS}
-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
-DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
-DBUILD_SHARED_LIBS=OFF
Expand All @@ -36,6 +38,22 @@ ExternalProject_Get_Property(lua-ext install_dir)
ADD_LIBRARY(lua IMPORTED STATIC)
SET_TARGET_PROPERTIES(lua PROPERTIES IMPORTED_LOCATION ${lua_location})
ADD_DEPENDENCIES(lua lua-ext)
SET(LUA_INCLUDE_DIRECTORIES ${install_dir}/include)
SET(LUA_INCLUDE_DIR ${install_dir}/include)
SET(LUA_LIBRARIES lua)
SET(LUA_FOUND ON)

########################################
# Installation
########################################
INSTALL(DIRECTORY "${prefix}/bin"
DESTINATION "lua/"
USE_SOURCE_PERMISSIONS
COMPONENT lua_bin)
INSTALL(DIRECTORY "${prefix}/lib"
DESTINATION "lua/"
USE_SOURCE_PERMISSIONS
COMPONENT lua_lib)
INSTALL(DIRECTORY "${prefix}/include"
DESTINATION "lua/"
USE_SOURCE_PERMISSIONS
COMPONENT lua_include)
72 changes: 42 additions & 30 deletions wrapper/Lua/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,50 +1,55 @@
cmake_minimum_required(VERSION 2.8)
SET(AF_LUA_VERSION_MAJOR 0)
SET(AF_LUA_VERSION 0)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(ArrayFire_Lib)

SET_PROPERTY(GLOBAL PROPERTY USE_FOLDERS ON)
FIND_PACKAGE(ArrayFire REQUIRED)
FIND_PACKAGE(Lua REQUIRED)

# OS Definitions
IF(UNIX)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -pthread -Wno-comment")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -pthread -Wno-comment")
ADD_DEFINITIONS(-Wall -std=c++11 -fvisibility=hidden)
ELSE() #Windows
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /bigobj")
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /bigobj")
ENDIF()

FIND_PACKAGE(Lua QUIET)
IF(USE_LOCAL_LUA OR NOT LUA_FOUND)
SET(USE_LOCAL_LUA ON)
INCLUDE(${CMAKE_MODULE_PATH}/build_lua.cmake)
ELSE()
ADD_DEFINITIONS(-DLUA_COMPAT_MODULE)
ENDIF()

FILE(GLOB src
"*.hpp"
"*.h"
"*.cpp"
)
"*.hpp"
"*.h"
"*.cpp"
)

FILE(GLOB funcs_src
"funcs/*.cpp"
)
"funcs/*.cpp"
)

SOURCE_GROUP(funcs FILES ${funcs_src})

FILE(GLOB graphics_src
"graphics/*.cpp"
)
"graphics/*.cpp"
)

SOURCE_GROUP(graphics FILES ${graphics_src})

FILE(GLOB methods_src
"methods/*.cpp"
)
"methods/*.cpp"
)

SOURCE_GROUP(methods FILES ${methods_src})

FILE(GLOB template_src
"template/*.cpp")
"template/*.cpp")

SOURCE_GROUP(template FILES ${template_src})
ADD_DEFINITIONS(-DLUA_COMPAT_MODULE)

# OS Definitions
IF(UNIX)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -pthread -Wno-comment")
ADD_DEFINITIONS(-Wall -std=c++11 -fvisibility=hidden)
ELSE(${UNIX}) #Windows
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /bigobj")
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /bigobj")
ENDIF()

INCLUDE_DIRECTORIES(${ArrayFire_INCLUDE_DIRS})
INCLUDE_DIRECTORIES(${LUA_INCLUDE_DIR})
Expand All @@ -56,9 +61,16 @@ ADD_LIBRARY(arrayfire_lib SHARED
${methods_src})

TARGET_LINK_LIBRARIES(arrayfire_lib
${ArrayFire_Unified_LIBRARIES}
${LUA_LIBRARIES}
)
${ArrayFire_Unified_LIBRARIES}
${LUA_LIBRARIES}
)

SET_TARGET_PROPERTIES(arrayfire_lib PROPERTIES
PREFIX "")

########################################
# Installation
########################################
INSTALL(TARGETS arrayfire_lib EXPORT ARRAYFIRE_LIB
DESTINATION "./"
COMPONENT libraries)

0 comments on commit 4779dc6

Please sign in to comment.