| 1 |
INCLUDE(TrilinosCreateClientTemplateHeaders) |
| 2 |
|
| 3 |
# NTS: The funny thing is that I need to include this in order to |
| 4 |
# get the link/include directories correct. Go figure. |
| 5 |
SET(HEADERS_EXEC "") |
| 6 |
SET(SOURCES_EXEC "") |
| 7 |
|
| 8 |
TRIBITS_INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/) |
| 9 |
TRIBITS_INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/) |
| 10 |
|
| 11 |
if(TPL_ENABLE_MATLAB) |
| 12 |
TRIBITS_INCLUDE_DIRECTORIES(${MATLAB_INCLUDE_DIRS}) |
| 13 |
|
| 14 |
# Must glob the binary dir last to get all of the auto-generated headers |
| 15 |
TRIBITS_SET_AND_INC_DIRS(DIR ${CMAKE_CURRENT_BINARY_DIR}) |
| 16 |
|
| 17 |
# Force the code into R2017b compatibility mode |
| 18 |
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DMX_COMPAT_64 -fPIC -DMATLAB_MEXCMD_RELEASE=R2017b") |
| 19 |
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DMX_COMPAT_64 -fPIC -DMATLAB_MEXCMD_RELEASE=R2017b") |
| 20 |
# Debugging information |
| 21 |
MESSAGE("MEX_COMPILER = " ${MEX_COMPILER}) |
| 22 |
MESSAGE("MEX_MEXEXT = " ${MEX_MEXEXT}) |
| 23 |
MESSAGE("MEX_EXTENSION = " ${MEX_EXTENSION}) |
| 24 |
MESSAGE("MATLAB_MEX_DIR = " ${MATLAB_MEX_DIR}) |
| 25 |
|
| 26 |
APPEND_SET(HEADERS_EXEC muemex.h) |
| 27 |
APPEND_SET(SOURCES_EXEC muemex.cpp) |
| 28 |
|
| 29 |
# Manually drop in options from the mex script (R2009b) on a linux platform. |
| 30 |
# g++ -O -pthread -shared -Wl,--version-script,/usr/local/matlab/7.9/extern/lib/glnxa64/mexFunction.map -Wl,--no-undefined -o "mlmex.mexa64" "mlmex-mlmex.o" -lm -Wl,-rpath-link,/usr/local/matlab/7.9/bin/glnxa64 -L/usr/local/matlab/7.9/bin/glnxa64 -lmx -lmex -lmat -lm |
| 31 |
if (NOT APPLE) |
| 32 |
SET(MLMEX_OPTS1 "-pthread;-shared;-Wl,--version-script,${MATLAB_ROOT}/extern/lib/${MATLAB_ARCH}/mexFunction.map;-Wl,--no-undefined") |
| 33 |
SET(MLMEX_OPTS2 "-Wl,-rpath-link,${MATLAB_ROOT}/bin/${MATLAB_ARCH}") |
| 34 |
else() |
| 35 |
SET(MLMEX_OPTS1 "-shared") |
| 36 |
SET(MLMEX_OPTS2 "") |
| 37 |
endif() |
| 38 |
|
| 39 |
# Use TARGET_LINK_LIBRARIES and the C++ compiler to link the mlmex.cpp file to the rest of Trilinos & the mex libs. |
| 40 |
# This code is extremely fragile and probably won't work on any system but GNU/Linux with gcc. |
| 41 |
# This is because Cmake will not allow me to *just call the mex linker*, and so I have to do this the hard way. |
| 42 |
# |
| 43 |
|
| 44 |
LINK_DIRECTORIES(${MATLAB_LIBRARY_DIRS}) |
| 45 |
TRIBITS_ADD_EXECUTABLE(muemex.${MEX_EXTENSION} SOURCES ${SOURCES_EXEC} NOEXEPREFIX NOEXESUFFIX) |
| 46 |
SET_TARGET_PROPERTIES(muemex.${MEX_EXTENSION} PROPERTIES SUFFIX "") # remove .exe extension |
| 47 |
TARGET_LINK_LIBRARIES(muemex.${MEX_EXTENSION} PUBLIC ${MLMEX_OPTS1} ${LINK_LIBS} ${MLMEX_OPTS2} ${${PROJECT_NAME}_EXTRA_LINK_FLAGS}) |
| 48 |
|
| 49 |
# Copy these files over from src tree |
| 50 |
TRIBITS_COPY_FILES_TO_BINARY_DIR(Matlab_Output_cp |
| 51 |
SOURCE_FILES muelu.m setup.m |
| 52 |
) |
| 53 |
|
| 54 |
CONFIGURE_FILE(matlab ${CMAKE_CURRENT_BINARY_DIR}/matlab @ONLY) |
| 55 |
|
| 56 |
ENDIF() |