diff --git a/CMakeLists.txt b/CMakeLists.txt index bd63c88..34cd712 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/CMakeModules/build_lua.cmake b/CMakeModules/build_lua.cmake index 15a9269..62ebf84 100644 --- a/CMakeModules/build_lua.cmake +++ b/CMakeModules/build_lua.cmake @@ -25,6 +25,8 @@ ExternalProject_Add( -DCMAKE_SOURCE_DIR:PATH= -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= -DBUILD_SHARED_LIBS=OFF @@ -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) diff --git a/wrapper/Lua/CMakeLists.txt b/wrapper/Lua/CMakeLists.txt index bef6e08..df52d0d 100644 --- a/wrapper/Lua/CMakeLists.txt +++ b/wrapper/Lua/CMakeLists.txt @@ -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}) @@ -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)