source: trunk/RuntimeLibrary/src/jmi/CMakeLists.txt @ 12148

Last change on this file since 12148 was 12148, checked in by randersson, 12 months ago

Updated CMakeLists to include libjmi_block_solver in installer

File size: 7.6 KB
Line 
1#    Copyright (C) 2014 Modelon AB
2
3#    This program is free software: you can redistribute it and/or modify
4#    it under the terms of the GNU General Public License version 3 as published
5#    by the Free Software Foundation, or optionally, under the terms of the
6#    Common Public License version 1.0 as published by IBM.
7
8#    This program is distributed in the hope that it will be useful,
9#    but WITHOUT ANY WARRANTY; without even the implied warranty of
10#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11#    GNU General Public License, or the Common Public License, for more details.
12
13#    You should have received copies of the GNU General Public License
14#    and the Common Public License along with this program.  If not,
15#    see <http://www.gnu.org/licenses/> or
16#    <http://www.ibm.com/developerworks/library/os-cpl.html/> respectively.
17
18# NOTE: CMake 2.8.6 is required since this is the version used in development.
19# The script is KNOWN NOT TO WORK WITH 2.8.3 and below (ExternalProject
20# interface changes). CMake 2.8.4 and 2.8.5 are not tested.
21cmake_minimum_required (VERSION 2.8.6 FATAL_ERROR)
22
23if(NOT TOP_SRC)
24    set(TOP_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../../../)
25    message(STATUS "TOP_SRC was not defined, using ${TOP_SRC}")
26endif()
27set(MSLCSOURCES ${TOP_SRC}/ThirdParty/MSL/Modelica/Resources/C-Sources)
28message(STATUS MSLCSOURCES=${MSLCSOURCES})
29
30set(JMICommonSources
31    # Types
32    jmi_types.h
33    jmi_types.c
34   
35    # Math
36    jmi_linear_algebra.h
37    jmi_linear_algebra.c
38   
39    # Logging sources
40    jmi_callbacks.h
41    jmi_log.h
42    jmi_log_impl.h
43    jmi_log.c
44)
45
46set(JMIBlockSourcesPartial
47    jmi_block_solver.h
48    jmi_block_solver_impl.h
49    jmi_block_log.h
50    jmi_kinsol_solver.h
51    jmi_brent_solver.h
52    jmi_minpack_solver.h
53    jmi_linear_solver.h
54    jmi_realtime_solver.h
55    jmi_simple_newton.h
56
57    jmi_block_solver.c
58    jmi_block_log.c
59    jmi_kinsol_solver.c
60    jmi_brent_solver.c
61    jmi_minpack_solver.c
62    jmi_linear_solver.c
63    jmi_realtime_solver.c
64    jmi_simple_newton.c
65)
66
67set(JMIODESolverSourcesPartial
68    jmi_ode_cvode.h
69    jmi_ode_euler.h
70    jmi_ode_solver.h
71    jmi_ode_solver_impl.h
72    jmi_ode_problem.h
73   
74    jmi_ode_cvode.c
75    jmi_ode_euler.c
76    jmi_ode_solver.c
77    jmi_ode_problem.c
78)
79
80set(JMIBlockSources     ${JMIBlockSourcesPartial}     ${JMICommonSources})
81set(JMIODESolverSources ${JMIODESolverSourcesPartial} ${JMICommonSources})
82
83set(JMISources   
84    jmi.h
85    jmi_array_none.h
86    jmi_block_residual.h
87    jmi_cs.h
88    jmi_me.h
89    jmi_util.h
90    jmi_global.h
91    jmi_delay.h
92    jmi_delay_impl.h
93    jmi_dynamic_state.h
94    jmi_chattering.h
95    jmi_work_array.h
96    jmi_math.h
97    jmi_math_ad.h
98    jmi_types.h
99   
100    jmi_util.c
101    jmi_global.c
102    jmi.c
103    jmi_array_none.c
104    jmi_types.c
105    jmi_dyn_mem.c
106    jmi_dyn_mem_.c
107    jmi_block_residual.c
108    jmi_cs.c
109    jmi_me.c
110    jmi_delay.c
111    jmi_dynamic_state.c
112    jmi_chattering.c
113    jmi_work_array.c
114    jmi_math.c
115    jmi_math_ad.c
116   
117    ${JMICommonSources}
118    ${JMIBlockSourcesPartial}
119    ${JMIODESolverSourcesPartial}
120)
121
122# Source files for ModelicaExternalC
123set(MODELICAEXTERNALCSources
124    jmi_global.h
125    ModelicaUtilities.h
126   
127    jmi_global.c
128    ModelicaUtilities.c
129   
130    ${MSLCSOURCES}/ModelicaInternal.c
131    ${MSLCSOURCES}/ModelicaStrings.c
132    ${MSLCSOURCES}/ModelicaRandom.c
133    ${MSLCSOURCES}/ModelicaFFT.c
134)
135
136# Source files for Zlib
137set(ZLIB_SOURCES
138    ${MSLCSOURCES}/zlib/adler32.c
139    ${MSLCSOURCES}/zlib/compress.c
140    ${MSLCSOURCES}/zlib/crc32.c
141    ${MSLCSOURCES}/zlib/deflate.c
142    ${MSLCSOURCES}/zlib/gzclose.c
143    ${MSLCSOURCES}/zlib/gzlib.c
144    ${MSLCSOURCES}/zlib/gzread.c
145    ${MSLCSOURCES}/zlib/gzwrite.c
146    ${MSLCSOURCES}/zlib/infback.c
147    ${MSLCSOURCES}/zlib/inffast.c
148    ${MSLCSOURCES}/zlib/inflate.c
149    ${MSLCSOURCES}/zlib/inftrees.c
150    ${MSLCSOURCES}/zlib/trees.c
151    ${MSLCSOURCES}/zlib/uncompr.c
152    ${MSLCSOURCES}/zlib/zutil.c
153)
154
155include_directories(module_include)
156
157if(WIN32)
158    #Flag that is needed for compiling lib togheter with MINPACK, no dll is created.
159    add_definitions(-DCMINPACK_NO_DLL)
160endif()
161add_definitions(-DJMI_INCLUDE_MINPACK)
162
163OPTION(BUILD_BLOCK_SOLVER_LIB "Build the block solver library" ON)
164if (${BUILD_BLOCK_SOLVER_LIB})
165    add_library(jmi_block_solver STATIC ${JMIBlockSources})
166    if(NOT MSVC)
167        set_target_properties(jmi_block_solver PROPERTIES COMPILE_FLAGS "-Wall -g -std=c89 -pedantic -Werror -Wno-long-long -O2 -msse2 -mfpmath=sse")
168    endif()
169   
170    #Install the libraries
171    install(TARGETS jmi_block_solver
172        DESTINATION "${RTLIB_LIB_DIR}")
173   
174    if(JMI_SUNDIALS AND JMI_LAPACK AND JMI_MINPACK)
175        add_executable(jmi_block_solver_test jmi_block_solver_test.c)
176        target_link_libraries(jmi_block_solver_test jmi_block_solver ${JMI_SUNDIALS} ${JMI_LAPACK} ${JMI_MINPACK})
177        add_test(NAME jmi_block_solver_test COMMAND jmi_block_solver_test)
178    endif()
179endif()
180
181OPTION(BUILD_ODE_SOLVER_LIB "Build the ode solver library" ON)
182if (${BUILD_ODE_SOLVER_LIB})
183    add_library(jmi_ode_solver STATIC ${JMIODESolverSources})
184    if(NOT MSVC)
185        set_target_properties(jmi_ode_solver PROPERTIES COMPILE_FLAGS "-Wall -g -std=c89 -pedantic -Werror -Wno-long-long -O2 -msse2 -mfpmath=sse")
186    endif()
187   
188    if(JMI_SUNDIALS)
189        add_executable(jmi_ode_solver_test jmi_ode_solver_test.c)
190        target_link_libraries(jmi_ode_solver_test jmi_ode_solver ${JMI_SUNDIALS})
191        add_test(NAME jmi_ode_solver_test COMMAND jmi_ode_solver_test)
192    endif()
193endif()
194
195OPTION(BUILD_JMI_LIB "Build the jmi library" ON)
196if (${BUILD_JMI_LIB})
197    add_library(jmi STATIC ${JMISources})
198    if(NOT MSVC)
199        set_target_properties(jmi PROPERTIES COMPILE_FLAGS "-Wall -g -std=c89 -pedantic -Werror -Wno-long-long -O2 -msse2 -mfpmath=sse")
200    endif()
201    include_directories(${TOP_SRC}/RuntimeLibrary/src/jmi)
202
203    #Install the libraries
204    install(TARGETS jmi
205        DESTINATION "${RTLIB_LIB_DIR}")
206
207    #Install header files
208    install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/"
209        DESTINATION "${RTLIB_INCLUDE_DIR}"
210        FILES_MATCHING PATTERN "*.h")
211endif()
212
213OPTION(BUILD_MSL_EXTERNAL_LIBS "Build the MSL external libraries" ON)
214if (${BUILD_MSL_EXTERNAL_LIBS})
215    #Build ModelicaExternalC library
216    include_directories(${MSLCSOURCES})
217    include_directories(${MSLCSOURCES}/zlib)
218    add_library(ModelicaExternalC STATIC ${MODELICAEXTERNALCSources})
219    if(NOT MSVC)
220        set_target_properties(ModelicaExternalC PROPERTIES COMPILE_FLAGS "-Wall -g -std=c89 -pedantic")
221    endif()
222
223    #Build ModelicaStandardTables library
224    add_definitions("-DDUMMY_FUNCTION_USERTAB -DHAVE_ZLIB")
225    add_library(ModelicaStandardTables STATIC ${MSLCSOURCES}/ModelicaStandardTables.c)
226    if(NOT MSVC)
227        set_target_properties(ModelicaStandardTables PROPERTIES COMPILE_FLAGS "-Wall -g")
228    endif()
229
230    #Build ModelicaIO library
231    add_library(ModelicaIO STATIC ${MSLCSOURCES}/ModelicaIO.c)
232    if(NOT MSVC)
233        set_target_properties(ModelicaIO PROPERTIES COMPILE_FLAGS "-Wall -g")
234    endif()
235
236    #Build ModelicaMatIO library
237    add_library(ModelicaMatIO STATIC ${MSLCSOURCES}/ModelicaMatIO.c)
238    if(NOT MSVC)
239        set_target_properties(ModelicaMatIO PROPERTIES COMPILE_FLAGS "-Wall -g")
240    endif()
241
242    #Build Zlib library
243    add_library(zlib STATIC ${ZLIB_SOURCES})
244    if(NOT MSVC)
245        set_target_properties(ModelicaStandardTables PROPERTIES COMPILE_FLAGS "-Wall -g")
246    endif()
247
248    #Install the libraries
249    install(TARGETS ModelicaExternalC ModelicaStandardTables ModelicaIO ModelicaMatIO zlib
250        DESTINATION "${RTLIB_LIB_DIR}")
251
252    install(DIRECTORY "${MSLCSOURCES}/"
253        DESTINATION "${RTLIB_INCLUDE_DIR}"
254        FILES_MATCHING PATTERN "*.h")
255endif()
256
Note: See TracBrowser for help on using the repository browser.