-
Notifications
You must be signed in to change notification settings - Fork 160
/
CMakeLists.txt
128 lines (106 loc) · 4.26 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
##################################################################
# CMake file for Modelica Buildings Library
# To build all targets, run
# rm -rf build && mkdir build && cd build && cmake ../ && cmake --build . --target install && cd ..
#
##################################################################
cmake_policy(SET CMP0048 NEW)
set(ENERGYPLUS_VERSION "24_2_0")
project( Modelica-Buildings
DESCRIPTION "Modelica Buildings Library"
LANGUAGES C
)
cmake_minimum_required(VERSION 3.8)
# Create position independent code
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
message(STATUS "Build type not specified: Use Release by default")
endif(NOT CMAKE_BUILD_TYPE)
# find_package(Java REQUIRED)
# include(UseJava)
set(BUILDINGS_INSTALL_PREFIX "${CMAKE_SOURCE_DIR}/Buildings")
# Output build system directories.
message("CMake source directory is: ${CMAKE_SOURCE_DIR}")
# Detect OS.
if(CMAKE_SYSTEM_NAME MATCHES Windows)
set(WINDOWS 1)
message("Windows system detected.")
elseif(CMAKE_SYSTEM_NAME MATCHES Linux)
set(LINUX 1)
message("Linux system detected.")
elseif(CMAKE_SYSTEM_NAME MATCHES Darwin)
set(MACOSX 1)
message("Mac OS X system detected.")
else()
message(WARNING "OS unknown!")
endif()
# Set compiler options
if ( CMAKE_COMPILER_IS_GNUCC )
set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} -O3 -Wall -Wextra -pedantic -Wmisleading-indentation -Wconversion -Wno-unused-function -Wno-unused-parameter")
endif()
if ( MSVC )
add_compile_options("/wd4100")
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
add_compile_definitions(EXTERNAL_FUNCTION_EXPORT)
endif()
# Set target directories.
# NOTE: always add quotes to protect spaces in path when setting new variables.
if (WIN32) # True also on 64 bit Windows
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(PLATFORM_INSTALL_PREFIX win64)
else()
set(PLATFORM_INSTALL_PREFIX win32)
endif()
elseif(APPLE)
set(PLATFORM_INSTALL_PREFIX darwin64)
elseif(UNIX)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(PLATFORM_INSTALL_PREFIX linux64)
else()
set(PLATFORM_INSTALL_PREFIX linux32)
endif()
else()
message(FATAL_ERROR "OS unknown!")
endif()
set(CMAKE_INSTALL_PREFIX "${BUILDINGS_INSTALL_PREFIX}/Resources/Library/${PLATFORM_INSTALL_PREFIX}/" )
# Set name of fmilib_shared
if (WIN32)
set(FMILIB_SHARED "${CMAKE_INSTALL_PREFIX}fmilib_shared.lib")
elseif(APPLE)
message(FATAL_ERROR "OS X is not yet supported.")
else()
set(FMILIB_SHARED "${CMAKE_INSTALL_PREFIX}libfmilib_shared.so")
endif()
if (LINUX)
add_definitions(-D_GNU_SOURCE)
message("Added GNU_SOURCE")
endif()
add_library( ModelicaBuildingsEnergyPlus_${ENERGYPLUS_VERSION} SHARED
Buildings/Resources/src/ThermalZones/EnergyPlus_${ENERGYPLUS_VERSION}/C-Sources/SpawnUtil.c
Buildings/Resources/src/ThermalZones/EnergyPlus_${ENERGYPLUS_VERSION}/C-Sources/SpawnObjectFree.c
Buildings/Resources/src/ThermalZones/EnergyPlus_${ENERGYPLUS_VERSION}/C-Sources/SpawnObjectExchange.c
Buildings/Resources/src/ThermalZones/EnergyPlus_${ENERGYPLUS_VERSION}/C-Sources/SpawnObjectInstantiate.c
Buildings/Resources/src/ThermalZones/EnergyPlus_${ENERGYPLUS_VERSION}/C-Sources/BuildingInstantiate.c
Buildings/Resources/src/ThermalZones/EnergyPlus_${ENERGYPLUS_VERSION}/C-Sources/SpawnFMU.c
Buildings/Resources/src/ThermalZones/EnergyPlus_${ENERGYPLUS_VERSION}/C-Sources/cryptographicsHash.c
Buildings/Resources/src/ThermalZones/EnergyPlus_${ENERGYPLUS_VERSION}/C-Sources/SpawnObjectAllocate.c
)
target_include_directories( ModelicaBuildingsEnergyPlus_${ENERGYPLUS_VERSION}
PRIVATE Buildings/Resources/src/ThermalZones_${ENERGYPLUS_VERSION}/EnergyPlus/C-Sources
PRIVATE Buildings/Resources/src/fmi-library/include
)
#link_directories(${CMAKE_SOURCE_DIR}/Buildings/Resources/Library/darwin64)
if (WIN32)
target_link_libraries( ModelicaBuildingsEnergyPlus_${ENERGYPLUS_VERSION}
PRIVATE ${FMILIB_SHARED}
PRIVATE ${CMAKE_DL_LIBS}
)
else()
target_link_libraries( ModelicaBuildingsEnergyPlus_${ENERGYPLUS_VERSION}
PRIVATE ${CMAKE_DL_LIBS}
)
endif()
set(BUILDINGS_INSTALL_DIR "${BUILDINGS_INSTALL_PREFIX}/Resources/Library/${PLATFORM_INSTALL_PREFIX}/")
message("Installing to: ${BUILDINGS_INSTALL_DIR}")
install( TARGETS ModelicaBuildingsEnergyPlus_${ENERGYPLUS_VERSION} DESTINATION ${BUILDINGS_INSTALL_DIR} )