Skip to content

Commit

Permalink
refinements to Cpp FMU makefiles for win32
Browse files Browse the repository at this point in the history
  • Loading branch information
rfranke committed Nov 14, 2015
1 parent 5fb2fc5 commit 43df7a6
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions Compiler/Template/CodegenFMUCpp.tpl
Expand Up @@ -645,28 +645,29 @@ case SIMCODE(modelInfo=MODELINFO(__), makefileParams=MAKEFILE_PARAMS(__), simula

<<
# Makefile generated by OpenModelica

# Simulations use -O3 by default
OMHOME=<%makefileParams.omhome%>
include $(OMHOME)/include/omc/cpp/ModelicaConfig_msvc.inc
include $(OMHOME)/include/omc/cpp/ModelicaLibraryConfig_msvc.inc
# Simulations use /Od by default
SIM_OR_DYNLOAD_OPT_LEVEL=
MODELICAUSERCFLAGS=
CXX=cl
EXEEXT=.exe
DLLEXT=.dll
include <%makefileParams.omhome%>/include/omc/cpp/ModelicaConfig_msvc.inc
include <%makefileParams.omhome%>/include/omc/cpp/ModelicaLibraryConfig_msvc.inc

# /Od - Optimization disabled
# /EHa enable C++ EH (w/ SEH exceptions)
# /fp:except - consider floating-point exceptions when generating code
# /arch:SSE2 - enable use of instructions available with SSE2 enabled CPUs
# /I - Include Directories
# /DNOMINMAX - Define NOMINMAX (does what it says)
# /TP - Use C++ Compiler
CFLAGS=$(SYSTEM_CFLAGS) /w /I"<%makefileParams.omhome%>/include/omc/cpp/" /I"$(BOOST_INCLUDE)" /I"$(SUITESPARSE_INCLUDE)" /I. /TP /DNOMINMAX /DNO_INTERACTIVE_DEPENDENCY /DFMU_BUILD /DRUNTIME_STATIC_LINKING
CFLAGS=$(SYSTEM_CFLAGS) /I"$(OMHOME)/include/omc/cpp/" /I"$(BOOST_INCLUDE)" /I"$(SUITESPARSE_INCLUDE)" /I. /TP /DNOMINMAX /DNO_INTERACTIVE_DEPENDENCY /DFMU_BUILD /DRUNTIME_STATIC_LINKING

# /MD - link with MSVCRT.LIB
# /link - [linker options and libraries]
# /LIBPATH: - Directories where libs can be found
LDFLAGS=/link /DLL /NOENTRY /LIBPATH:"<%makefileParams.omhome%>/lib/omc/cpp/msvc" /LIBPATH:"<%makefileParams.omhome%>/bin" OMCppSystem_FMU_static.lib OMCppMath_static.lib OMCppModelicaUtilities_static.lib OMCppExtensionUtilities_static.lib OMCppFMU_static.lib ModelicaExternalC.lib ModelicaStandardTables.lib $(BOOST_SYSTEM_LIB).lib
LDFLAGS=/link /DLL /NOENTRY /LIBPATH:"$(OMHOME)/lib/omc/cpp/msvc" /LIBPATH:"$(OMHOME)/bin" OMCppSystem_FMU_static.lib OMCppMath_static.lib OMCppModelicaUtilities_static.lib OMCppExtensionUtilities_static.lib OMCppFMU_static.lib ModelicaExternalC.lib ModelicaStandardTables.lib $(BOOST_SYSTEM_LIB).lib
PLATFORM="win32"

MODELICA_SYSTEM_LIB=<%fileNamePrefix%>
Expand Down Expand Up @@ -694,6 +695,8 @@ case SIMCODE(modelInfo=MODELINFO(__), makefileParams=MAKEFILE_PARAMS(__), simula
// Note: FMI 1.0 did not distinguish modelIdentifier from fileNamePrefix
let modelName = if isFMIVersion10(FMUVersion) then fileNamePrefix else dotPath(modelInfo.name)
let platformstr = match makefileParams.platform case "i386-pc-linux" then 'linux32' case "x86_64-linux" then 'linux64' else '<%makefileParams.platform%>'
let omhome = makefileParams.omhome
let platformbins = match platformstr case "win32" then '"<%omhome%>/bin/libgcc_s_dw2-1.dll"' else ''
let mkdir = match makefileParams.platform case "win32" then '"mkdir.exe"' else 'mkdir'
<<
# Makefile generated by OpenModelica
Expand All @@ -717,7 +720,7 @@ case SIMCODE(modelInfo=MODELINFO(__), makefileParams=MAKEFILE_PARAMS(__), simula
endif

LDFLAGS=-L"$(OMHOME)/lib/<%getTriple()%>/omc/cpp" -L"$(BOOST_LIBS)" <%additionalLinkerFlags_GCC%> -Wl,--no-undefined
PLATFORM="<%platformstr%>"
PLATFORM=<%platformstr%>

CALCHELPERMAINFILE=OMCpp<%fileNamePrefix%>CalcHelperMain.cpp

Expand All @@ -728,16 +731,19 @@ case SIMCODE(modelInfo=MODELINFO(__), makefileParams=MAKEFILE_PARAMS(__), simula
$(eval CFLAGS=-DENABLE_SUNDIALS_STATIC $(CFLAGS))
endif

CPPFLAGS = $(CFLAGS)
CPPFLAGS=$(CFLAGS)

OMCPP_LIBS=-lOMCppSystem_FMU_static -lOMCppMath_static -lOMCppExtensionUtilities_static -lOMCppModelicaUtilities_static -lOMCppFMU_static $(OMCPP_SOLVER_LIBS)

MODELICA_EXTERNAL_LIBS=-lModelicaExternalC -lModelicaStandardTables -L$(LAPACK_LIBS) $(LAPACK_LIBRARIES)
LIBS= $(OMCPP_LIBS) $(MODELICA_EXTERNAL_LIBS) $(BASE_LIB)
LIBS=$(OMCPP_LIBS) $(MODELICA_EXTERNAL_LIBS) $(BASE_LIB)

BINARIES=<%fileNamePrefix%>$(DLLEXT) <%platformbins%>

# need boost system lib prior to C++11
ifneq ($(findstring USE_CPP_ELEVEN,$(CFLAGS)),USE_CPP_ELEVEN)
$(eval LIBS= $(LIBS) -l$(BOOST_SYSTEM_LIB))
$(eval LIBS=$(LIBS) -l$(BOOST_SYSTEM_LIB))
$(eval BINARIES=$(BINARIES) $(BOOST_LIBS)/lib$(BOOST_SYSTEM_LIB)$(DLLEXT))
endif

CPPFILES=$(CALCHELPERMAINFILE)
Expand All @@ -749,7 +755,7 @@ case SIMCODE(modelInfo=MODELINFO(__), makefileParams=MAKEFILE_PARAMS(__), simula
<%\t%>$(CXX) -shared -o <%fileNamePrefix%>$(DLLEXT) $(OFILES) $(LDFLAGS) $(LIBS)
<%\t%>rm -rf binaries
<%\t%><%mkdir%> -p "binaries/$(PLATFORM)"
<%\t%>cp <%fileNamePrefix%>$(DLLEXT) "binaries/$(PLATFORM)/"
<%\t%>cp $(BINARIES) "binaries/$(PLATFORM)/"
ifeq ($(USE_FMU_SUNDIALS),ON)
<%\t%>rm -rf documentation
<%\t%><%mkdir%> -p "documentation"
Expand Down

0 comments on commit 43df7a6

Please sign in to comment.