root/library/system/SetBdmEnv.cmake @ 1204

Revision 1024, 3.3 kB (checked in by smidl, 14 years ago)

win32

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