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 ACML_DIR) |
---|
19 | SET(ACML_DIR "${BDM_SOURCE_DIR}\\system\\win32\\acml3.6.0") |
---|
20 | ENDIF(NOT ACML_DIR) |
---|
21 | |
---|
22 | INCLUDE(\\system\\win32\\local_paths.txt OPTIONAL) |
---|
23 | ADD_DEFINITIONS(-DHAVE_ACML) |
---|
24 | ADD_DEFINITIONS(/wd4290) |
---|
25 | ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -D_HAS_CPP0X=0) |
---|
26 | ADD_DEFINITIONS(-DLIBCONFIG_STATIC -DLIBCONFIGXX_STATIC) |
---|
27 | |
---|
28 | FIND_PACKAGE(ACML REQUIRED) |
---|
29 | IF(ACML_FOUND) |
---|
30 | INCLUDE_DIRECTORIES(${ACML_INCLUDE_DIR}) |
---|
31 | ADD_DEFINITIONS(-DHAVE_LAPACK) |
---|
32 | LINK_DIRECTORIES(${NATIVE_ACML_LIB_PATH}) |
---|
33 | ENDIF(ACML_FOUND) |
---|
34 | SET(lapack_libs libacml_dll) |
---|
35 | ENDIF(WIN32) |
---|
36 | IF(APPLE) |
---|
37 | FIND_LIBRARY(FRAMEWORK_VECLIB vecLib) |
---|
38 | ADD_DEFINITIONS(-DHAVE_XLOCALE_H) |
---|
39 | SET(lapack_libs ${FRAMEWORK_VECLIB}) |
---|
40 | ENDIF(APPLE) |
---|
41 | IF(UNIX) |
---|
42 | SET(lapack_libs lapack blas) |
---|
43 | ENDIF(UNIX) |
---|
44 | |
---|
45 | # Local ettings should be written to file called CMakeLists.local |
---|
46 | # Use this option for machine-specific options, such as prallel architectures |
---|
47 | INCLUDE(CMakeLists.local OPTIONAL) |
---|
48 | |
---|
49 | FIND_PACKAGE(Matlab COMPONENTS) |
---|
50 | |
---|
51 | |
---|
52 | ## BUILD own ITPP |
---|
53 | INCLUDE_DIRECTORIES("${BDM_SOURCE_DIR}/bdm/base")#${ITPP_INCLUDE_DIR}) |
---|
54 | LINK_DIRECTORIES("${BDM_SOURCE_DIR}/bdm/base/itpp")#${NATIVE_ITPP_LIB_PATH}) |
---|
55 | |
---|
56 | |
---|
57 | IF(UNIX) |
---|
58 | SET(CMAKE_BUILD_TYPE Debug) |
---|
59 | IF(MATLAB_FOUND) |
---|
60 | SET(CMAKE_CXX_FLAGS "-Wall -pipe -Wno-unknown-pragmas -fPIC") |
---|
61 | SET(CMAKE_C_FLAGS "-Wall -pipe -Wno-unknown-pragmas -fPIC") |
---|
62 | ELSE(MATLAB_FOUND) |
---|
63 | SET(CMAKE_CXX_FLAGS "-Wall -Wno-unknown-pragmas ") |
---|
64 | SET(CMAKE_C_FLAGS "-Wall -Wno-unknown-pragmas ") |
---|
65 | ENDIF(MATLAB_FOUND) |
---|
66 | |
---|
67 | SET(CMAKE_CXX_FLAGS_RELEASE " -DNDEBUG -O2") |
---|
68 | SET(CMAKE_CXX_FLAGS_DEBUG "-g -O0") |
---|
69 | ENDIF(UNIX) |
---|
70 | |
---|
71 | ## |
---|
72 | ## PREPARE MACROS for building executables |
---|
73 | ## |
---|
74 | |
---|
75 | MACRO(EXEC FN) |
---|
76 | add_executable (${FN} ${FN}.cpp) |
---|
77 | target_link_libraries (${FN} bdm) |
---|
78 | target_link_libraries (${FN} itpp) |
---|
79 | target_link_libraries (${FN} ${lapack_libs}) |
---|
80 | target_link_libraries (${FN} ${ARGN}) ## Additional libraries can be added to a macro |
---|
81 | ENDMACRO(EXEC) |
---|
82 | |
---|
83 | MACRO(LINK_EXEC FN) |
---|
84 | target_link_libraries (${FN} bdm) |
---|
85 | target_link_libraries (${FN} itpp) |
---|
86 | target_link_libraries (${FN} ${lapack_libs}) |
---|
87 | ENDMACRO(LINK_EXEC) |
---|
88 | |
---|
89 | MACRO(MEX FN) |
---|
90 | IF(MATLAB_FOUND) |
---|
91 | INCLUDE_DIRECTORIES(${MATLAB_INCLUDE_DIR} "${BDM_SOURCE_DIR}/bdm") |
---|
92 | LINK_DIRECTORIES("${BDM_SOURCE_DIR}/bdm") |
---|
93 | IF(APPLE) |
---|
94 | LINK_DIRECTORIES("/Applications/MATLAB_R2007b/bin/maci/") |
---|
95 | ENDIF(APPLE) |
---|
96 | IF(WIN32) |
---|
97 | ADD_LIBRARY("${FN}.${MATLAB_MEX_SUFFIX}" MODULE ${FN}.cpp "${BDM_SOURCE_DIR}/system/mexFunction.def") |
---|
98 | ELSE(WIN32) |
---|
99 | ADD_LIBRARY("${FN}.${MATLAB_MEX_SUFFIX}" MODULE ${FN}.cpp) |
---|
100 | ENDIF(WIN32) |
---|
101 | |
---|
102 | set_target_properties("${FN}.${MATLAB_MEX_SUFFIX}" PROPERTIES |
---|
103 | PREFIX "" |
---|
104 | SUFFIX "" |
---|
105 | COMPILE_FLAGS "-DMEX" |
---|
106 | ) |
---|
107 | # general libraries |
---|
108 | TARGET_LINK_LIBRARIES("${FN}.${MATLAB_MEX_SUFFIX}" ${MATLAB_LIBRARIES} bdm itpp ${lapack_libs}) |
---|
109 | ## Additional libraries can be added to a macro |
---|
110 | target_link_libraries ("${FN}.${MATLAB_MEX_SUFFIX}" ${ARGN}) |
---|
111 | ENDIF(MATLAB_FOUND) |
---|
112 | ENDMACRO(MEX) |
---|