CMakeLists.txt 2.96 KB
Newer Older
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
cmake_minimum_required( VERSION 2.8 )
project( VAPython )

list( APPEND CMAKE_MODULE_PATH "$ENV{VISTA_CMAKE_COMMON}" )

include( VistaCommon )

vista_use_package( VANet REQUIRED FIND_DEPENDENCIES )
vista_use_package( PythonLibs REQUIRED )

if( ITA_VISTA_BUILD_STATIC )
	add_definitions( -DVISTABASE_STATIC -DVISTAMATH_STATIC -DVISTAASPECTS_STATIC -DVISTATOOLS_STATIC -DVISTAINTERPROCCOMM_STATIC )
endif( )

if( NOT BUILD_SHARED_LIBS )
	add_definitions( -DVAPYTHON_STATIC -DVABASE_STATIC -DVANET_STATIC )
endif( )

add_definitions( -DPy_NO_ENABLE_SHARED )

21

22
# Only add library here to check if it compiles in your preferred build env. CMake will run Python distutils to actually compile the extension, see below.
23
add_library( VAPython STATIC "src/vasingleton.cpp" "src/vasingletondoc.hpp" "src/vasingletonmethods.hpp" "MANIFEST.in" "setup.py" )
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
24 25 26
target_link_libraries( VAPython ${VISTA_USE_PACKAGE_LIBRARIES} )


27 28 29 30 31 32 33
# Run distutils after (useless) build in your dev env to compile the Python extension into 'dist' folder
set( BATCH_SCRIPT_EXTENSION "bat" )
if( NOT WIN32 )
	set( BATCH_SCRIPT_EXTENSION "sh" )
endif( )
add_custom_command( TARGET VAPython POST_BUILD COMMAND "distutils_build.${BATCH_SCRIPT_EXTENSION}" WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMENT "Running distutils" VERBATIM )

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
34 35 36 37 38 39 40
# configure
vista_configure_lib( VAPython )
vista_install( VAPython )
vista_create_cmake_configs( VAPython )
vista_create_default_info_file( VAPython )

set_property( TARGET VAPython PROPERTY FOLDER "VA/Bindings" )
41

42

43
# install
44 45 46 47 48 49 50 51

# Copy python extension if available. Requires successful distutils execution.
vista_install_files_by_extension( dist/Lib/site-packages "python/Lib/site-packages" "pyd" "egg-info" )

# install by copying DLL/SO next to python extension
set( SHARED_LIBRARY_EXTENSION "dll" )
if( NOT WIN32 )
	set( SHARED_LIBRARY_EXTENSION "so" )
52
endif( )
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71

# VA shared libs
install( FILES "${VABASE_LIBRARY_DIRS}/VABase.${SHARED_LIBRARY_EXTENSION}" DESTINATION "python/Lib/site-packages" )
install( FILES "${VANET_LIBRARY_DIRS}/VANet.${SHARED_LIBRARY_EXTENSION}" DESTINATION "python/Lib/site-packages" )

# VistaCoreLibs shared libs
foreach( VISTACORELIBS_LIBRARY_DIR ${VISTACORELIBS_LIBRARY_DIRS} )
	if( EXISTS "${VISTACORELIBS_LIBRARY_DIR}/VistaBase.${SHARED_LIBRARY_EXTENSION}" )
		install( FILES "${VISTACORELIBS_LIBRARY_DIR}/VistaBase.${SHARED_LIBRARY_EXTENSION}" DESTINATION "python/Lib/site-packages" )
	endif( )
	if( EXISTS "${VISTACORELIBS_LIBRARY_DIR}/VistaAspects.${SHARED_LIBRARY_EXTENSION}" )
		install( FILES "${VISTACORELIBS_LIBRARY_DIR}/VistaAspects.${SHARED_LIBRARY_EXTENSION}" DESTINATION "python/Lib/site-packages" )
	endif( )
	if( EXISTS "${VISTACORELIBS_LIBRARY_DIR}/VistaInterProcComm.${SHARED_LIBRARY_EXTENSION}" )
		install( FILES "${VISTACORELIBS_LIBRARY_DIR}/VistaInterProcComm.${SHARED_LIBRARY_EXTENSION}" DESTINATION "python/Lib/site-packages" )
	endif( )
endforeach( )

# Tests
72
install( DIRECTORY "tests" DESTINATION "python" )
73 74

# Examples
75
install( DIRECTORY "examples" DESTINATION "python" )