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