CMakeLists.txt 4.85 KB
Newer Older
1 2
cmake_minimum_required( VERSION 2.8 )

3 4 5
project( VAMatlab )
list( APPEND CMAKE_MODULE_PATH "$ENV{VISTA_CMAKE_COMMON}" )
include( VistaCommon )
6 7 8 9 10

if( NOT DEFINED ITA_VA_MATLAB_BUILD_WITH_INTERNAL_CORE )
	set( ITA_VA_MATLAB_BUILD_WITH_INTERNAL_CORE OFF CACHE BOOL "Build a VACore into VAMatlab instead of using a network adapter (not recommended)" )
endif( NOT DEFINED ITA_VA_MATLAB_BUILD_WITH_INTERNAL_CORE )

11
if( NOT DEFINED ITA_VAMATLAB_VERSION_MAJOR )
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
12
	set( ITA_VAMATLAB_VERSION_MAJOR "v2017" CACHE STRING "VAMatlab version major (usually 'v' and year)" )
13 14 15
endif( NOT DEFINED ITA_VAMATLAB_VERSION_MAJOR )

if( NOT DEFINED ITA_VAMATLAB_VERSION_MINOR )
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
16
	set( ITA_VAMATLAB_VERSION_MINOR "d" CACHE STRING "VAMatlab version minor (usually a,b,c ...)" )
17 18 19 20 21 22
endif( NOT DEFINED ITA_VAMATLAB_VERSION_MINOR )

if( NOT DEFINED ITA_VAMATLAB_SHOW_BANNER )
	set( ITA_VAMATLAB_SHOW_BANNER ON CACHE BOOL "Show VA banner on Matlab init" )
endif( NOT DEFINED ITA_VAMATLAB_SHOW_BANNER )

23 24 25 26 27 28 29 30 31 32
if( NOT DEFINED ITA_VAMATLAB_DEPLOY_MATLAB_EXECUTABLE )
	set( ITA_VAMATLAB_DEPLOY_MATLAB_EXECUTABLE ON CACHE BOOL "Install VAMatlab executable into deploy binary directory" )
endif( )

if( NOT DEFINED ITA_VAMATLAB_BUILD_WITH_OPTITRACK_TRACKING_SUPPORT )
	set( ITA_VAMATLAB_BUILD_WITH_OPTITRACK_TRACKING_SUPPORT ON CACHE BOOL "Activate integrated OptiTrack tracking support" )
endif( )

if( NOT DEFINED ITA_VAMATLAB_POSTBUILD_CREATE_MATLAB_CLASS )
	set( ITA_VAMATLAB_POSTBUILD_CREATE_MATLAB_CLASS OFF CACHE BOOL "Auto-create Matlab convenience class after build [for future use]" )
33 34
endif( )

35 36
vista_use_package( VABase REQUIRED FIND_DEPENDENCIES )
vista_use_package( VANet REQUIRED FIND_DEPENDENCIES )
37
vista_use_package( Matlab REQUIRED FIND_DEPENDENCIES )
38
vista_use_package( NatNetSDK REQUIRED FIND_DEPENDENCIES )
39

40

41 42 43
# Build settings
if( ITA_CORE_LIBS_STATIC )
	add_definitions( -DITACORELIBS_STATIC )
44
endif( )
45 46

if( ITA_VISTA_BUILD_STATIC )
47 48 49 50
	add_definitions( -DVISTA_STATIC )
	if( WIN32 )
		list( APPEND VISTA_USE_PACKAGE_LIBRARIES ws2_32 winspool )
	endif( )
51
endif( )
52

53
if( NOT BUILD_SHARED_LIBS )
54
	add_definitions( -DVABASE_STATIC -DVANET_STATIC  )
55
endif( )
56

57

58
if( ITA_VAMATLAB_BUILD_WITH_INTERNAL_CORE )
59
	vista_use_package( VACore REQUIRED FIND_DEPENDENCIES )
Dipl.-Ing. Jonas Stienen's avatar
test  
Dipl.-Ing. Jonas Stienen committed
60
	add_definitions( -DVAMATLAB_INTERNAL_CORE )
61
endif( )
62

63 64 65
add_definitions( "-DVAMATLAB_VERSION_MAJOR=\"${ITA_VAMATLAB_VERSION_MAJOR}\"" )
add_definitions( "-DVAMATLAB_VERSION_MINOR=\"${ITA_VAMATLAB_VERSION_MINOR}\"" )
if( ITA_VAMATLAB_SHOW_BANNER )
66
	add_definitions( -DVAMATLAB_SHOW_BANNER )
67
endif( )
68

69 70 71
if( ITA_VAMATLAB_BUILD_WITH_OPTITRACK_TRACKING_SUPPORT )
	add_definitions( -DVAMATLAB_WITH_OPTITRACK )
endif( )
72

73
# Sources
74
set( VAMATLAB_SRC
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
75 76 77
	"src/VAMatlabFunctionMapping.h"
	"src/VAMatlabHelpers.h"
	"src/VAMatlabHelpers.cpp"
78 79 80
	"src/VAMatlabConnection.cpp"
	"src/VAMatlabConnection.h"
	"src/VAMatlabExecutable.cpp"
81 82 83 84
	)
if( ITA_VAMATLAB_BUILD_WITH_OPTITRACK_TRACKING_SUPPORT )
	list( APPEND VAMATLAB_SRC "src/VAMatlabTracking.h" "src/VAMatlabTracking.cpp" )
endif( )
85
	
86
add_library( VAMatlab SHARED ${VAMATLAB_SRC} VAMatlab.def )
87 88
target_link_libraries( VAMatlab ${VISTA_USE_PACKAGE_LIBRARIES} )

89 90 91 92
if( ITA_VA_INSTALL_WITH_DLLS )
	vista_install_all_dlls( bin )
endif( )

93
vista_configure_lib( VAMatlab )
94 95
vista_install( VAMatlab )
vista_create_default_info_file( VAMatlab )
96
vista_create_cmake_configs( VAMatlab )
97

98
set_property( TARGET VAMatlab PROPERTY FOLDER "VA/Bindings" )
99
set_target_properties( VAMatlab PROPERTIES SUFFIX ".${MATLAB_MEX_EXTENSION}")
100

101
if( ITA_VAMATLAB_DEPLOY_MATLAB_EXECUTABLE )
102
	install( FILES "${CMAKE_BINARY_DIR}/lib/VAMatlab.${MATLAB_MEX_EXTENSION}" DESTINATION "bin" )
103 104
endif( )

105
# VA matlab scripts file
106 107 108
set( VAMATLAB_BASE_DIR "${CMAKE_INSTALL_PREFIX}" )
configure_file( "matlab/itaVA_build.m.proto" "${CMAKE_CURRENT_SOURCE_DIR}/matlab/itaVA_build_absolute.m" @ONLY )
set( VAMATLAB_BASE_DIR ".." ) # relative path from matlab folder
109
configure_file( "matlab/itaVA_build.m.proto" "${CMAKE_CURRENT_SOURCE_DIR}/matlab/itaVA_build.m" @ONLY )
110 111 112 113 114 115 116

# Install specialties
install( FILES "matlab/itaVA_build.m" DESTINATION "matlab" )
install( FILES "matlab/itaVA.m.proto" DESTINATION "matlab" )
install( FILES "matlab/itaVA_generateStubs.m" DESTINATION "matlab" )
install( FILES "matlab/itaVA_example_simple.m" DESTINATION "matlab" )
install( FILES "matlab/itaVA_example_tracked_listener.m" DESTINATION "matlab" )
117 118

# Build Matlab class using Matlab (future work)
119
if( ITA_VAMATLAB_POSTBUILD_CREATE_MATLAB_CLASS )
120 121
	set( MATLAB_BUILD_CLASS_COMMAND "matlab -nodisplay -nosplash -nodesktop -r \"run( 'matlab/itaVA_build_absolute.m' )\"" )
	add_custom_command( TARGET VAMatlab POST_BUILD COMMAND ${MATLAB_BUILD_CLASS_COMMAND} WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" COMMENT "Running matlab itaVA installer" VERBATIM )
122 123
else( )
	message( STATUS "To make the itaVA convenience class available, after deploy, please run the 'matlab/itaVA_build.m' ccript once in Matlab. It will generate the itavA.m class file in the matlab folder." )
124
endif( )