1 | # This Module Sets CMake variables for BDM |
---|
2 | # Variable BDM_SOURCE_DIR must be set |
---|
3 | # |
---|
4 | # Other respected variables are |
---|
5 | # ITPP_DIR, ACML_DIR, MATLAB_ROOT |
---|
6 | # |
---|
7 | |
---|
8 | IF(NOT BDM_SOURCE_DIR) |
---|
9 | MESSAGE(FATAL_ERROR "BDM_SOURCE_DIR is not set!") |
---|
10 | ENDIF(NOT BDM_SOURCE_DIR) |
---|
11 | |
---|
12 | ###################### |
---|
13 | #Platform specific |
---|
14 | IF(WIN32) |
---|
15 | # IF YOU WANT TO USE YOUR OWN INSTALLATION OF THE NEXT EXTERNAL LIBRARIES, |
---|
16 | # THEN IT IS NECESSARY TO CREATE TEXT FILE "\system\WIN32\LOCAL_PATHS.TXT" WITH |
---|
17 | # COPIES OF THE TWO FOLLOWING LINES AND THEN CORECT ALL THE INVOLVED PATHS |
---|
18 | IF(NOT ITPP_DIR) |
---|
19 | SET(ITPP_DIR "${BDM_SOURCE_DIR}\\system\\win32\\itpp-4.0.6") |
---|
20 | ENDIF(NOT ITPP_DIR) |
---|
21 | IF(NOT ACML_DIR) |
---|
22 | SET(ACML_DIR "${BDM_SOURCE_DIR}\\system\\win32\\acml3.6.0") |
---|
23 | ENDIF(NOT ACML_DIR) |
---|
24 | |
---|
25 | INCLUDE(\\system\\win32\\local_paths.txt OPTIONAL) |
---|
26 | ADD_DEFINITIONS(-DHAVE_ACML) |
---|
27 | ADD_DEFINITIONS(/wd4290) |
---|
28 | ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS) |
---|
29 | ENDIF(WIN32) |
---|
30 | IF(APPLE) |
---|
31 | IF(NOT ITPP_DIR) |
---|
32 | SET(ITPP_DIR "${BDM_SOURCE_DIR}/system/macosx/itpp-4.0.6") |
---|
33 | ENDIF(NOT ITPP_DIR) |
---|
34 | FIND_LIBRARY(FRAMEWORK_VECLIB vecLib) |
---|
35 | ADD_DEFINITIONS(-DHAVE_XLOCALE_H) |
---|
36 | ENDIF(APPLE) |
---|
37 | IF(UNIX) |
---|
38 | # Generally this directory should not exist! |
---|
39 | # Use this location is you compile itpp from sources |
---|
40 | IF(NOT ITPP_DIR) |
---|
41 | SET(ITPP_DIR "${BDM_SOURCE_DIR}/system/linux/") |
---|
42 | ENDIF(NOT ITPP_DIR) |
---|
43 | #This is for UNIX makefile which does only one release at a time. |
---|
44 | ENDIF(UNIX) |
---|
45 | |
---|
46 | # Local ettings should be written to file called CMakeLists.local |
---|
47 | # Use this option for machine-specific options, such as prallel architectures |
---|
48 | INCLUDE(CMakeLists.local OPTIONAL) |
---|
49 | |
---|
50 | FIND_PACKAGE(ITPP REQUIRED) |
---|
51 | FIND_PACKAGE(ACML COMPONENTS) |
---|
52 | FIND_PACKAGE(Matlab COMPONENTS) |
---|
53 | |
---|
54 | IF(ITPP_FOUND) |
---|
55 | INCLUDE_DIRECTORIES(${ITPP_INCLUDE_DIR}) |
---|
56 | LINK_DIRECTORIES(${NATIVE_ITPP_LIB_PATH}) |
---|
57 | ENDIF(ITPP_FOUND) |
---|
58 | |
---|
59 | IF(ACML_FOUND) |
---|
60 | INCLUDE_DIRECTORIES(${ACML_INCLUDE_DIR}) |
---|
61 | LINK_DIRECTORIES(${NATIVE_ACML_LIB_PATH}) |
---|
62 | ENDIF(ACML_FOUND) |
---|
63 | |
---|
64 | IF(UNIX) |
---|
65 | SET(CMAKE_BUILD_TYPE Debug) |
---|
66 | IF(MATLAB_FOUND) |
---|
67 | SET(CMAKE_CXX_FLAGS "-Wall -pipe -Wno-unknown-pragmas -fPIC") |
---|
68 | SET(CMAKE_C_FLAGS "-Wall -pipe -Wno-unknown-pragmas -fPIC") |
---|
69 | ELSE(MATLAB_FOUND) |
---|
70 | SET(CMAKE_CXX_FLAGS "-Wall -Wno-unknown-pragmas ") |
---|
71 | SET(CMAKE_C_FLAGS "-Wall -Wno-unknown-pragmas ") |
---|
72 | ENDIF(MATLAB_FOUND) |
---|
73 | |
---|
74 | SET(CMAKE_CXX_FLAGS_RELEASE " -DNDEBUG -O2") |
---|
75 | SET(CMAKE_CXX_FLAGS_DEBUG "-g -O0") |
---|
76 | ENDIF(UNIX) |
---|
77 | |
---|
78 | ## |
---|
79 | ## PREPARE MACROS for building executables |
---|
80 | ## |
---|
81 | |
---|
82 | MACRO(EXEC FN) |
---|
83 | add_executable (${FN} ${FN}.cpp) |
---|
84 | IF(WIN32) |
---|
85 | target_link_libraries (${FN} debug itpp_debug) |
---|
86 | target_link_libraries (${FN} optimized itpp) |
---|
87 | target_link_libraries (${FN} libacml_dll) |
---|
88 | ELSE(WIN32) |
---|
89 | IF(APPLE) |
---|
90 | target_link_libraries (${FN} ${FRAMEWORK_VECLIB}) |
---|
91 | ENDIF(APPLE) |
---|
92 | IF(ITPP_LIBRARY_DEBUG) |
---|
93 | target_link_libraries (${FN} debug itpp_debug) |
---|
94 | target_link_libraries (${FN} optimized itpp) |
---|
95 | ELSE(ITPP_LIBRARY_DEBUG) |
---|
96 | target_link_libraries (${FN} itpp) |
---|
97 | ENDIF(ITPP_LIBRARY_DEBUG) |
---|
98 | ENDIF(WIN32) |
---|
99 | target_link_libraries (${FN} bdm) |
---|
100 | target_link_libraries (${FN} ${ARGN}) ## Additional libraries can be added to a macro |
---|
101 | ENDMACRO(EXEC) |
---|
102 | |
---|
103 | MACRO(LINK_EXEC FN) |
---|
104 | IF(WIN32) |
---|
105 | target_link_libraries (${FN} debug itpp_debug) |
---|
106 | target_link_libraries (${FN} optimized itpp) |
---|
107 | target_link_libraries (${FN} libacml_dll) |
---|
108 | ELSE(WIN32) |
---|
109 | IF(APPLE) |
---|
110 | target_link_libraries (${FN} ${FRAMEWORK_VECLIB}) |
---|
111 | ENDIF(APPLE) |
---|
112 | IF(ITPP_LIBRARY_DEBUG) |
---|
113 | target_link_libraries (${FN} debug itpp_debug) |
---|
114 | target_link_libraries (${FN} optimized itpp) |
---|
115 | ELSE(ITPP_LIBRARY_DEBUG) |
---|
116 | target_link_libraries (${FN} itpp) |
---|
117 | ENDIF(ITPP_LIBRARY_DEBUG) |
---|
118 | ENDIF(WIN32) |
---|
119 | target_link_libraries (${FN} bdm) |
---|
120 | ENDMACRO(LINK_EXEC) |
---|
121 | |
---|
122 | MACRO(MEX FN) |
---|
123 | IF(MATLAB_FOUND) |
---|
124 | INCLUDE_DIRECTORIES(${MATLAB_INCLUDE_DIR} "${BDM_SOURCE_DIR}/bdm") |
---|
125 | LINK_DIRECTORIES("${BDM_SOURCE_DIR}/bdm") |
---|
126 | IF(APPLE) |
---|
127 | LINK_DIRECTORIES("/Applications/MATLAB_R2007b/bin/maci/") |
---|
128 | ENDIF(APPLE) |
---|
129 | IF(WIN32) |
---|
130 | ADD_LIBRARY("${FN}.${MATLAB_MEX_SUFFIX}" MODULE ${FN}.cpp "${BDM_SOURCE_DIR}/system/mexFunction.def") |
---|
131 | ELSE(WIN32) |
---|
132 | ADD_LIBRARY("${FN}.${MATLAB_MEX_SUFFIX}" MODULE ${FN}.cpp) |
---|
133 | ENDIF(WIN32) |
---|
134 | |
---|
135 | set_target_properties("${FN}.${MATLAB_MEX_SUFFIX}" PROPERTIES |
---|
136 | PREFIX "" |
---|
137 | SUFFIX "" |
---|
138 | COMPILE_FLAGS "-DMEX" |
---|
139 | ) |
---|
140 | # general libraries |
---|
141 | TARGET_LINK_LIBRARIES("${FN}.${MATLAB_MEX_SUFFIX}" ${MATLAB_LIBRARIES} bdm itpp) |
---|
142 | # platform specific libraries |
---|
143 | IF(WIN32) |
---|
144 | target_link_libraries ("${FN}.${MATLAB_MEX_SUFFIX}" libacml_dll) |
---|
145 | ELSE(WIN32) |
---|
146 | IF(APPLE) |
---|
147 | target_link_libraries ("${FN}.${MATLAB_MEX_SUFFIX}" ${FRAMEWORK_VECLIB}) |
---|
148 | ENDIF(APPLE) |
---|
149 | ENDIF(WIN32) |
---|
150 | ## Additional libraries can be added to a macro |
---|
151 | target_link_libraries ("${FN}.${MATLAB_MEX_SUFFIX}" ${ARGN}) |
---|
152 | ENDIF(MATLAB_FOUND) |
---|
153 | ENDMACRO(MEX) |
---|