forked from CATIA-Systems/FMIKit-Simulink
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
84 lines (71 loc) · 2.4 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
cmake_minimum_required (VERSION 3.2)
set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING INTERNAL FORCE)
set (CMAKE_CXX_STANDARD 11)
project (FMIKit)
if (MSVC)
# link statically against the the Visual C runtime
string(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
string(REPLACE "/MDd" "/MTd" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
string(REPLACE "/MDd" "/MTd" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
endif ()
if (WIN32)
if ("${CMAKE_SIZEOF_VOID_P}" STREQUAL "8")
set(MATLAB_DIR "C:/Program Files/MATLAB/R2012b" CACHE STRING "MATLAB install directory")
set(TARGET_SUFFIX mexw64)
link_directories(${MATLAB_DIR}/extern/lib/win64/microsoft)
else ()
set(MATLAB_DIR "C:/Program Files (x86)/MATLAB/R2012b" CACHE STRING "MATLAB install directory")
set(TARGET_SUFFIX mexw32)
link_directories(${MATLAB_DIR}/extern/lib/win32/microsoft)
endif ()
elseif (APPLE)
set(MATLAB_DIR "/Applications/MATLAB_R2018b.app" CACHE STRING "MATLAB install directory")
set(TARGET_SUFFIX mexmaci64)
set (CMAKE_SHARED_LINKER_FLAGS "-Wl,-exported_symbols_list,${MATLAB_DIR}/extern/lib/maci64/mexFunction.map")
else ()
set(TARGET_SUFFIX mexa64)
endif ()
add_library(sfun_fmurun SHARED
include/fmi1.h
include/fmi2Functions.h
include/fmi2FunctionTypes.h
include/fmi2TypesPlatform.h
include/FMU.h
include/FMU1.h
include/FMU2.h
sfun_fmurun.cpp
src/FMU.cpp
src/FMU1.cpp
src/FMU2.cpp
)
SET_TARGET_PROPERTIES(sfun_fmurun PROPERTIES PREFIX "")
if (WIN32)
target_compile_definitions(sfun_fmurun PUBLIC
MATLAB_MEX_FILE
_CRT_SECURE_NO_WARNINGS
"DLL_EXPORT_SYM=__declspec(dllexport)"
)
else ()
target_compile_definitions(sfun_fmurun PUBLIC MATLAB_MEX_FILE)
endif ()
target_include_directories(sfun_fmurun PUBLIC
${MATLAB_DIR}/extern/include
${MATLAB_DIR}/simulink/include
include
coder
)
if (WIN32)
target_link_libraries(sfun_fmurun libmat libmex libmx)
elseif (APPLE)
target_link_libraries(sfun_fmurun
${MATLAB_DIR}/bin/maci64/libmat.dylib
${MATLAB_DIR}/bin/maci64/libmex.dylib
${MATLAB_DIR}/bin/maci64/libmx.dylib
)
endif ()
set_target_properties(sfun_fmurun PROPERTIES SUFFIX ".${TARGET_SUFFIX}")
add_custom_command(TARGET sfun_fmurun POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy
"$<TARGET_FILE:sfun_fmurun>"
"${CMAKE_CURRENT_SOURCE_DIR}"
)