Python: now statically linking (i.e. recompiling everything) for better portability.
This commit is contained in:
@@ -21,6 +21,8 @@ ADD_DEFINITIONS(-Wno-sign-compare -D__CL_ENABLE_EXCEPTIONS ${BACKEND_DEFINES} -W
|
||||
ADD_EXECUTABLE(bin2cpp ${CMAKE_MODULE_PATH}/bin2cpp.cpp)
|
||||
|
||||
include(CTest)
|
||||
|
||||
file(GLOB_RECURSE LIBISAAC_SRC lib/*.cpp)
|
||||
add_subdirectory(lib)
|
||||
add_subdirectory(tests)
|
||||
add_subdirectory(bench)
|
||||
|
@@ -1,14 +1,11 @@
|
||||
if(ANDROID)
|
||||
file(GLOB ADRENO_SDK_ROOT /opt/adreno-sdk*)
|
||||
set(L_HINTS ${ADRENO_SDK_ROOT}/driver/lib/)
|
||||
file(GLOB ADRENO_DRIVER_ROOT /opt/adreno-driver*)
|
||||
set(L_HINTS ${ADRENO_DRIVER_ROOT}/lib/)
|
||||
else()
|
||||
file(GLOB AMDAPPSDK_ROOT /opt/AMDAPPSDK*)
|
||||
set(L_HINTS ${AMDAPPSDK_ROOT}/lib/x86_64/ ${CUDA_TOOLKIT_ROOT_DIR}/targets/x86_64-linux/lib/)
|
||||
endif()
|
||||
|
||||
find_library(OPENCL_LIBRARIES NAMES OpenCL NO_CMAKE_FIND_ROOT_PATH HINTS ${L_HINTS} )
|
||||
message(STATUS ${OPENCL_LIBRARIES})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(OpenCL DEFAULT_MSG OPENCL_LIBRARIES)
|
||||
mark_as_advanced(OpenCL)
|
||||
|
@@ -121,7 +121,7 @@ macro(android_create_apk name apk_package_name apk_directory libs_directory andr
|
||||
add_custom_command(TARGET ${ANDROID_NAME}
|
||||
COMMAND ant debug
|
||||
WORKING_DIRECTORY "${apk_directory}")
|
||||
|
||||
|
||||
# Install current version on the device/emulator
|
||||
if(ANDROID_APK_INSTALL OR ANDROID_APK_RUN)
|
||||
add_custom_command(TARGET ${ANDROID_NAME}
|
||||
|
@@ -1,9 +1,3 @@
|
||||
set(CMAKE_BUILD_TYPE RELEASE)
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "-O2")
|
||||
|
||||
file( GLOB_RECURSE LIBISAAC_SRC *.cpp)
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
if(ANDROID)
|
||||
add_library(isaac STATIC ${LIBISAAC_SRC})
|
||||
else()
|
||||
|
@@ -2,16 +2,26 @@ file( GLOB_RECURSE PYTHON_SRC *.cpp)
|
||||
file( GLOB_RECURSE PYTHON_PYSRC *.py)
|
||||
add_custom_target( MAKE_PYTHON_SRC_VISIBLE SOURCES ${PYTHON_SRC} ${PYTHON_PYSRC})
|
||||
|
||||
set(SETUP_PY_IN "${CMAKE_CURRENT_SOURCE_DIR}/setup.py")
|
||||
set(SETUP_PY "${CMAKE_CURRENT_BINARY_DIR}/setup.py")
|
||||
set(SETUP_PY_IN "${CMAKE_CURRENT_SOURCE_DIR}/external/cmake/setup.py")
|
||||
set(SETUP_PY "${CMAKE_CURRENT_SOURCE_DIR}/setup.py")
|
||||
set(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/build")
|
||||
|
||||
function(JOIN VALUES GLUE OUTPUT)
|
||||
string (REGEX REPLACE "([^\\]|^);" "\\1${GLUE}" _TMP_STR "${VALUES}")
|
||||
string (REGEX REPLACE "[\\](.)" "\\1" _TMP_STR "${_TMP_STR}") #fixes escaping
|
||||
set (${OUTPUT} "${_TMP_STR}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
join("${LIBISAAC_SRC}" " " LIBISAAC_SRC_STR)
|
||||
|
||||
get_property(INCLUDE_DIRECTORIES_LST DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES)
|
||||
join("${INCLUDE_DIRECTORIES_LST}" " " INCLUDE_DIRECTORIES_STR)
|
||||
|
||||
configure_file(${SETUP_PY_IN} ${SETUP_PY})
|
||||
|
||||
add_custom_command(OUTPUT ${OUTPUT}/timestamp
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/isaac ${CMAKE_CURRENT_BINARY_DIR}/isaac
|
||||
COMMAND ${PYTHON} ${CMAKE_CURRENT_BINARY_DIR}/setup.py build
|
||||
COMMAND ${PYTHON} ${CMAKE_CURRENT_SOURCE_DIR}/setup.py build
|
||||
COMMAND ${CMAKE_COMMAND} -E touch ${OUTPUT}/timestamp
|
||||
DEPENDS isaac ${PYTHON_SRC} ${PYTHON_PYSRC} ${SETUP_PY})
|
||||
add_custom_target(python ALL DEPENDS ${OUTPUT}/timestamp)
|
||||
|
||||
install(CODE "execute_process(WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${PYTHON} ${SETUP_PY} install)")
|
||||
DEPENDS ${LIBISAAC_SRC} ${PYTHON_SRC} ${PYTHON_PYSRC} ${SETUP_PY})
|
||||
add_custom_target(python DEPENDS ${OUTPUT}/timestamp)
|
||||
install(CODE "execute_process(WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${PYTHON} ${SETUP_PY} install)" OPTIONAL)
|
||||
|
30
python/setup.py → python/external/cmake/setup.py
vendored
30
python/setup.py → python/external/cmake/setup.py
vendored
@@ -1,3 +1,6 @@
|
||||
#Thanks to Andreas Knoeckler for providing stand-alone boost.python
|
||||
#through PyOpenCL and PyCUDA
|
||||
|
||||
import os, sys
|
||||
from distutils.command.build_ext import build_ext
|
||||
from distutils.command.build_py import build_py
|
||||
@@ -12,9 +15,6 @@ platform_ldflags = {}
|
||||
platform_libs = {}
|
||||
|
||||
class build_ext_subclass(build_ext):
|
||||
"""Shamelessly stolen from
|
||||
https://stackoverflow.com/questions/724664
|
||||
"""
|
||||
def build_extensions(self):
|
||||
c = self.compiler.compiler_type
|
||||
if c in platform_cflags.keys():
|
||||
@@ -46,20 +46,22 @@ def main():
|
||||
break
|
||||
return optlist
|
||||
|
||||
#Compiler options
|
||||
cvars = sysconfig.get_config_vars()
|
||||
cvars['OPT'] = "-DNDEBUG -O3 -std=c++11 ${BACKEND_DEFINES}" + str.join(' ', remove_prefixes(cvars['OPT'].split(), ['-g', '-O', '-Wstrict-prototypes', '-DNDEBUG']))
|
||||
cvars['BASECFLAGS'] = "-D__CL_ENABLE_EXCEPTIONS -fPIC -Wno-sign-compare -Wall -Wextra -pedantic -Wno-ignored-qualifiers -std=c++11 "
|
||||
cvars['OPT'] = str.join(' ', remove_prefixes(cvars['OPT'].split(), ['-g', '-Wstrict-prototypes']))
|
||||
cvars["CFLAGS"] = cvars["BASECFLAGS"] + " " + cvars["OPT"]
|
||||
cvars["LDFLAGS"] = '-Wl,--no-as-needed ' + cvars["LDFLAGS"]
|
||||
|
||||
DEFINES = []
|
||||
INCLUDE_DIRS = ['${CMAKE_CURRENT_SOURCE_DIR}/external/boost/include',
|
||||
os.path.join(find_module("numpy")[1], "core", "include"),
|
||||
'${PROJECT_SOURCE_DIR}/include',
|
||||
'${CUDA_INCLUDE_DIRS}']
|
||||
LIBRARY_DIRS = ['${CMAKE_BINARY_DIR}/lib']
|
||||
|
||||
src = [os.path.join('${CMAKE_CURRENT_SOURCE_DIR}', 'src', sf) for sf in ['_isaac.cpp', 'core.cpp', 'driver.cpp', 'model.cpp', 'exceptions.cpp']]
|
||||
#Includes
|
||||
include ='${INCLUDE_DIRECTORIES_STR}'.split() +\
|
||||
['${CMAKE_CURRENT_SOURCE_DIR}/external/boost/include',
|
||||
os.path.join(find_module("numpy")[1], "core", "include")]
|
||||
|
||||
#Sources
|
||||
src = '${LIBISAAC_SRC_STR}'.split() +\
|
||||
[os.path.join('${CMAKE_CURRENT_SOURCE_DIR}', 'src', sf) \
|
||||
for sf in ['_isaac.cpp', 'core.cpp', 'driver.cpp', 'model.cpp', 'exceptions.cpp']]
|
||||
boostsrc = '${CMAKE_CURRENT_SOURCE_DIR}/external/boost/libs/'
|
||||
for s in ['numpy','python','smart_ptr','system','thread']:
|
||||
src = src + [x for x in recursive_glob('${CMAKE_CURRENT_SOURCE_DIR}/external/boost/libs/' + s + '/src/','.cpp') if 'win32' not in x and 'pthread' not in x]
|
||||
@@ -87,10 +89,8 @@ def main():
|
||||
'_isaac',src,
|
||||
extra_compile_args= ['-Wno-unused-function', '-Wno-unused-local-typedefs'],
|
||||
extra_link_args=['-Wl,-soname=_isaac.so'],
|
||||
define_macros=DEFINES,
|
||||
undef_macros=[],
|
||||
include_dirs=INCLUDE_DIRS,
|
||||
library_dirs=LIBRARY_DIRS,
|
||||
include_dirs=include,
|
||||
libraries=['OpenCL', 'isaac']
|
||||
)],
|
||||
cmdclass={'build_py': build_py, 'build_ext': build_ext_subclass},
|
@@ -12,3 +12,4 @@ void android_main(struct android_app* state)
|
||||
__android_log_print(ANDROID_LOG_INFO, "IsaacAndroidTest", isaac::tools::to_string(test).c_str());
|
||||
ANativeActivity_finish(state->activity);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user