You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
2.1 KiB
CMake

10 years ago
# BuildMex.cmake
# Author: Kent Williams norman-k-williams at uiowa.edu
# Modified by Ismael Gomez, 2014
include(CMakeParseArguments)
if(NOT DisableMEX)
if(NOT MATLAB_FOUND)
find_package(MATLAB)
endif()
if(NOT OCTAVE_FOUND)
find_package(OCTAVE)
endif()
10 years ago
# CMake 2.8.12 & earlier apparently don't define the
# Mex script path, so find it.
if(NOT MATLAB_MEX_PATH)
find_program( MATLAB_MEX_PATH mex
HINTS ${MATLAB_ROOT}/bin
PATHS ${MATLAB_ROOT}/bin
DOC "The mex program path"
)
endif()
10 years ago
endif()
#
# BuildMex -- arguments
# MEXNAME = root of mex library name
# SOURCE = list of source files
# LIBRARIES = libraries needed to link mex library
FUNCTION(BuildMex)
set(oneValueArgs MEXNAME)
set(multiValueArgs SOURCES LIBRARIES)
cmake_parse_arguments(BuildMex "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if (MATLAB_FOUND)
add_library(${BuildMex_MEXNAME}-mat SHARED ${BuildMex_SOURCES})
#target_include_directories(${BuildMex_MEXNAME}-mat PUBLIC ${MATLAB_INCLUDE_DIR})
10 years ago
set_target_properties(${BuildMex_MEXNAME}-mat PROPERTIES
SUFFIX "${MATLAB_MEX_EXTENSION}"
PREFIX "liblte_"
OUTPUT_NAME "${BuildMex_MEXNAME}"
COMPILE_FLAGS "-fvisibility=default ${MATLAB_MEX_CFLAGS} -I${MATLAB_INCLUDE_DIR}"
10 years ago
)
target_link_libraries(${BuildMex_MEXNAME}-mat ${BuildMex_LIBRARIES} ${MATLAB_MEX_LIBRARY})
install(TARGETS ${BuildMex_MEXNAME}-mat DESTINATION "${MEX_DIR}/liblte/")
10 years ago
endif(MATLAB_FOUND)
if (OCTAVE_FOUND)
add_library(${BuildMex_MEXNAME}-oct SHARED ${BuildMex_SOURCES})
#target_include_directories(${BuildMex_MEXNAME}-oct PUBLIC ${OCTAVE_INCLUDE_DIR})
10 years ago
set_target_properties(${BuildMex_MEXNAME}-oct PROPERTIES
SUFFIX ".${OCTAVE_MEXFILE_EXT}"
PREFIX "liblte_"
OUTPUT_NAME "${BuildMex_MEXNAME}"
COMPILE_FLAGS "-fvisibility=default ${OCTAVE_MEX_CFLAGS} -DUNDEF_BOOL -I${OCTAVE_INCLUDE_DIR}"
10 years ago
)
target_link_libraries(${BuildMex_MEXNAME}-oct ${BuildMex_LIBRARIES} ${OCTAVE_LIBRARIES})
install(TARGETS ${BuildMex_MEXNAME}-oct DESTINATION "${MEX_DIR}/liblte/")
10 years ago
endif (OCTAVE_FOUND)
ENDFUNCTION(BuildMex)