-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathCMakeLists.txt
119 lines (103 loc) · 5.2 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
#########################################################################
## Sundials
message(STATUS "##### 3rdParty Sundials")
if(NOT OPENMODELICA_NEW_CMAKE_BUILD)
option(SUNDIALS_BUILD_SHARED_LIBS "Build shared libraries" OFF)
option(SUNDIALS_EXAMPLES_ENABLE_C "Build SUNDIALS C examples" OFF)
add_subdirectory(sundials-5.4.0 EXCLUDE_FROM_ALL)
## Sundials thoughtfully has organized its headers cleanly in one include/ directory
## Take advantage of that to transitively provide the headers when an external target links to
## any one of the sundials' libs.
add_library(sundials_interface INTERFACE)
target_include_directories(sundials_interface INTERFACE ${sundials_SOURCE_DIR}/include/)
## The sundials_config.h files are generated in the build directory. Add it as an include dir.
target_include_directories(sundials_interface INTERFACE ${sundials_BINARY_DIR}/include/)
## Add an interface lib for linking ot the static libs. This will transitively add
## DLINK_SUNDIALS_STATIC to anything that links to the static sundials libs.
add_library(sundials_interface_static INTERFACE)
target_link_libraries(sundials_interface_static INTERFACE sundials_interface)
target_compile_definitions(sundials_interface_static INTERFACE LINK_SUNDIALS_STATIC)
## Now that the includes and defines are attached to a utility interface library (sundials_interface_static) link it
## to the sundials static libs so they can be found when the sundials lib is linked-to from an external lib.
### Note! It should have been enough for the scope here to be INTERFACE instead of PUBLIC. However,
### that does not seem to work. This should be fine anyway.
target_link_libraries(sundials_cvode_static PUBLIC sundials_interface_static)
target_link_libraries(sundials_kinsol_static PUBLIC sundials_interface_static)
endif()
add_library(oms::3rd::cvode ALIAS sundials_cvode_static)
add_library(oms::3rd::kinsol ALIAS sundials_kinsol_static)
#########################################################################
## zlib.
message(STATUS "##### 3rdParty zlib")
add_subdirectory(zlib EXCLUDE_FROM_ALL)
add_library(oms::3rd::zlib ALIAS zlibstatic)
#########################################################################
## minizip.
message(STATUS "##### 3rdParty minizip")
add_subdirectory(minizip EXCLUDE_FROM_ALL)
add_library(oms::3rd::minizip ALIAS oms_minizip)
#########################################################################
## fmi4c.
message(STATUS "##### 3rdParty fmi4c")
set(FMI4C_BUILD_SHARED OFF)
set(FMI4C_USE_SYSTEM_ZIP OFF)
set(FMI4C_USE_EXTERNAL_MINIZIP ON)
set(FMI4C_EXTERNAL_MINIZIP "oms::3rd::minizip" CACHE STRING "Defines an external target for minizip.")
add_subdirectory(fmi4c EXCLUDE_FROM_ALL)
add_library(oms::3rd::fmi4c ALIAS fmi4c)
#########################################################################
## Lua.
message(STATUS "##### 3rdParty Lua")
option(LUA_ENABLE_SHARED OFF)
add_subdirectory(Lua EXCLUDE_FROM_ALL)
add_library(oms::3rd::lua ALIAS lua_static)
#########################################################################
## PugiXml.
message(STATUS "##### 3rdParty PugiXml")
add_subdirectory(PugiXml EXCLUDE_FROM_ALL)
add_library(oms::3rd::pugixml::header ALIAS pugixml_header_only)
#########################################################################
## xerces
message(STATUS "##### 3rdParty xerces")
option(XERCES_BUILD_SHARED_LIBS OFF)
add_subdirectory(xerces EXCLUDE_FROM_ALL)
### xerces does not include the target directories by default, so we have to externally add the include directories
target_include_directories(xerces-c INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/xerces/src)
### Xerces_autoconf_config.hpp is generated at build directory and we have to include it
target_include_directories(xerces-c INTERFACE ${CMAKE_CURRENT_BINARY_DIR}/xerces/src)
add_library(oms::3rd::xerces ALIAS xerces-c)
#########################################################################
## CTPL.
message(STATUS "##### 3rdParty CTPL")
add_subdirectory(CTPL EXCLUDE_FROM_ALL)
add_library(oms::3rd::ctpl::header ALIAS ctpl_header_only)
#########################################################################
## Dear ImGui.
if (OMS_ENABLE_OMSimulatorGui)
message(STATUS "##### 3rdParty Dear ImGui")
add_subdirectory(imgui EXCLUDE_FROM_ALL)
add_library(oms::3rd::imgui ALIAS imgui)
endif ()
#########################################################################
## GLFW.
if (OMS_ENABLE_OMSimulatorGui)
message(STATUS "##### 3rdParty GLFW")
set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_WAYLAND OFF CACHE BOOL "" FORCE)
add_subdirectory(glfw EXCLUDE_FROM_ALL)
add_library(oms::3rd::GLFW ALIAS glfw)
endif ()
#########################################################################
## tinyfiledialogs.
if (OMS_ENABLE_OMSimulatorGui)
message(STATUS "##### 3rdParty tinyfiledialogs")
add_subdirectory(tinyfd EXCLUDE_FROM_ALL)
add_library(oms::3rd::tinyfd ALIAS tinyfd)
endif ()
#########################################################################
## nlohmann/json
message(STATUS "##### 3rdParty nlohmann/json")
add_subdirectory(json EXCLUDE_FROM_ALL)
add_library(oms::3rd::json::header ALIAS json_header_only)