root/library/system/SetBdmEnv.cmake @ 621

Revision 582, 4.4 kB (checked in by smidl, 15 years ago)

eol native

  • 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 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)
29ENDIF(WIN32)
30IF(APPLE)
31        IF(NOT ITPP_DIR)
32                SET(ITPP_DIR "${BDM_SOURCE_DIR}/macosx/itpp-4.0.6")
33        ENDIF(NOT ITPP_DIR)
34        FIND_LIBRARY(FRAMEWORK_VECLIB vecLib)
35        ADD_DEFINITIONS(-DHAVE_XLOCALE_H)
36ENDIF(APPLE)
37IF(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.
44ENDIF(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
48INCLUDE(CMakeLists.local OPTIONAL)     
49
50FIND_PACKAGE(ITPP REQUIRED)
51FIND_PACKAGE(ACML COMPONENTS)
52FIND_PACKAGE(Matlab COMPONENTS)
53FIND_PROGRAM(MEX_COMPILER mex)
54
55IF(ITPP_FOUND)
56        INCLUDE_DIRECTORIES(${ITPP_INCLUDE_DIR})
57        LINK_DIRECTORIES(${NATIVE_ITPP_LIB_PATH})
58ENDIF(ITPP_FOUND)
59
60IF(ACML_FOUND)
61        INCLUDE_DIRECTORIES(${ACML_INCLUDE_DIR})
62        LINK_DIRECTORIES(${NATIVE_ACML_LIB_PATH})
63ENDIF(ACML_FOUND)
64
65IF(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")
77ENDIF(UNIX)
78
79##
80## PREPARE MACROS for building executables
81##
82
83MACRO(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
102ENDMACRO(EXEC)
103
104MACRO(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)
121ENDMACRO(LINK_EXEC)
122       
123MACRO(MEX FN)
124        IF(MEX_COMPILER)
125        INCLUDE_DIRECTORIES(${MATLAB_INCLUDE_DIR} "${BDM_SOURCE_DIR}/bdm")
126        LINK_DIRECTORIES("${BDM_SOURCE_DIR}/bdm")
127        IF(WIN32)
128                ADD_DEFINITIONS(/EXPORT:_mexFunction)
129        ENDIF(WIN32)
130        ADD_LIBRARY("${FN}.${MATLAB_MEX_SUFFIX}" MODULE ${FN}.cpp)
131        set_target_properties("${FN}.${MATLAB_MEX_SUFFIX}" PROPERTIES
132                PREFIX ""
133                SUFFIX ""
134                COMPILE_FLAGS "-DMEX"
135        )
136        # general libraries
137        TARGET_LINK_LIBRARIES("${FN}.${MATLAB_MEX_SUFFIX}" ${MATLAB_LIBRARIES} bdm itpp)
138        # platform specific libraries
139        IF(WIN32)
140                target_link_libraries ("${FN}.${MATLAB_MEX_SUFFIX}" libacml_dll)
141        ELSE(WIN32)
142                IF(APPLE)
143                        target_link_libraries ("${FN}.${MATLAB_MEX_SUFFIX}" ${FRAMEWORK_VECLIB})
144                ENDIF(APPLE)
145        ENDIF(WIN32)
146        ## Additional libraries can be added to a macro
147        target_link_libraries ("${FN}.${MATLAB_MEX_SUFFIX}" ${ARGN})
148        ENDIF(MEX_COMPILER)
149ENDMACRO(MEX)
Note: See TracBrowser for help on using the browser.