forked from casadi/casadi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
625 lines (537 loc) · 21.9 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
cmake_minimum_required(VERSION 2.8.6)
project(casadi C CXX)
set(PACKAGE_NAME "CasADi")
set(PACKAGE_VERSION "3.0.0")
set(PACKAGE_SO_VERSION "3.0")
set(PACKAGE_DESCRIPTION "CasADi is a symbolic framework for automatic differentation and numeric optimization")
set(PACKAGE_AUTHOR "Joel Andersson and Joris Gillis")
set(PACKAGE_MAINTAINER "Joel Andersson and Joris Gillis")
set(PACKAGE_URL "http://casadi.org")
#############################################################
########################## Version ##########################
#############################################################
# For systems with git installed, find out revsion and description.
execute_process(COMMAND git rev-parse HEAD
OUTPUT_VARIABLE git_revision
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
)
execute_process(COMMAND git describe --first-parent HEAD
OUTPUT_VARIABLE git_describe
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
)
# special version number for pkg-config, use n.n.n.n where n are all numbers
string(REGEX REPLACE "-g.*" "" PACKAGE_VERSION_PKGCONFIG "${git_describe}")
string(REPLACE "+-" "." PACKAGE_VERSION_PKGCONFIG "${PACKAGE_VERSION_PKGCONFIG}")
string(REPLACE "+-" "+" git_describe "${git_describe}")
string(REPLACE "-g" "." git_describe "${git_describe}")
set(PACKAGE_VERSION_FULL "${git_describe}")
# overwrite version numbers for official release
if((PACKAGE_VERSION_FULL STREQUAL "") OR (NOT PACKAGE_VERSION MATCHES "\\+"))
set(PACKAGE_VERSION_PKGCONFIG "${PACKAGE_VERSION}")
set(PACKAGE_VERSION_FULL "${PACKAGE_VERSION}")
endif()
##################################################################
########################## Options ###############################
##################################################################
option(WITH_EXTRA_WARNINGS "Add extra warnings (like -Wall -Wextra)" OFF)
option(WITH_WERROR "Add -Werror" OFF)
option(WITH_DL "Enable dynamic loading of functions" ON)
option(WITH_DOC "Enable documentation generation" OFF)
option(ENABLE_EXPORT_ALL "Export all symbols to a shared library" OFF)
option(WITH_EXAMPLES "Build examples" ON)
option(WITH_OPENMP "Compile with parallelization support" OFF)
option(WITH_OOQP "Enable OOQP interface" ON)
option(WITH_SQIC "Enable SQIC interface" OFF)
option(WITH_SLICOT "Enable SLICOT interface" OFF)
option(WITH_WORHP "Compile the WORHP interface" OFF)
option(WITH_SNOPT "Compile the SNOPT interface if SNOPT libraries can be found" ON)
option(WITH_SNOPT_FORCE_DUMMY "Compile the SNOPT interface against a dummy library (for Debian distribution; breaks normal snopt build)" OFF)
option(WITH_ACADO "Compile the interfaces to ACADO and qpOASES, if it can be found" OFF)
option(WITH_EIGEN3 "Use Eigen3 backend for matrix operations" OFF)
option(WITH_BUILD_SUNDIALS "Compile the included source code for Sundials 2.5" ON)
option(WITH_SUNDIALS "Compile the interface to Sundials" ON)
option(WITH_QPOASES "Compile the interface to qpOASES (the source code for qpOASES 3.0beta is included)" ON)
option(WITH_BUILD_DSDP "Compile the the included source code for DSDP" ON)
option(WITH_DSDP "Compile the interface to DSDP" ON)
option(WITH_MOSEK "Compile the interface to MOSEK" OFF)
option(WITH_ECOS "Compile the interface to ECOS" OFF)
option(WITH_BUILD_CSPARSE "Compile the included source code for CSparse" ON)
option(WITH_CSPARSE "Compile the interface to CSparse" ON)
option(WITH_GUROBI "Compile the interface to GUROBI" ON)
option(WITH_IPOPT "Compile the interface to IPOPT" ON)
option(WITH_KNITRO "Compile the interface to KNITRO" ON)
option(WITH_CPLEX "Compile the interface to CPLEX" ON)
option(WITH_LAPACK "Compile the interface to LAPACK" ON)
option(WITH_OPENCL "Compile with OpenCL support (experimental)" OFF)
option(WITH_BUILD_TINYXML "Compile the included TinyXML source code" ON)
option(WITH_TINYXML "Compile the interface to TinyXML" ON)
option(WITH_COVERAGE "Create coverage report" OFF)
option(OLD_LLVM "Use pre-3.5 LLVM" OFF)
option(WITH_CLANG "Compile the interface to clang JIT" OFF)
option(WITH_MATLAB "Compile the MATLAB front-end (experimental)" OFF)
option(WITH_PYTHON "Compile the Python front-end" OFF)
option(WITH_JSON "Compile the JSON front-end" OFF)
option(WITH_DEBIAN_BUILD "Add -DWITH_DEBIAN_BUILD (used for debian-specific warnings)" OFF)
option(WITH_DEEPBIND "Load plugins with RTLD_DEEPBIND (can be used to resolve conflicting libraries in e.g. MATLAB)" OFF)
option(WITH_SELFCONTAINED "Make the install directory self-contained" OFF)
option(WITH_DEPRECATED_FEATURES "Compile with syntax that is scheduled to be deprecated" ON)
option(WITH_EXTENDING_CASADI "Compile a demonstration that shows how a project that depends on CasADi can be implemented." OFF)
# static on windows, shared on linux/osx by default
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
option(ENABLE_STATIC "Compile static libraries (.a on Linux)" ON)
option(ENABLE_SHARED "Compile shared libraries (.so on Linux)" OFF)
else()
option(ENABLE_STATIC "Compile static libraries (.a on Linux)" OFF)
option(ENABLE_SHARED "Compile shared libraries (.so on Linux)" ON)
endif()
############################################################
####################### Fortran ############################
############################################################
# begin workaround for
# http://public.kitware.com/Bug/print_bug_page.php?bug_id=9220
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
include(language_support)
workaround_9220(Fortran Fortran_language_works)
if(Fortran_language_works)
enable_language(Fortran OPTIONAL)
endif()
#end workaround
include(CppLint)
include(SpellCheck)
include(embed_resources)
include(GenerateExportHeader)
############################################################
####################### Policies ###########################
############################################################
# Enforce cmake2.4+ style behaviour for
# mixed filename/full path linker directives
cmake_policy(SET CMP0003 NEW)
# cmake_policy propagation rules
if(POLICY CMP0011)
cmake_policy(SET CMP0011 OLD)
endif()
# cmake_policy avoid escaping in add_definitions
cmake_policy(SET CMP0005 OLD)
# cmake_policy use MACOSX_RPATH=ON by default
if(POLICY CMP0042)
cmake_policy(SET CMP0042 NEW)
endif()
############################################################
####################### macports python ####################
############################################################
# find the macports python libs if they exist
if(APPLE)
set(CMAKE_LIBRARY_PATH /opt/local/lib ${CMAKE_LIBRARY_PATH})
endif()
# We use the FeatureSummary module to get a more readable CMake output
include(FeatureSummary)
if(NOT COMMAND add_feature_info)
function(add_feature_info _name _enabled _description)
message(STATUS "Detected: ${_name} ${_description}")
endfunction()
function(feature_summary)
endfunction()
endif()
############################################################
######################## rpath #############################
############################################################
if(WITH_SELFCONTAINED)
if(APPLE)
set(CMAKE_INSTALL_RPATH "@loader_path/")
else()
set(CMAKE_INSTALL_RPATH "$ORIGIN")
endif()
else()
# use, i.e. don't skip the full RPATH for the build tree
set(CMAKE_SKIP_BUILD_RPATH FALSE)
# when building, don't use the install RPATH already
# (but later on when installing)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib;${CMAKE_INSTALL_PREFIX}/lib/casadi")
# add the automatically determined parts of the RPATH
# which point to directories outside the build tree to the install RPATH
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
# the RPATH to be used when installing, but only if it's not a system directory
list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
if("${isSystemDir}" STREQUAL "-1")
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib;${CMAKE_INSTALL_PREFIX}/lib/casadi")
endif("${isSystemDir}" STREQUAL "-1")
endif()
# For code optimization
if(CMAKE_BUILD_TYPE)
else()
set(CMAKE_BUILD_TYPE Release)
#set(CMAKE_BUILD_TYPE Debug)
endif()
string(TOUPPER ${CMAKE_BUILD_TYPE} UPPER_CMAKE_BUILD_TYPE)
########################################################################
############################# C++11 ####################################
########################################################################
# Check if the compiler supports C++11
foreach(CXX11FLAG_TEST "" "-std=c++11" "-std=c++0x")
if(NOT USE_CXX11)
# Try to compile test with the proposed flag
try_compile(USE_CXX11
${CMAKE_BINARY_DIR}
${CMAKE_MODULE_PATH}/check_cxx11.cpp
CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${CXX11FLAG_TEST}
OUTPUT_VARIABLE OUTPUT)
# Save flag, if successful
if(USE_CXX11)
set(CXX11FLAG ${CXX11FLAG_TEST} CACHE INTERNAL "C++11 compile flag")
endif()
endif()
endforeach()
# If found, set flag
if(USE_CXX11)
if(CXX11FLAG)
message(STATUS "Flag needed for enabling C++11 features: ${CXX11FLAG}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX11FLAG}")
else()
message(STATUS "No flag needed for enabling C++11 features.")
endif()
add_definitions(-DUSE_CXX11)
else()
message(FATAL_ERROR "Cannot enable C++11 features.")
endif()
if(CXX11FLAG)
try_compile(HAS_COPYSIGN
${CMAKE_BINARY_DIR}
${CMAKE_MODULE_PATH}/check_copysign.cpp
CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${CXX11FLAG}
OUTPUT_VARIABLE OUTPUT)
if(HAS_COPYSIGN)
add_definitions(-DHAS_COPYSIGN)
endif()
try_compile(HAS_ERF
${CMAKE_BINARY_DIR}
${CMAKE_MODULE_PATH}/check_erf.cpp
CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${CXX11FLAG}
OUTPUT_VARIABLE OUTPUT)
if(HAS_ERF)
add_definitions(-DHAS_ERF)
endif()
try_compile(HAS_ERFINV
${CMAKE_BINARY_DIR}
${CMAKE_MODULE_PATH}/check_erfinv.cpp
CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${CXX11FLAG}
OUTPUT_VARIABLE OUTPUT)
if(HAS_ERFINV)
add_definitions(-DHAS_ERFINV)
endif()
endif()
# Check if mkstemps is available
if(NOT WIN32)
file(WRITE ${CMAKE_BINARY_DIR}/mkstemps_test.cxx
"#include <cstdlib>\n"
"#include <unistd.h>\n"
"int main() {\n"
" char tmp[] = \"mkstempstestXXXXXX.so\";\n"
" int flag = mkstemps(tmp, 3);\n"
" return flag;\n"
"}\n")
try_compile(HAVE_MKSTEMPS ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}/mkstemps_test.cxx
OUTPUT_VARIABLE HAVE_MKSTEMPS_OUTPUT)
if(HAVE_MKSTEMPS)
add_definitions(-DHAVE_MKSTEMPS)
else()
message(WARNING "mkstemp is not available, falling back on tmpnam. "
"Test compilation returned the following:\n"
"${HAVE_MKSTEMPS_OUTPUT}")
endif()
endif()
################################################################################
############################### compiler warnings ##############################
################################################################################
# add compiler warnings
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
if(WITH_EXTRA_WARNINGS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-unused-parameter -Wno-sign-compare")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat-security -Wno-unused-parameter -Wno-maybe-uninitialized -Wno-unused-but-set-variable -Wno-unused-function -Wno-unused-value")
endif()
if(WITH_WERROR)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
endif()
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
if(WITH_EXTRA_WARNINGS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-unused-parameter -Wno-sign-compare -Wno-mismatched-tags -Wno-tautological-compare")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat-security -Wno-unused-parameter -Wno-unused-function -Wno-unused-value")
endif()
if(WITH_WERROR)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
endif()
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
if(WITH_EXTRA_WARNINGS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-unused-parameter -Wno-sign-compare")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat-security -Wno-unused-parameter -Wno-maybe-uninitialized -Wno-unused-but-set-variable -Wno-unused-function -Wno-unused-value")
endif()
if(WITH_WERROR)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
endif()
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
# I don't know the MSVC warnings, so do nothing for now
endif()
#######################################################################
############################# -fPIC ###################################
#######################################################################
# the following commands are needed to fix a problem with the libraries
# for linux 64 bits
if("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64")
message(STATUS "x86_64 architecture detected - setting flag -fPIC")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fPIC")
endif()
#######################################################################
########################### code coverage #############################
#######################################################################
if(WITH_COVERAGE)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -fprofile-arcs -ftest-coverage")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -fprofile-arcs -ftest-coverage")
set(CMAKE_EXE_LINKER_FLAGS " -lgcov -fprofile-arcs --coverage ${CMAKE_EXE_LINKER_FLAGS}")
endif()
if(MINGW)
# Circumventing a bug in MinGW g++ v4.7.2, evoked by 752fa89355ffa
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-ipa-cp-clone")
endif()
# Tentative fix for https://github.com/casadi/casadi/issues/1665
if(MINGW OR ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") OR ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel"))
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fkeep-inline-functions")
endif()
# Necessary for Visual C++
add_definitions(-D_USE_MATH_DEFINES)
add_definitions(-D_SCL_SECURE_NO_WARNINGS)
if(WITH_DL)
add_definitions(-DWITH_DL)
endif()
add_feature_info(dynamic-loading WITH_DL "Compile with support for dynamic loading of generated functions (needed for ExternalFunction)")
if(WITH_PRINTME)
add_definitions(-DWITH_PRINTME)
endif()
if(WITH_DEBIAN_BUILD)
add_definitions(-DWITH_DEBIAN_BUILD)
endif()
if (WITH_DEPRECATED_FEATURES)
add_definitions(-DWITH_DEPRECATED_FEATURES)
endif()
include_directories(.)
include_directories(${CMAKE_BINARY_DIR})
#######################################################################
########################### find packages ############################
#######################################################################
# Optional auxillary dependencies
find_package(BLAS QUIET)
find_package(HSL QUIET)
find_package(WSMP QUIET)
find_package(METIS QUIET)
find_package(LibXml2 QUIET)
if(WITH_LAPACK)
find_package(LAPACK)
endif()
add_feature_info(lapack-interface LAPACK_FOUND "Interface to LAPACK.")
#######################################################################
################# third-party libraries we can build ##################
#######################################################################
# sundials
if(WITH_SUNDIALS)
if(WITH_BUILD_SUNDIALS)
# build the included sundials
set(SUNDIALS_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/external_packages/sundials-2.5mod)
set(SUNDIALS_LIBRARIES casadi_sundials)
set(SUNDIALS_FOUND ON)
else()
# try to find system sundials
add_definitions(-DWITH_SYSTEM_SUNDIALS)
find_package(SUNDIALS)
endif()
endif()
add_feature_info(sundials-interface SUNDIALS_FOUND "Interface to the ODE/DAE integrator suite SUNDIALS.")
# CSparse
if(WITH_CSPARSE)
if(WITH_BUILD_CSPARSE)
# build the included csparse
set(CSPARSE_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/external_packages/CSparse/Include)
set(CSPARSE_LIBRARIES casadi_csparse)
set(CSPARSE_FOUND ON)
else()
# try to find system csparse
find_package(CSPARSE)
endif()
endif()
add_feature_info(csparse-interface CSPARSE_FOUND "Interface to the sparse direct linear solver CSparse.")
# TinyXML
if(WITH_TINYXML)
if(WITH_BUILD_TINYXML)
# build the included tinyxml
set(TINYXML_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/external_packages/tinyxml-2.6.2)
set(TINYXML_LIBRARIES casadi_tinyxml)
set(TINYXML_FOUND ON)
else()
# try to find system tinyxml
find_package(TINYXML)
endif()
endif()
add_feature_info(tinyxml-interface TINYXML_FOUND "Interface to the XML parser TinyXML.")
# DSDP
if(WITH_DSDP)
if(WITH_BUILD_DSDP AND BLAS_FOUND AND LAPACK_FOUND)
# build the included dsdp
set(DSDP_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/external_packages/DSDP/include)
set(DSDP_LIBRARIES casadi_dsdp)
set(DSDP_FOUND true)
else()
# try to find system dsdp
find_package(DSDP)
endif()
endif()
add_feature_info(dsdp-interface DSDP_FOUND "Interface to the interior point SDP solver DSDP.")
# MOSEK
if(WITH_MOSEK)
# try to find system mosek
find_package(MOSEK)
endif()
add_feature_info(mosek-interface MOSEK_FOUND "Interface to the interior point SOCP solver MOSEK.")
# CLANG
if(WITH_CLANG)
# try to find system CLANG
find_package(CLANG)
endif()
add_feature_info(clang-interface CLANG_FOUND "Interface to the Clang JIT compiler.")
# ECOS
if(WITH_ECOS)
# try to find system ecos
find_package(ECOS)
endif()
add_feature_info(ecos-interface ECOS_FOUND "Interface to the interior point SOCP solver ECOS.")
# Use the included qpOASES
if(WITH_QPOASES AND BLAS_FOUND AND LAPACK_FOUND)
set(QPOASES_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/external_packages/qpOASES/include)
set(QPOASES_LIBRARIES casadi_qpoases)
set(QPOASES_FOUND true)
endif()
add_feature_info(qpoases-interface QPOASES_FOUND "Interface to the active-set QP solver qpOASES.")
#######################################################################
############### third-party libraries we don't build ##################
#######################################################################
# enabling openmp support if requesed
if(WITH_OPENMP)
find_package(OpenMP)
if(OPENMP_FOUND)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS} -DWITH_OPENMP")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS} -DWITH_OPENMP")
endif()
endif()
# OpenCL
if(WITH_OPENCL)
# Core depends on OpenCL for GPU calculations
find_package(OpenCL REQUIRED)
add_definitions(-DWITH_OPENCL)
include_directories(${OPENCL_INCLUDE_DIRS})
endif()
add_feature_info(opencl-support WITH_OPENCL "Enable just-in-time compiliation to CPUs and GPUs with OpenCL.")
if(WITH_IPOPT)
find_package(IPOPT)
endif()
add_feature_info(ipopt-interface IPOPT_FOUND "Interface to the NLP solver Ipopt.")
if(WITH_KNITRO)
find_package(KNITRO)
endif()
add_feature_info(knitro-interface KNITRO_FOUND "Interface to the NLP solver KNITRO.")
if(WITH_CPLEX)
find_package(CPLEX)
endif()
add_feature_info(cplex-interface CPLEX_FOUND "Interface to the QP solver CPLEX.")
if(WITH_SNOPT)
find_package(SNOPT)
endif()
# if(WITH_GSL)
# find_package (GSL)
# endif()
if(WITH_OOQP AND BLAS_FOUND AND HSL_FOUND)
find_package(OOQP)
endif()
add_feature_info(ooqp-interface OOQP_FOUND "Interface to the QP solver OOQP (requires BLAS and HSL libraries).")
if(WITH_GUROBI)
find_package(GUROBI)
endif()
add_feature_info(gurobi-interface GUROBI_FOUND "Interface to the (mixed-integer) QP solver GUROBI")
if(Fortran_language_works AND WITH_SQIC)
find_package(SQIC)
endif()
add_feature_info(sqic-interface SQIC_FOUND "Interface to the QP solver SQIC.")
if(Fortran_language_works AND WITH_SLICOT)
find_package(SLICOT)
endif()
add_feature_info(slicot-interface SLICOT_FOUND "Interface to the controls library SLICOT.")
if(WITH_WORHP)
find_package(WORHP)
endif()
add_feature_info(worhp-interface WORHP_FOUND "Interface to the NLP solver Worhp (requires gfortran, gomp).")
if(WITH_PROFILING)
find_library(RT rt)
add_definitions(-DWITH_PROFILING)
endif()
if(WITH_DEEPBIND)
add_definitions(-DWITH_DEEPBIND)
endif()
######################################################
##################### paths ##########################
######################################################
#set(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/lib)
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib/)
#####################################################
################# include the rest ##################
#####################################################
add_subdirectory(external_packages)
add_subdirectory(casadi)
#add_subdirectory(experimental/greg EXCLUDE_FROM_ALL)
add_subdirectory(experimental/joel EXCLUDE_FROM_ALL)
#add_subdirectory(experimental/andrew EXCLUDE_FROM_ALL)
add_subdirectory(misc)
if(WITH_EXAMPLES)
add_subdirectory(docs/examples)
add_subdirectory(docs/api/examples/ctemplate)
endif()
#####################################################
######################### swig ######################
#####################################################
if(WITH_PYTHON OR WITH_MATLAB OR WITH_JSON)
add_subdirectory(swig)
endif()
#####################################################
######################### docs ######################
#####################################################
if(WITH_DOC)
set(DOXYFILE_LATEX "NO")
set(DOXYFILE_IN_DIR ${CMAKE_SOURCE_DIR}/docs/api)
set(DOXYFILE_OUTPUT_DIR ${CMAKE_SOURCE_DIR}/docs/api)
set(DOXYFILE_SOURCE_DIR ${CMAKE_SOURCE_DIR}/casadi)
include(UseDoxygen OPTIONAL)
add_subdirectory(docs/tutorials EXCLUDE_FROM_ALL)
add_custom_target(tutor)
endif()
# Print a summary
feature_summary(WHAT ALL)
feature_summary(WHAT ENABLED_FEATURES VAR feature_list)
string(REPLACE "\n" "\\n" feature_list "${feature_list}")
get_directory_property( compiler_definitions COMPILE_DEFINITIONS )
set(EXTRA_CXX_FLAGS_FROM_DEFS "")
foreach(DEF ${compiler_definitions})
set(EXTRA_CXX_FLAGS_FROM_DEFS "${EXTRA_CXX_FLAGS_FROM_DEFS} -D${DEF}")
endforeach()
# Pass meta information
configure_file(
${CMAKE_SOURCE_DIR}/casadi/core/casadi_meta.cpp.cmake
${PROJECT_BINARY_DIR}/casadi_meta.cpp
ESCAPE_QUOTES
)
# what is this?
if(EXTRA_CMAKE)
include(${EXTRA_CMAKE})
endif()