Skip to content

Commit

Permalink
adapt code to MSVC2015
Browse files Browse the repository at this point in the history
- the compilation will now use the existing
  VS 2015, 2013, 2012, 2010 in that order
- use VSVERSION=20NN to change the order
- fix a minor warning in the CPP runtime CMakeLists.txt
  • Loading branch information
adrpo committed Oct 15, 2016
1 parent 4f6ee12 commit 9447a8c
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 43 deletions.
43 changes: 23 additions & 20 deletions Makefile.omdev.mingw
Expand Up @@ -10,10 +10,6 @@ endif
ifeq ($(BUILDTYPE),)
BUILDTYPE=Debug
endif
ifeq ($(VSVERSION),)
VSVERSION = 2010
endif
VSCOMNTOOLS = $(VS140COMNTOOLS)

OMDEVMSYS=$(shell cygpath $$OMDEV)

Expand Down Expand Up @@ -85,22 +81,28 @@ CMINPACKLIB_SHARED = OFF
CONFIG_REVISION = $(shell git describe --match "v*.*" --always)

getMSVCversion:
echo "Check for given VSVERSION (2010|2012|2013|2015) version: [VSVERSION=$(VSVERSION)]"
ifeq ("$(VSVERSION)","")
ifeq ("$(VS140COMNTOOLS)", "") #check VS 2015
ifeq ("$(VS120COMNTOOLS)", "") #check VS 2013
ifeq ("$(VS110COMNTOOLS)", "") #check VS 2012
ifeq ("$(VS100COMNTOOLS)", "") #check VS 2010
echo "Could not identify Visual Studio version"
else
$(eval VSCOMNTOOLS=$(VS100COMNTOOLS))
endif
else
$(eval VSCOMNTOOLS=$(VS110COMNTOOLS))
endif
else
$(eval VSCOMNTOOLS=$(VS120COMNTOOLS))
endif
endif
ifeq ("$(VS140COMNTOOLS)", "") #check VS 2015
ifeq ("$(VS120COMNTOOLS)", "") #check VS 2013
ifeq ("$(VS110COMNTOOLS)", "") #check VS 2012
ifeq ("$(VS100COMNTOOLS)", "") #check VS 2010
echo "Could not identify Visual Studio version, setting it to VSVERSION=2010"
VSVERSION=2010
$(eval VSCOMNTOOLS=$(VS100COMNTOOLS))
else
$(eval VSCOMNTOOLS=$(VS100COMNTOOLS))
endif
else
$(eval VSCOMNTOOLS=$(VS110COMNTOOLS))
endif
else
$(eval VSCOMNTOOLS=$(VS120COMNTOOLS))
endif
else
$(eval VSCOMNTOOLS=$(VS140COMNTOOLS))
$(eval BOOST_PATH_MSVC=$(OMDEVMSYS)/lib/3rdParty/boost-1_59/)
endif
else
ifeq ($(VSVERSION),2010)
$(eval VSCOMNTOOLS=$(VS100COMNTOOLS))
Expand All @@ -113,6 +115,7 @@ ifeq ($(VSVERSION),2013)
else
ifeq ($(VSVERSION),2015)
$(eval VSCOMNTOOLS=$(VS140COMNTOOLS))
$(eval BOOST_PATH_MSVC=$(OMDEVMSYS)/lib/3rdParty/boost-1_59/)
endif
endif
endif
Expand Down Expand Up @@ -279,7 +282,7 @@ copycppheader:
(cp -pufr $(BOOST_PATH)/boost/property_tree $(OMBUILDDIR)/include/omc/cpp/3rdParty/boost/gcc/boost)
(cp -pufr $(BOOST_PATH)/boost/multi_index $(OMBUILDDIR)/include/omc/cpp/3rdParty/boost/gcc/boost)

copycppmsvcheader:
copycppmsvcheader: getMSVCversion
echo Copying needed header files to the $(OMBUILDDIR)/include/omc/cpp/ directory
(mkdir -p $(OMBUILDDIR)/include/omc/cpp/3rdParty/boost/msvc/boost)
(cp -puf $(BOOST_PATH_MSVC)/boost/*.hpp $(OMBUILDDIR)/include/omc/cpp/3rdParty/boost/msvc/boost)
Expand Down
6 changes: 4 additions & 2 deletions SimulationRuntime/c/util/omc_msvc.h
Expand Up @@ -89,8 +89,6 @@ static union MSVC_FLOAT_HACK __NAN = {{0x00, 0x00, 0xC0, 0x7F}};
#define trunc(a) ((double)((int)(a)))
#endif

#define snprintf sprintf_s

#define PATH_MAX _MAX_PATH
#include <stdarg.h>
char *realpath(const char *path, char *resolved_path);
Expand All @@ -104,9 +102,13 @@ unsigned int alarm (unsigned int seconds);
#define isnan _isnan
#define fpu_error(x) (isinf(x) || isnan(x))


#if _MSC_VER < 1900 /* VS 2015 */
#define snprintf sprintf_s
#if !defined(snprintf)
#define snprintf snprintf_s
#endif
#endif

#else /* not msvc */

Expand Down
6 changes: 5 additions & 1 deletion SimulationRuntime/cpp/CMakeLists.txt
Expand Up @@ -304,7 +304,11 @@ IF(WIN32)
ELSEIF(IS_MINGW64)
SET(BOOST_ROOT $ENV{OMDEV}"/tools/mingw64/include")
ELSE()
SET(BOOST_ROOT $ENV{OMDEV}"/lib/3rdParty/boost-1_55/")
IF(MSVC_VERSION GREATER 1700)
SET(BOOST_ROOT $ENV{OMDEV}"/lib/3rdParty/boost-1_59/")
ELSE(MSVC_VERSION GREATER 1700)
SET(BOOST_ROOT $ENV{OMDEV}"/lib/3rdParty/boost-1_55/")
ENDIF(MSVC_VERSION GREATER 1700)
ENDIF(IS_MINGW32)
MESSAGE(STATUS "Boost root:")
MESSAGE(STATUS ${BOOST_ROOT})
Expand Down
39 changes: 20 additions & 19 deletions SimulationRuntime/cpp/Makefile.omdev.mingw
Expand Up @@ -12,10 +12,6 @@ builddir_build=$(OMBUILDDIR)
builddir_bin=$(OMBUILDDIR)/bin
builddir_lib=$(OMBUILDDIR)/lib/omc
builddir_inc=$(OMBUILDDIR)/include/omc
ifeq ($(VSVERSION),)
VSVERSION = 2010
endif
VSCOMNTOOLS = $(VS140COMNTOOLS)

OMDEVMSYS=$(shell cygpath $$OMDEV)

Expand Down Expand Up @@ -92,22 +88,27 @@ else
endif

getMSVCversion:
echo "Check for given VSVERSION (2010|2012|2013|2015) version: [VSVERSION=$(VSVERSION)]"
ifeq ("$(VSVERSION)","")
ifeq ("$(VS140COMNTOOLS)", "") #check VS 2015
ifeq ("$(VS120COMNTOOLS)", "") #check VS 2013
ifeq ("$(VS110COMNTOOLS)", "") #check VS 2012
ifeq ("$(VS100COMNTOOLS)", "") #check VS 2010
echo "Could not identify Visual Studio version"
else
$(eval VSCOMNTOOLS=$(VS100COMNTOOLS))
endif
else
$(eval VSCOMNTOOLS=$(VS110COMNTOOLS))
endif
else
$(eval VSCOMNTOOLS=$(VS120COMNTOOLS))
endif
endif
ifeq ("$(VS140COMNTOOLS)", "") #check VS 2015
ifeq ("$(VS120COMNTOOLS)", "") #check VS 2013
ifeq ("$(VS110COMNTOOLS)", "") #check VS 2012
ifeq ("$(VS100COMNTOOLS)", "") #check VS 2010
echo "Could not identify Visual Studio version, setting it to VSVERSION=2010"
VSVERSION=2010
$(eval VSCOMNTOOLS=$(VS100COMNTOOLS))
else
$(eval VSCOMNTOOLS=$(VS100COMNTOOLS))
endif
else
$(eval VSCOMNTOOLS=$(VS110COMNTOOLS))
endif
else
$(eval VSCOMNTOOLS=$(VS120COMNTOOLS))
endif
else
$(eval VSCOMNTOOLS=$(VS140COMNTOOLS))
endif
else
ifeq ($(VSVERSION),2010)
$(eval VSCOMNTOOLS=$(VS100COMNTOOLS))
Expand Down
2 changes: 1 addition & 1 deletion SimulationRuntime/cpp/PrecompiledHeader.cmake
Expand Up @@ -255,7 +255,7 @@ IF(MSVC)
ENDIF(_source MATCHES \\.\(cc|cxx|cpp\)$)
ENDFOREACH()

ENDIF(CMAKE_BUILD_TYPE MATCHES "Release")
ENDIF(CMAKE_BUILD_TYPE MATCHES "Release" AND PLATFORM MATCHES "dynamic")

ENDIF(MSVC)

Expand Down

0 comments on commit 9447a8c

Please sign in to comment.