CMakeLists.txt 5.14 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 )
12
	set( ITA_VAMATLAB_VERSION_MAJOR "v2018" 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 )
16
	set( ITA_VAMATLAB_VERSION_MINOR "a" 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

if( ITA_VISTA_BUILD_STATIC )
42 43 44 45
	add_definitions( -DVISTA_STATIC )
	if( WIN32 )
		list( APPEND VISTA_USE_PACKAGE_LIBRARIES ws2_32 winspool )
	endif( )
46
endif( )
47

48
if( NOT BUILD_SHARED_LIBS )
49
	add_definitions( -DVABASE_STATIC -DVANET_STATIC )
50
endif( )
51

52

53
if( ITA_VAMATLAB_BUILD_WITH_INTERNAL_CORE )
54
	vista_use_package( VACore REQUIRED FIND_DEPENDENCIES )
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
55
	add_definitions( -DVAMATLAB_INTERNAL_CORE )
56
endif( )
57

58 59 60
add_definitions( "-DVAMATLAB_VERSION_MAJOR=\"${ITA_VAMATLAB_VERSION_MAJOR}\"" )
add_definitions( "-DVAMATLAB_VERSION_MINOR=\"${ITA_VAMATLAB_VERSION_MINOR}\"" )
if( ITA_VAMATLAB_SHOW_BANNER )
61
	add_definitions( -DVAMATLAB_SHOW_BANNER )
62
endif( )
63

64 65 66
if( ITA_VAMATLAB_BUILD_WITH_OPTITRACK_TRACKING_SUPPORT )
	add_definitions( -DVAMATLAB_WITH_OPTITRACK )
endif( )
67

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

84 85 86 87
if( ITA_VA_INSTALL_WITH_DLLS )
	vista_install_all_dlls( bin )
endif( )

88
vista_configure_lib( VAMatlab )
89 90
vista_install( VAMatlab )
vista_create_default_info_file( VAMatlab )
91
vista_create_cmake_configs( VAMatlab )
92

93
set_property( TARGET VAMatlab PROPERTY FOLDER "VA/Bindings" )
94
set_target_properties( VAMatlab PROPERTIES SUFFIX ".${MATLAB_MEX_EXTENSION}")
95

96
if( ITA_VAMATLAB_DEPLOY_MATLAB_EXECUTABLE )
97
	install( FILES "${CMAKE_BINARY_DIR}/lib/VAMatlab.${MATLAB_MEX_EXTENSION}" DESTINATION "bin" )
98 99
endif( )

100
# VA matlab scripts file
101 102 103
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
104
configure_file( "matlab/itaVA_build.m.proto" "${CMAKE_CURRENT_SOURCE_DIR}/matlab/itaVA_build.m" @ONLY )
105 106 107 108 109 110 111

# 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" )
112 113
install( FILES "matlab/itaVA_example_offline_simulation.m" DESTINATION "matlab" )
install( FILES "matlab/itaVA_example_offline_simulation_ir.m" DESTINATION "matlab" )
114 115
install( FILES "matlab/itaVA_setup.fig" DESTINATION "matlab" )
install( FILES "matlab/itaVA_setup.m" DESTINATION "matlab" )
116 117

# Build Matlab class using Matlab (future work)
118
if( ITA_VAMATLAB_POSTBUILD_CREATE_MATLAB_CLASS )
119 120
	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 )
121 122
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." )
123
endif( )
124 125 126 127

if( EXISTS "matlab/itaVA.m" ) 
	install( FILES "matlab/itaVA.m" DESTINATION "matlab" )
endif( )