Skip to content

Commit a936ac7

Browse files
OCT-5087 Fix expat integration for linux gcc
1. Not passing all FMIL C-flags to expat. We're using C89 and they C99, which prevented compilation. We should regardless let expat set their flags internal flags and not override them with ours. 2. XML_STATIC is only exposed in the public header for expat. So only needs to be set when we're compiling any library that users that header, i.e. fmixml. Not when compiling expat. 3. Removed FMI_XML_QUERY because it seems unused.
1 parent e0c0a51 commit a936ac7

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

Config.cmake/fmixml.cmake

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,6 @@ set(FMIXMLSOURCE
137137
src/FMI2/fmi2_xml_variable.c
138138
)
139139

140-
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DXML_STATIC -DFMI_XML_QUERY")
141-
142140
include(ExternalProject)
143141

144142
# The *_POSTFIX variables are set because it makes it easier to determine the name of
@@ -155,12 +153,8 @@ set(EXPAT_SETTINGS
155153
-DCMAKE_RELEASE_POSTFIX:STRING=
156154
-DCMAKE_MINSIZEREL_POSTFIX:STRING=
157155
-DCMAKE_RELWITHDEBINFO_POSTFIX:STRING=
156+
-DCMAKE_POSITION_INDEPENDENT_CODE:BOOLEAN=ON
158157
-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
159-
-DCMAKE_C_FLAGS:STRING=${CMAKE_C_FLAGS}
160-
-DCMAKE_C_FLAGS_DEBUG:STRING=${CMAKE_C_FLAGS_DEBUG}
161-
-DCMAKE_C_FLAGS_RELEASE:STRING=${CMAKE_C_FLAGS_RELEASE}
162-
-DCMAKE_C_FLAGS_MINSIZEREL:STRING=${CMAKE_C_FLAGS_MINSIZEREL}
163-
-DCMAKE_C_FLAGS_RELWITHDEBINFO:STRING=${CMAKE_C_FLAGS_RELWITHDEBINFO}
164158
-DCMAKE_EXE_LINKER_FLAGS:STRING=${CMAKE_EXE_LINKER_FLAGS}
165159
-DCMAKE_LINK_LIBRARY_FLAG:STRING=${CMAKE_LINK_LIBRARY_FLAG}
166160
-DCMAKE_MODULE_LINKER_FLAGS:STRING=${CMAKE_MODULE_LINKER_FLAGS}
@@ -192,7 +186,7 @@ ExternalProject_Add_Step(
192186
add_dependencies(expatex ${CMAKE_BINARY_DIR}/CMakeCache.txt ${FMILIBRARYHOME}/CMakeLists.txt)
193187

194188

195-
if(WIN32 AND NOT MINGW)
189+
if(MSVC)
196190
# Expat uses special naming with MSVC, which is mirrored here.
197191
set(EXPAT_LIB_PREFIX lib)
198192
else()
@@ -233,6 +227,9 @@ list(APPEND FMIXMLSOURCE
233227
debug_message(STATUS "adding fmixml")
234228

235229
add_library(fmixml ${FMILIBKIND} ${FMIXMLSOURCE} ${FMIXMLHEADERS})
230+
if(MSVC)
231+
target_compile_definitions(fmixml XML_STATIC)
232+
endif()
236233

237234
target_link_libraries(fmixml ${JMUTIL_LIBRARIES} expat)
238235

build/config/win64_static_runtime

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ CONFIG=win64_static_runtime
44
SRC_DIR=.
55
BUILD_DIR=build-$(CONFIG)
66
INSTALL_DIR=install-$(CONFIG)
7-
GENERATOR="Visual Studio 15 2017 win64"
7+
GENERATOR="Visual Studio 15 2017 Win64"
88
FMILIB_CMAKE_CUSTOM_FLAGS=-DCMAKE_C_FLAGS= # N/A
99

1010
# FMILIB_...

0 commit comments

Comments
 (0)