From ade081ba8d57e71f83a2c577f18f3699d0e3b177 Mon Sep 17 00:00:00 2001 From: nealkruis Date: Thu, 16 Oct 2014 14:53:08 -0600 Subject: [PATCH 1/3] Fix third-party library builds on MinGW. --- CMakeLists.txt | 4 ++ third_party/BCVTB/utilSocket.h | 32 ++++++------ third_party/Expat/CMakeLists.txt | 4 +- third_party/FMI/fmumini.c | 24 ++++----- third_party/FMI/main.h | 84 ++++++++++++++++---------------- third_party/FMI/util.h | 2 +- third_party/FMUParser/fmumini.c | 24 ++++----- third_party/FMUParser/parser.h | 4 +- third_party/FMUParser/util.h | 2 +- 9 files changed, 94 insertions(+), 86 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0bcc49110e9..98827525cbe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -82,6 +82,10 @@ if (MSVC) set(gtest_force_shared_crt ON) endif() +if (MINGW) + set(CMAKE_SHARED_LIBRARY_PREFIX "") +endif () + set( CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/Products" ) set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/Products" ) set( CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/Products" ) diff --git a/third_party/BCVTB/utilSocket.h b/third_party/BCVTB/utilSocket.h index b89c88a9d7a..ac495a2e333 100644 --- a/third_party/BCVTB/utilSocket.h +++ b/third_party/BCVTB/utilSocket.h @@ -48,7 +48,7 @@ modification, are permitted provided that the following conditions are met: 3. Neither the name of the University of California, Lawrence Berkeley National Laboratory, U.S. Dept. of Energy nor the names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. + derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED @@ -83,7 +83,7 @@ derivative works thereof, in binary and source code form. /// using BSD sockets. /// /// \author Michael Wetter, -/// Simulation Research Group, +/// Simulation Research Group, /// LBNL, /// MWetter@lbl.gov /// @@ -94,7 +94,7 @@ derivative works thereof, in binary and source code form. /// This file provides methods that allow clients to /// establish a socket connection. Clients typically call /// the method \c establishclientsocket() -/// once, and then call the method +/// once, and then call the method /// \c exchangedoubleswithsocket() in each time step. /// At the end of the simulation, a client should call /// \c closeipc() to close the socket connection. @@ -108,7 +108,7 @@ derivative works thereof, in binary and source code form. /////////////////////////////////////////////////////// #ifndef _UTILSOCKET_H_ #define _UTILSOCKET_H_ -#ifdef _MSC_VER // Microsoft compiler +#ifdef _WIN32 // Microsoft compiler #include #include @@ -120,7 +120,7 @@ derivative works thereof, in binary and source code form. #include #include //#include -#include +#include #endif #include @@ -133,14 +133,14 @@ derivative works thereof, in binary and source code form. #include "defines.h" -FILE *f1 = NULL; +FILE *f1 = NULL; #define HEADER_LENGTH 54 // =10 + 4*(10+1); int REQUIRED_READ_LENGTH = 0; int REQUIRED_WRITE_LENGTH = 0; /// This will be overwritten to contain the /// version number of the server -int SERVER_VERSION = 0; +int SERVER_VERSION = 0; //////////////////////////////////////////////////////////////// /// Appends a character array to another character array. @@ -180,7 +180,7 @@ int assembleBuffer(int flag, /// Gets an integer and does the required error checking. /// ///\param nptr Pointer to character buffer that contains the number. -///\param endptr After return, this variable contains a pointer to the +///\param endptr After return, this variable contains a pointer to the /// character after the last character of the number. ///\param base Base for the integer. ///\param The value contained in the character buffer. @@ -192,11 +192,11 @@ int getIntCheckError(const char *nptr, char **endptr, const int base, /// Gets a double and does the required error checking. /// ///\param nptr Pointer to character buffer that contains the number. -///\param endptr After return, this variable contains a pointer to the +///\param endptr After return, this variable contains a pointer to the /// character after the last character of the number. ///\param The value contained in the character buffer. ///\return 0 if no error occurred. -int getDoubleCheckError(const char *nptr, char **endptr, +int getDoubleCheckError(const char *nptr, char **endptr, double* val); @@ -286,7 +286,7 @@ int establishclientsocket(const char *const docname); ///\param boolValWri Boolean values to write. ///\sa int establishclientsocket(uint16_t *portNo) ///\return The exit value of \c send, or a negative value if an error occured. -int writetosocket(const int *sockfd, +int writetosocket(const int *sockfd, const int *flaWri, const int *nDblWri, const int *nIntWri, const int *nBooWri, double *curSimTim, @@ -303,7 +303,7 @@ int writetosocket(const int *sockfd, /// +1: simulation reached end time. /// -1: simulation terminates due to an (unspecified) error. /// -10: simulation terminates due to error during initialization. -/// -20: simulation terminates due to error during time integration. +/// -20: simulation terminates due to error during time integration. /// ///\param sockfd Socket file descripter ///\param flaWri Flag to be sent to the BCVTB @@ -355,7 +355,7 @@ int getrequiredbufferlength(const int nDbl, const int nInt, const int nBoo); ///\param intValRea Integer values read from socket. ///\param boolValRea Boolean values read from socket. ///\sa int establishclientsocket(uint16_t *portNo) -int readfromsocket(const int *sockfd, int *flaRea, +int readfromsocket(const int *sockfd, int *flaRea, int *nDblRea, int *nIntRea, int *nBooRea, double *curSimTim, double dblValRea[], int intValRea[], int booValRea[]); @@ -395,7 +395,7 @@ int readbufferfromsocket(const int *sockfd, ///\param boolValRea Boolean values read from socket. ///\sa int establishclientsocket(uint16_t *portNo) ///\return The exit value of \c send or \c read, or a negative value if an error occured. -int exchangewithsocket(const int *sockfd, +int exchangewithsocket(const int *sockfd, const int *flaWri, int *flaRea, const int *nDblWri, const int *nIntWri, const int *nBooWri, int *nDblRea, int *nIntRea, int *nBooRea, @@ -419,7 +419,7 @@ int exchangewithsocket(const int *sockfd, ///\param dblValRea Double values read from socket. ///\sa int establishclientsocket(uint16_t *portNo) ///\return The exit value of \c send or \c read, or a negative value if an error occured. -int exchangedoubleswithsocket(const int *sockfd, +int exchangedoubleswithsocket(const int *sockfd, const int *flaWri, int *flaRea, const int *nDblWri, int *nDblRea, @@ -446,7 +446,7 @@ int exchangedoubleswithsocket(const int *sockfd, ///\param flaexport Flag for FMUExport. ///\sa int establishclientsocket(uint16_t *portNo) ///\return The exit value of \c send or \c read, or a negative value if an error occured. -int exchangedoubleswithsocketFMU(const int *sockfd, +int exchangedoubleswithsocketFMU(const int *sockfd, const int *flaWri, int *flaRea, const int *nDblWri, int *nDblRea, diff --git a/third_party/Expat/CMakeLists.txt b/third_party/Expat/CMakeLists.txt index 9f0a957359e..fdfcb8a8bc1 100644 --- a/third_party/Expat/CMakeLists.txt +++ b/third_party/Expat/CMakeLists.txt @@ -14,9 +14,9 @@ lib/xmltok_impl.c lib/xmltok_ns.c ) -if(WIN32) +if(MSVC) set(epexpat_SRCS ${epexpat_SRCS} lib/libexpat.def) -endif(WIN32) +endif(MSVC) IF( MSVC ) ADD_DEFINITIONS( "/w" ) diff --git a/third_party/FMI/fmumini.c b/third_party/FMI/fmumini.c index f41b30c31c9..0de3b1ba2cf 100644 --- a/third_party/FMI/fmumini.c +++ b/third_party/FMI/fmumini.c @@ -13,7 +13,7 @@ /// /// This file provides unzip functions for fmus and it is modified /// based on the miniunz.c (Version 1.1) from the MiniZip project. -/// The original file, its copyright notice and its license can +/// The original file, its copyright notice and its license can /// be found in FMI/Copyright folder /////////////////////////////////////////////////////// /* @@ -77,9 +77,11 @@ #define MAXFILENAME (256) #ifdef _WIN32 +#ifndef __MINGW32__ #define USEWIN32IOAPI #include #endif +#endif /* mini unzip, demo of unzip package @@ -567,7 +569,7 @@ int unpackmz(const char *filNam, char *tmpPat) const char *dirname=tmpPat; char *cmd; char cwd[1024]; - unzFile uf=NULL; + unzFile uf=NULL; printDebug("Start Minizip\n"); if (zipfilename) @@ -610,7 +612,7 @@ int unpackmz(const char *filNam, char *tmpPat) } printfDebug("%s opened\n",filename_try); - + cmd = calloc(sizeof(char), strlen(dirname) +9); if (cmd == NULL){ printfError("Fail to allocate memory for cmd.\n", tmpPat); @@ -619,14 +621,14 @@ int unpackmz(const char *filNam, char *tmpPat) #ifdef _WIN32 if(_access(dirname, 0) ==-1) { - sprintf(cmd, "mkdir %s", dirname); // Command in windows + sprintf(cmd, "mkdir %s", dirname); // Command in windows #else if(access(dirname, F_OK) ==-1) { sprintf(cmd, "mkdir -p %s", dirname); // Command in linux #endif printfDebug("Generated cmd: \"%s\".\n", cmd); - if ( system(cmd) != 0 ){ + if ( system(cmd) != 0 ){ printError("Fail to creat temporary folders"); return -1; } @@ -635,21 +637,21 @@ int unpackmz(const char *filNam, char *tmpPat) if(getcwd(cwd, sizeof(cwd)) == NULL) fprintf(stdout, "Cannot get current working dir: %s\n", cwd); -#ifdef _WIN32 - _chdir(dirname); // Command in windows +#ifdef _WIN32 + _chdir(dirname); // Command in windows #else int i_unused = chdir(dirname); // Command in linux #endif ret_value = do_extract(uf, opt_do_extract_withoutpath, opt_overwrite, password); // Extract all files - + unzClose(uf); -#ifdef _WIN32 - _chdir(cwd); // Command in windows +#ifdef _WIN32 + _chdir(cwd); // Command in windows #else int j_unused = chdir(cwd); // Command in linux #endif - + return ret_value; } diff --git a/third_party/FMI/main.h b/third_party/FMI/main.h index ff75305b135..90abc34a3f5 100644 --- a/third_party/FMI/main.h +++ b/third_party/FMI/main.h @@ -1,30 +1,30 @@ -/* ------------------------------------------------------------------------- +/* ------------------------------------------------------------------------- /////////////////////////////////////////////////////// /// \file main.h /// /// \author Thierry Stephane Nouidui, -/// Simulation Research Group, +/// Simulation Research Group, /// LBNL, /// TSNouidui@lbl.gov /// /// \date 2011-10-11 /// -/// This files contains the definition of all -/// energyplus functions that are needed to mapped +/// This files contains the definition of all +/// energyplus functions that are needed to mapped /// to fmiFunctions /// This file is based on main.h that is copyrighted by -/// QTronic GmbH and that is distributed under the BSD license. -/// Function types for all FMU functions and a struct to wrap a FMU dll. -/// Copyright 2010 QTronic GmbH. All rights reserved. +/// QTronic GmbH and that is distributed under the BSD license. +/// Function types for all FMU functions and a struct to wrap a FMU dll. +/// Copyright 2010 QTronic GmbH. All rights reserved. /// ------------------------------------------------------------------------- */ #ifndef main_h #define main_h -// Use windows.h only for Windows -#ifdef _MSC_VER +// Use windows.h only for Windows +#ifdef _WIN32 #include #define WINDOWS 1 #else @@ -38,27 +38,27 @@ #include "xml_parser_cosim.h" #include "eplusModelFunctions.h" -typedef const char* (*fGetTypesPlatform)(); +typedef const char* (*fGetTypesPlatform)(); typedef const char* (*fGetVersion)(); -typedef fmiComponent (*fInstantiateSlave)(fmiString instanceName, fmiString GUID, - fmiString fmuLocation, fmiString mimeType, fmiReal timeout, - fmiBoolean visible, fmiBoolean interactive, - fmiCallbackFunctions functions, fmiBoolean loggingOn); -typedef void (*fFreeSlaveInstance) (fmiComponent c); -typedef fmiStatus (*fResetSlaveInstance) (fmiComponent c); +typedef fmiComponent (*fInstantiateSlave)(fmiString instanceName, fmiString GUID, + fmiString fmuLocation, fmiString mimeType, fmiReal timeout, + fmiBoolean visible, fmiBoolean interactive, + fmiCallbackFunctions functions, fmiBoolean loggingOn); +typedef void (*fFreeSlaveInstance) (fmiComponent c); +typedef fmiStatus (*fResetSlaveInstance) (fmiComponent c); typedef fmiStatus (*fSetDebugLogging) (fmiComponent c, fmiBoolean loggingOn); typedef fmiStatus (*fSetReal) (fmiComponent c, const fmiValueReference vr[], size_t nvr, const fmiReal value[]); typedef fmiStatus (*fSetInteger)(fmiComponent c, const fmiValueReference vr[], size_t nvr, const fmiInteger value[]); typedef fmiStatus (*fSetBoolean)(fmiComponent c, const fmiValueReference vr[], size_t nvr, const fmiBoolean value[]); typedef fmiStatus (*fSetString) (fmiComponent c, const fmiValueReference vr[], size_t nvr, const fmiString value[]); -typedef fmiStatus (*fInitializeSlave)(fmiComponent c, fmiReal tStart, fmiBoolean StopTimeDefined, fmiReal tStop); +typedef fmiStatus (*fInitializeSlave)(fmiComponent c, fmiReal tStart, fmiBoolean StopTimeDefined, fmiReal tStop); typedef fmiStatus (*fGetReal) (fmiComponent c, const fmiValueReference vr[], size_t nvr, fmiReal value[]); typedef fmiStatus (*fGetInteger)(fmiComponent c, const fmiValueReference vr[], size_t nvr, fmiInteger value[]); typedef fmiStatus (*fGetBoolean)(fmiComponent c, const fmiValueReference vr[], size_t nvr, fmiBoolean value[]); typedef fmiStatus (*fGetString) (fmiComponent c, const fmiValueReference vr[], size_t nvr, fmiString value[]); -typedef fmiStatus (*fDoStep) (fmiComponent c, fmiReal currentCommunicationPoint, fmiReal communicationStepSize, +typedef fmiStatus (*fDoStep) (fmiComponent c, fmiReal currentCommunicationPoint, fmiReal communicationStepSize, fmiBoolean newStep); // Zuo: add for co-sim typedef struct FMU{ @@ -66,67 +66,67 @@ typedef struct FMU{ fmiString modelID; fmiString modelGUID; ModelDescription* modelDescription; - HANDLE dllHandle; - fGetTypesPlatform getTypesPlatform; - fGetVersion getVersion; - fInstantiateSlave instantiateSlave; - fFreeSlaveInstance freeSlaveInstance; - fResetSlaveInstance resetSlaveInstance; + HANDLE dllHandle; + fGetTypesPlatform getTypesPlatform; + fGetVersion getVersion; + fInstantiateSlave instantiateSlave; + fFreeSlaveInstance freeSlaveInstance; + fResetSlaveInstance resetSlaveInstance; fSetDebugLogging setDebugLogging; fSetReal setReal; fSetInteger setInteger; fSetBoolean setBoolean; fSetString setString; - fInitializeSlave initializeSlave; + fInitializeSlave initializeSlave; fGetReal getReal; fGetInteger getInteger; fGetBoolean getBoolean; fGetString getString; - fDoStep doStep; + fDoStep doStep; } FMU; fmiComponent fmiEPlusInstantiateSlave(char* fmuResFolder, - fmiInteger *sizefmuResFolder, fmiReal *timeOut, fmiInteger *visible, + fmiInteger *sizefmuResFolder, fmiReal *timeOut, fmiInteger *visible, fmiInteger *interactive, fmiInteger *loggingOn, fmiInteger *index); -fmiStatus fmiEPlusInitializeSlave(fmiComponent *fmuInstance, +fmiStatus fmiEPlusInitializeSlave(fmiComponent *fmuInstance, fmiReal *tStart, fmiInteger *newStep, fmiReal *tStop, fmiInteger *index); -fmiStatus fmiEPlusGetReal(fmiComponent *fmuInstance, const fmiValueReference valRef [], +fmiStatus fmiEPlusGetReal(fmiComponent *fmuInstance, const fmiValueReference valRef [], fmiReal outValue[], fmiInteger *numOutputs, fmiInteger *index); -fmiStatus fmiEPlusSetReal(fmiComponent *fmuInstance, const fmiValueReference valRef[], +fmiStatus fmiEPlusSetReal(fmiComponent *fmuInstance, const fmiValueReference valRef[], fmiReal inpVal[], fmiInteger *numInputs, fmiInteger *index); -fmiStatus fmiEPlusDoStep(fmiComponent *fmuInstance, fmiReal *curCommPoint, +fmiStatus fmiEPlusDoStep(fmiComponent *fmuInstance, fmiReal *curCommPoint, fmiReal *commStepSize, fmiInteger *newStep, fmiInteger *index); fmiStatus fmiEPlusFreeSlave(fmiComponent *fmuInstance, fmiInteger *index); -fmiStatus fmiEPlusResetSlave(fmiComponent *fmuInstance, fmiInteger *index); +fmiStatus fmiEPlusResetSlave(fmiComponent *fmuInstance, fmiInteger *index); -fmiInteger fmiEPlusUnpack(char* fmuName, char* fmuOutputWorkingFolder, - fmiInteger *sizefmuName, fmiInteger *sizefmuOutputWorkingFolder); +fmiInteger fmiEPlusUnpack(char* fmuName, char* fmuOutputWorkingFolder, + fmiInteger *sizefmuName, fmiInteger *sizefmuOutputWorkingFolder); -fmiInteger addLibPathCurrentWorkingFolder(char* trimfmuOutputWorkingFolder_wLiB, - char* fmuWorkingFolder, fmiInteger *sizefmuWorkingFolder, +fmiInteger addLibPathCurrentWorkingFolder(char* trimfmuOutputWorkingFolder_wLiB, + char* fmuWorkingFolder, fmiInteger *sizefmuWorkingFolder, fmiInteger *index); -fmiInteger getValueReferenceByNameFMUInputVariables(char* variableName, +fmiInteger getValueReferenceByNameFMUInputVariables(char* variableName, fmiInteger *sizeVariableName, fmiInteger *index); -fmiInteger getValueReferenceByNameFMUOutputVariables(char* variableName, +fmiInteger getValueReferenceByNameFMUOutputVariables(char* variableName, fmiInteger *sizeVariableName, fmiInteger *index); -fmiInteger model_ID_GUID(char* fmuWorkingFolder, - fmiInteger *sizefmuWorkingFolder, fmiInteger *numInputs, +fmiInteger model_ID_GUID(char* fmuWorkingFolder, + fmiInteger *sizefmuWorkingFolder, fmiInteger *numInputs, fmiInteger *numOutputs); -fmiInteger addFMURootFolderName(char* fmuOutputWorkingFolder, +fmiInteger addFMURootFolderName(char* fmuOutputWorkingFolder, char* fmuWorkingFolder, fmiInteger *sizefmuWorkingFolder); -fmiInteger getfmiEPlusVersion(char* fmuWorkingFolder, +fmiInteger getfmiEPlusVersion(char* fmuWorkingFolder, fmiInteger *sizefmuWorkingFolder, char *fmiVersionNumber, fmiInteger *index); fmiInteger checkOperatingSystem(char* errorMessage); diff --git a/third_party/FMI/util.h b/third_party/FMI/util.h index 337012de589..9c78e2939a1 100644 --- a/third_party/FMI/util.h +++ b/third_party/FMI/util.h @@ -15,7 +15,7 @@ /// /////////////////////////////////////////////////////// -#ifdef _MSC_VER +#ifdef _WIN32 #include #define WINDOWS 1 #else diff --git a/third_party/FMUParser/fmumini.c b/third_party/FMUParser/fmumini.c index 4cce7282913..06eb1db804a 100644 --- a/third_party/FMUParser/fmumini.c +++ b/third_party/FMUParser/fmumini.c @@ -13,7 +13,7 @@ /// /// This file provides unzip functions for fmus and it is modified /// based on the miniunz.c (Version 1.1) from the MiniZip project. -/// The original file, its copyright notice and its license can +/// The original file, its copyright notice and its license can /// be found in ../zlib /////////////////////////////////////////////////////// /* @@ -69,9 +69,11 @@ #define MAXFILENAME (256) #ifdef _WIN32 +#ifndef __MINGW32__ #define USEWIN32IOAPI #include #endif +#endif /* mini unzip, demo of unzip package @@ -559,7 +561,7 @@ int unpackmz(const char *filNam, char *tmpPat) const char *dirname=tmpPat; char *cmd; char cwd[1024]; - unzFile uf=NULL; + unzFile uf=NULL; printDebug("Start Minizip\n"); if (zipfilename) @@ -602,7 +604,7 @@ int unpackmz(const char *filNam, char *tmpPat) } printfDebug("%s opened\n",filename_try); - + cmd = calloc(sizeof(char), strlen(dirname) + 11); if (cmd == NULL){ printfError("Fail to allocate memory for cmd.\n", tmpPat); @@ -611,14 +613,14 @@ int unpackmz(const char *filNam, char *tmpPat) #ifdef _WIN32 if(_access(dirname, 0) ==-1) { - sprintf(cmd, "mkdir \"%s\"", dirname); // Command in windows + sprintf(cmd, "mkdir \"%s\"", dirname); // Command in windows #else if(access(dirname, F_OK) ==-1) { sprintf(cmd, "mkdir -p \"%s\"", dirname); // Command in linux #endif printfDebug("Generated cmd: \"%s\".\n", cmd); - if ( system(cmd) != 0 ){ + if ( system(cmd) != 0 ){ printError("Fail to creat temporary folders"); return -1; } @@ -627,21 +629,21 @@ int unpackmz(const char *filNam, char *tmpPat) if(getcwd(cwd, sizeof(cwd)) == NULL) fprintf(stdout, "Cannot get current working dir: %s\n", cwd); -#ifdef _WIN32 - _chdir(dirname); // Command in windows +#ifdef _WIN32 + _chdir(dirname); // Command in windows #else int i_unused = chdir(dirname); // Command in linux #endif ret_value = do_extract(uf, opt_do_extract_withoutpath, opt_overwrite, password); // Extract all files - + unzClose(uf); -#ifdef _WIN32 - _chdir(cwd); // Command in windows +#ifdef _WIN32 + _chdir(cwd); // Command in windows #else int j_unused = chdir(cwd); // Command in linux #endif - + return ret_value; } diff --git a/third_party/FMUParser/parser.h b/third_party/FMUParser/parser.h index cf89a776ba2..0863f0cfd78 100644 --- a/third_party/FMUParser/parser.h +++ b/third_party/FMUParser/parser.h @@ -24,7 +24,7 @@ #include #include -#ifdef _MSC_VER +#ifdef _WIN32 #include #define WINDOWS 1 #else @@ -77,7 +77,7 @@ typedef fmiStatus (*fGetNominalContinuousStates)(fmiComponent c, fmiReal x_nomin typedef fmiStatus (*fGetStateValueReferences) (fmiComponent c, fmiValueReference vrx[], size_t nx); typedef fmiStatus (*fTerminate) (fmiComponent c); -typedef enum {opt_printidf, opt_delete, opt_unpack, opt_help} option; +typedef enum {opt_printidf, opt_delete, opt_unpack, opt_help} option; typedef struct { diff --git a/third_party/FMUParser/util.h b/third_party/FMUParser/util.h index 337012de589..9c78e2939a1 100644 --- a/third_party/FMUParser/util.h +++ b/third_party/FMUParser/util.h @@ -15,7 +15,7 @@ /// /////////////////////////////////////////////////////// -#ifdef _MSC_VER +#ifdef _WIN32 #include #define WINDOWS 1 #else From 2e51be487e385a8402be1fb3f315d0eb6d23893f Mon Sep 17 00:00:00 2001 From: "Jason W. DeGraw" Date: Wed, 11 Feb 2015 14:51:32 -0700 Subject: [PATCH 2/3] Get MinGW build working, will need more work --- src/EnergyPlus/CMakeLists.txt | 11 ++++++++--- src/EnergyPlus/EnergyPlusPgm.cc | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/EnergyPlus/CMakeLists.txt b/src/EnergyPlus/CMakeLists.txt index 4b13272f869..3ff3ef95387 100644 --- a/src/EnergyPlus/CMakeLists.txt +++ b/src/EnergyPlus/CMakeLists.txt @@ -570,11 +570,16 @@ install( TARGETS energyplusapi LIBRARY DESTINATION ./ ) -if (CMAKE_COMPILER_IS_GNUCXX AND ENABLE_LTO) +if (CMAKE_COMPILER_IS_GNUCXX) target_link_libraries( energypluslib2 energypluslib ) target_link_libraries( energypluslib energypluslib2 ) - add_executable( energyplus main.cc "EnergyPlusPgm.cc" "public/EnergyPlusPgm.hh" ) - target_link_libraries( energyplus energypluslib energypluslib2 ) + if (ENABLE_LTO) + add_executable( energyplus main.cc "EnergyPlusPgm.cc" "public/EnergyPlusPgm.hh" ) + target_link_libraries( energyplus energypluslib energypluslib2 ) + else() + add_executable( energyplus main.cc ) + target_link_libraries( energyplus energyplusapi ) + endif() else() add_executable( energyplus main.cc ) target_link_libraries( energyplus energyplusapi ) diff --git a/src/EnergyPlus/EnergyPlusPgm.cc b/src/EnergyPlus/EnergyPlusPgm.cc index cf02a5287c8..01d2ea48a4b 100644 --- a/src/EnergyPlus/EnergyPlusPgm.cc +++ b/src/EnergyPlus/EnergyPlusPgm.cc @@ -239,7 +239,7 @@ EnergyPlusPgm( std::string const & filepath ) #endif #endif -#ifdef _WIN32 +#ifdef _MSC_VER SetErrorMode(SEM_NOGPFAULTERRORBOX); _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG); _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_DEBUG); From 79cf62de4a826d43af82e27e0195dcec7be4d4ee Mon Sep 17 00:00:00 2001 From: "Jason W. DeGraw" Date: Wed, 25 Feb 2015 12:11:39 -0700 Subject: [PATCH 3/3] Clean up CMake MinGW logic --- src/EnergyPlus/CMakeLists.txt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/EnergyPlus/CMakeLists.txt b/src/EnergyPlus/CMakeLists.txt index 3ff3ef95387..6d1570cd127 100644 --- a/src/EnergyPlus/CMakeLists.txt +++ b/src/EnergyPlus/CMakeLists.txt @@ -570,16 +570,16 @@ install( TARGETS energyplusapi LIBRARY DESTINATION ./ ) -if (CMAKE_COMPILER_IS_GNUCXX) +if (MINGW) target_link_libraries( energypluslib2 energypluslib ) target_link_libraries( energypluslib energypluslib2 ) - if (ENABLE_LTO) - add_executable( energyplus main.cc "EnergyPlusPgm.cc" "public/EnergyPlusPgm.hh" ) - target_link_libraries( energyplus energypluslib energypluslib2 ) - else() - add_executable( energyplus main.cc ) - target_link_libraries( energyplus energyplusapi ) - endif() + add_executable( energyplus main.cc ) + target_link_libraries( energyplus energyplusapi ) +elseif (CMAKE_COMPILER_IS_GNUCXX AND ENABLE_LTO) + target_link_libraries( energypluslib2 energypluslib ) + target_link_libraries( energypluslib energypluslib2 ) + add_executable( energyplus main.cc "EnergyPlusPgm.cc" "public/EnergyPlusPgm.hh" ) + target_link_libraries( energyplus energypluslib energypluslib2 ) else() add_executable( energyplus main.cc ) target_link_libraries( energyplus energyplusapi )