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 | ADD_DEFINITIONS(-DLIBCONFIG_STATIC -DLIBCONFIGXX_STATIC) |
---|
30 | ENDIF(WIN32) |
---|
31 | IF(APPLE) |
---|
32 | IF(NOT ITPP_DIR) |
---|
33 | SET(ITPP_DIR "${BDM_SOURCE_DIR}/system/macosx/itpp-4.0.6") |
---|
34 | ENDIF(NOT ITPP_DIR) |
---|
35 | FIND_LIBRARY(FRAMEWORK_VECLIB vecLib) |
---|
36 | ADD_DEFINITIONS(-DHAVE_XLOCALE_H) |
---|
37 | ENDIF(APPLE) |
---|
38 | IF(UNIX) |
---|
39 | # Generally this directory should not exist! |
---|
40 | # Use this location is you compile itpp from sources |
---|
41 | IF(NOT ITPP_DIR) |
---|
42 | SET(ITPP_DIR "${BDM_SOURCE_DIR}/system/linux/") |
---|
43 | ENDIF(NOT ITPP_DIR) |
---|
44 | #This is for UNIX makefile which does only one release at a time. |
---|
45 | ENDIF(UNIX) |
---|
46 | |
---|
47 | # Local ettings should be written to file called CMakeLists.local |
---|
48 | # Use this option for machine-specific options, such as prallel architectures |
---|
49 | INCLUDE(CMakeLists.local OPTIONAL) |
---|
50 | |
---|
51 | FIND_PACKAGE(ITPP REQUIRED) |
---|
52 | FIND_PACKAGE(ACML COMPONENTS) |
---|
53 | FIND_PACKAGE(Matlab COMPONENTS) |
---|
54 | |
---|
55 | IF(ITPP_FOUND) |
---|
56 | INCLUDE_DIRECTORIES(${ITPP_INCLUDE_DIR}) |
---|
57 | LINK_DIRECTORIES(${NATIVE_ITPP_LIB_PATH}) |
---|
58 | ENDIF(ITPP_FOUND) |
---|
59 | |
---|
60 | IF(ACML_FOUND) |
---|
61 | INCLUDE_DIRECTORIES(${ACML_INCLUDE_DIR}) |
---|
62 | LINK_DIRECTORIES(${NATIVE_ACML_LIB_PATH}) |
---|
63 | ENDIF(ACML_FOUND) |
---|
64 | |
---|
65 | IF(UNIX) |
---|
66 | SET(CMAKE_BUILD_TYPE Debug) |
---|
67 | IF(MATLAB_FOUND) |
---|
68 | SET(CMAKE_CXX_FLAGS "-Wall -pipe -Wno-unknown-pragmas -fPIC") |
---|
69 | SET(CMAKE_C_FLAGS "-Wall -pipe -Wno-unknown-pragmas -fPIC") |
---|
70 | ELSE(MATLAB_FOUND) |
---|
71 | SET(CMAKE_CXX_FLAGS "-Wall -Wno-unknown-pragmas ") |
---|
72 | SET(CMAKE_C_FLAGS "-Wall -Wno-unknown-pragmas ") |
---|
73 | ENDIF(MATLAB_FOUND) |
---|
74 | |
---|
75 | SET(CMAKE_CXX_FLAGS_RELEASE " -DNDEBUG -O2") |
---|
76 | SET(CMAKE_CXX_FLAGS_DEBUG "-g -O0") |
---|
77 | ENDIF(UNIX) |
---|
78 | |
---|
79 | ## |
---|
80 | ## PREPARE MACROS for building executables |
---|
81 | ## |
---|
82 | |
---|
83 | MACRO(EXEC FN) |
---|
84 | add_executable (${FN} ${FN}.cpp) |
---|
85 | IF(WIN32) |
---|
86 | target_link_libraries (${FN} debug itpp_debug) |
---|
87 | target_link_libraries (${FN} optimized itpp) |
---|
88 | target_link_libraries (${FN} libacml_dll) |
---|
89 | ELSE(WIN32) |
---|
90 | IF(APPLE) |
---|
91 | target_link_libraries (${FN} ${FRAMEWORK_VECLIB}) |
---|
92 | ENDIF(APPLE) |
---|
93 | IF(ITPP_LIBRARY_DEBUG) |
---|
94 | target_link_libraries (${FN} debug itpp_debug) |
---|
95 | target_link_libraries (${FN} optimized itpp) |
---|
96 | ELSE(ITPP_LIBRARY_DEBUG) |
---|
97 | target_link_libraries (${FN} itpp) |
---|
98 | ENDIF(ITPP_LIBRARY_DEBUG) |
---|
99 | ENDIF(WIN32) |
---|
100 | target_link_libraries (${FN} bdm) |
---|
101 | target_link_libraries (${FN} ${ARGN}) ## Additional libraries can be added to a macro |
---|
102 | ENDMACRO(EXEC) |
---|
103 | |
---|
104 | MACRO(LINK_EXEC FN) |
---|
105 | IF(WIN32) |
---|
106 | target_link_libraries (${FN} debug itpp_debug) |
---|
107 | target_link_libraries (${FN} optimized itpp) |
---|
108 | target_link_libraries (${FN} libacml_dll) |
---|
109 | ELSE(WIN32) |
---|
110 | IF(APPLE) |
---|
111 | target_link_libraries (${FN} ${FRAMEWORK_VECLIB}) |
---|
112 | ENDIF(APPLE) |
---|
113 | IF(ITPP_LIBRARY_DEBUG) |
---|
114 | target_link_libraries (${FN} debug itpp_debug) |
---|
115 | target_link_libraries (${FN} optimized itpp) |
---|
116 | ELSE(ITPP_LIBRARY_DEBUG) |
---|
117 | target_link_libraries (${FN} itpp) |
---|
118 | ENDIF(ITPP_LIBRARY_DEBUG) |
---|
119 | ENDIF(WIN32) |
---|
120 | target_link_libraries (${FN} bdm) |
---|
121 | ENDMACRO(LINK_EXEC) |
---|
122 | |
---|
123 | MACRO(MEX FN) |
---|
124 | IF(MATLAB_FOUND) |
---|
125 | INCLUDE_DIRECTORIES(${MATLAB_INCLUDE_DIR} "${BDM_SOURCE_DIR}/bdm") |
---|
126 | LINK_DIRECTORIES("${BDM_SOURCE_DIR}/bdm") |
---|
127 | IF(APPLE) |
---|
128 | LINK_DIRECTORIES("/Applications/MATLAB_R2007b/bin/maci/") |
---|
129 | ENDIF(APPLE) |
---|
130 | IF(WIN32) |
---|
131 | ADD_LIBRARY("${FN}.${MATLAB_MEX_SUFFIX}" MODULE ${FN}.cpp "${BDM_SOURCE_DIR}/system/mexFunction.def") |
---|
132 | ELSE(WIN32) |
---|
133 | ADD_LIBRARY("${FN}.${MATLAB_MEX_SUFFIX}" MODULE ${FN}.cpp) |
---|
134 | ENDIF(WIN32) |
---|
135 | |
---|
136 | set_target_properties("${FN}.${MATLAB_MEX_SUFFIX}" PROPERTIES |
---|
137 | PREFIX "" |
---|
138 | SUFFIX "" |
---|
139 | COMPILE_FLAGS "-DMEX" |
---|
140 | ) |
---|
141 | # general libraries |
---|
142 | TARGET_LINK_LIBRARIES("${FN}.${MATLAB_MEX_SUFFIX}" ${MATLAB_LIBRARIES} bdm itpp) |
---|
143 | # platform specific libraries |
---|
144 | IF(WIN32) |
---|
145 | target_link_libraries ("${FN}.${MATLAB_MEX_SUFFIX}" libacml_dll) |
---|
146 | ELSE(WIN32) |
---|
147 | IF(APPLE) |
---|
148 | target_link_libraries ("${FN}.${MATLAB_MEX_SUFFIX}" ${FRAMEWORK_VECLIB}) |
---|
149 | ENDIF(APPLE) |
---|
150 | ENDIF(WIN32) |
---|
151 | ## Additional libraries can be added to a macro |
---|
152 | target_link_libraries ("${FN}.${MATLAB_MEX_SUFFIX}" ${ARGN}) |
---|
153 | ENDIF(MATLAB_FOUND) |
---|
154 | ENDMACRO(MEX) |
---|