WSL/SLF GitLab Repository

Commit 8909bac0 authored by Mathias Bavay's avatar Mathias Bavay
Browse files

The CMakeLists has been adapted so that it properly supports various Visual...

The CMakeLists has been adapted so that it properly supports various Visual C++ options. Now, options are set per compiler and per plateform (depending on the scope of the said option). Therefore, choosing a target like "optimized" really produces compilation optimized for speed on g++ as well as Visual C++.

Several type casting issues (warnings) have also been addressed.
parent 059f9d66
......@@ -13,20 +13,34 @@ ADD_SUBDIRECTORY(meteoio/plugins/gsn)
ADD_SUBDIRECTORY(meteoio/meteolaws)
ADD_SUBDIRECTORY(meteoio/meteofilters)
# require proper c++
set(DEBUG_ARITHM ON CACHE BOOL "Use the debug flags -DDEBUG_ARITHM to catch arithmetic exceptions")
set(WARNINGS "-Wall")
set(PROFILING "-pg -fprofile-arcs")
set(EXTRA_WARNINGS "-Wextra -ansi -pedantic")
IF(DEBUG_ARITHM)
LIST(APPEND CFLAGS "-DDEBUG_ARITHM")
ENDIF(DEBUG_ARITHM)
SET(POPCC popcc)
###########################################################
#platform specific
#platform specific. First, compiler specific flags, then system specific flags
IF(CMAKE_COMPILER_IS_GNUCXX)
set(WARNINGS "-Wall")
set(PROFILING "-pg -fprofile-arcs")
set(EXTRA_WARNINGS "-Wextra -ansi -pedantic")
set(DEBUG_ARITHM ON CACHE BOOL "Use the debug flags -DDEBUG_ARITHM to catch arithmetic exceptions")
IF(DEBUG_ARITHM)
LIST(APPEND CFLAGS "-DDEBUG_ARITHM")
ENDIF(DEBUG_ARITHM)
set(OPTIM "-g -O3 -DNDEBUG")
set(ARCH_OPTIM "-march=pentium4 -mtune=native")
set(ARCH_SAFE "-march=pentium4")
set(DEBUG "-g -O0 -D__DEBUG")
ENDIF(CMAKE_COMPILER_IS_GNUCXX)
IF(MSVC)
# for linker, "/MD /MDd"?
set(WARNINGS "/W4")
set(EXTRA_WARNINGS "/Wp64") #/Wall
set(OPTIM "/O2 /Vmb")
set(ARCH_OPTIM "/arch:SSE2")
set(ARCH_SAFE "")
set(DEBUG "/Z7 /Od -D__DEBUG")
ENDIF(MSVC)
IF(UNIX)
IF(APPLE)
set(PLATFORM "-DAPPLE")
......@@ -35,9 +49,7 @@ IF(UNIX)
ENDIF(APPLE)
ELSE(UNIX)
IF(WIN32)
set(PLATFORM "-DWIN32 -U__STRICT_ANSI__ -D_USE_MATH_DEFINES -D_CRT_SECURE_NO_WARNING")
# see IF(MSVC) "/MD /MDd"
set(EXTRA_WARNINGS "-ansi")
set(PLATFORM "-U__STRICT_ANSI__ -D_USE_MATH_DEFINES -D_CRT_SECURE_NO_WARNINGS")
ENDIF(WIN32)
ENDIF(UNIX)
......@@ -50,42 +62,32 @@ endif(NOT CMAKE_BUILD_TYPE)
###########################################################
#targets providing sets of compiler options
if(NOT DEST)
set(DEST "safe" CACHE STRING "Choose safe, optimized, hera, or par, hera_par (with popc)" FORCE)
set(DEST "safe" CACHE STRING "Choose safe, optimized, hera, par or hera_par (with popc)" FORCE)
endif(NOT DEST)
if (DEST STREQUAL "par")
set(EXTRA_WARNINGS "-Wextra ")
set(OPTIM "-g -O3 -DNDEBUG")
set(ARCH "-mtune=native")
set(DEBUG "-g -O0 -D__DEBUG")
endif(DEST STREQUAL "par")
if (DEST STREQUAL "hera_par")
set(EXTRA_WARNINGS "-Wextra ")
set(OPTIM "-g -O3 -DNDEBUG")
if (DEST STREQUAL "hera_par") #only g++ is supported on hera
#required for AMD64: amdfam10 or fPIC, even for static libs
set(ARCH "-march=amdfam10 -fPIC")
set(DEBUG "-g -O0 -D__DEBUG")
endif(DEST STREQUAL "hera_par")
if (DEST STREQUAL "hera")
set(ARCH "-march=amdfam10")
endif(DEST STREQUAL "hera")
if (DEST STREQUAL "par")
set(ARCH "${ARCH_OPTIM}")
endif(DEST STREQUAL "par")
if (DEST STREQUAL "safe")
set(OPTIM "-g -O3 -DNDEBUG")
set(ARCH "")
set(DEBUG "-g -O0 -D__DEBUG")
set(ARCH "${ARCH_SAFE}")
endif(DEST STREQUAL "safe")
IF(DEST STREQUAL "optimized")
SET(OPTIM "-g -O3 -DNDEBUG")
SET(ARCH "-march=pentium4 -mtune=native")
SET(DEBUG "-g -O0 -D__DEBUG")
SET(ARCH "${ARCH_OPTIM}")
ENDIF(DEST STREQUAL "optimized")
if (DEST STREQUAL "hera")
set(OPTIM "-g -O3 -DNDEBUG")
set(ARCH "-march=amdfam10")
set(DEBUG "-g -O0 -D__DEBUG")
endif(DEST STREQUAL "hera")
###########################################################
#finally, set compile flags
set(CMAKE_CXX_FLAGS_RELEASE "${ARCH} ${OPTIM} ${CFLAGS} ${PLATFORM}" CACHE STRING "" FORCE)
set(CMAKE_CXX_FLAGS_DEBUG "${DEBUG} ${ARCH} ${CFLAGS} ${PLATFORM} ${WARNINGS} ${EXTRA_WARNINGS}" CACHE STRING "" FORCE)
......
......@@ -1070,7 +1070,7 @@ void Coords::parseUTMZone(const std::string& zone_info, char& zoneLetter, short
(sscanf(zone_info.c_str(), "%hd %c)", &zoneNumber, &zoneLetter) < 2)) {
throw InvalidFormatException("Can not parse given UTM zone: "+zone_info,AT);
}
zoneLetter = toupper(zoneLetter); //just in case... (sorry for the pun!)
zoneLetter = (char)toupper(zoneLetter); //just in case... (sorry for the pun!)
if(zoneLetter=='Y' || zoneLetter=='Z' || zoneLetter=='A' || zoneLetter=='B') {
//Special zones for the poles: we should NOT use UTM in these regions!
throw InvalidFormatException("Invalid UTM zone: "+zone_info+" (trying to use UTM in polar regions)",AT);
......
......@@ -73,7 +73,7 @@ void IOManager::push_meteo_data(const ProcessingLevel& level, const Date& date_s
}
}
unsigned int IOManager::getStationData(const Date& date, STATION_TIMESERIE& vecStation)
size_t IOManager::getStationData(const Date& date, STATION_TIMESERIE& vecStation)
{
vecStation.clear();
......@@ -88,7 +88,7 @@ unsigned int IOManager::getStationData(const Date& date, STATION_TIMESERIE& vecS
//for an interval of data: decide whether data should be filtered or raw
unsigned int IOManager::getMeteoData(const Date& dateStart, const Date& dateEnd,
size_t IOManager::getMeteoData(const Date& dateStart, const Date& dateEnd,
std::vector< METEO_TIMESERIE >& vecMeteo)
{
vecMeteo.clear();
......@@ -188,7 +188,7 @@ void IOManager::add_to_cache(const Date& i_date, const METEO_TIMESERIE& vecMeteo
}
//data can be raw or processed (filtered, resampled)
unsigned int IOManager::getMeteoData(const Date& i_date, METEO_TIMESERIE& vecMeteo)
size_t IOManager::getMeteoData(const Date& i_date, METEO_TIMESERIE& vecMeteo)
{
vecMeteo.clear();
......
......@@ -46,7 +46,7 @@ class IOManager {
void write2DGrid(const Grid2DObject& grid_in, const std::string& options="");
//end legacy support
unsigned int getStationData(const Date& date, STATION_TIMESERIE& vecStation);
size_t getStationData(const Date& date, STATION_TIMESERIE& vecStation);
/**
* @brief Fill vecMeteo with a time series of objects
......@@ -72,8 +72,8 @@ class IOManager {
* @param vecMeteo A vector of vector<MeteoData> objects to be filled with data
* @return Number of stations for which data has been found in the interval
*/
unsigned int getMeteoData(const Date& dateStart, const Date& dateEnd,
std::vector< METEO_TIMESERIE >& vecMeteo);
size_t getMeteoData(const Date& dateStart, const Date& dateEnd,
std::vector< METEO_TIMESERIE >& vecMeteo);
/**
* @brief Fill vector<MeteoData> object with multiple instances of MeteoData
......@@ -95,7 +95,7 @@ class IOManager {
* @param vecMeteo A vector of MeteoData objects to be filled with data
* @return Number of stations for which data has been found in the interval
*/
unsigned int getMeteoData(const Date& i_date, METEO_TIMESERIE& vecMeteo);
size_t getMeteoData(const Date& i_date, METEO_TIMESERIE& vecMeteo);
/**
* @brief Push a vector of time series of MeteoData objects into the IOManager. This overwrites
......
......@@ -122,7 +122,7 @@ void IOUtils::trim(std::string& str)
void IOUtils::toUpper(std::string& str){
for(unsigned int t=0; t<str.length(); t++) {
str[t] = toupper(str[t]);
str[t] = (char)toupper(str[t]);
}
}
......@@ -325,7 +325,7 @@ void IOUtils::skipLines(std::istream& fin, const unsigned int& nbLines, const ch
}
}
unsigned int IOUtils::readLineToVec(const std::string& line_in, std::vector<std::string>& vecString)
size_t IOUtils::readLineToVec(const std::string& line_in, std::vector<std::string>& vecString)
{
vecString.clear();
std::istringstream iss(line_in); //construct inputstream with the string line as input
......@@ -343,7 +343,7 @@ unsigned int IOUtils::readLineToVec(const std::string& line_in, std::vector<std:
return vecString.size();
}
unsigned int IOUtils::readLineToVec(const std::string& line_in, std::vector<std::string>& vecString, const char& delim)
size_t IOUtils::readLineToVec(const std::string& line_in, std::vector<std::string>& vecString, const char& delim)
{
vecString.clear();
std::string tmp_string;
......
......@@ -149,8 +149,8 @@ namespace IOUtils {
const std::string& keyprefix="", const bool& setToUpperCase=false);
void toUpper(std::string& str);
unsigned int readLineToVec(const std::string& line_in, std::vector<std::string>& vecString);
unsigned int readLineToVec(const std::string& line_in, std::vector<std::string>& vecString, const char& delim);
size_t readLineToVec(const std::string& line_in, std::vector<std::string>& vecString);
size_t readLineToVec(const std::string& line_in, std::vector<std::string>& vecString, const char& delim);
void readKeyValueHeader(std::map<std::string, std::string>& headermap,
std::istream& bs,
const unsigned int& linecount=1,
......
......@@ -88,8 +88,6 @@ InterpolationAlgorithm* AlgorithmFactory::getAlgorithm(const std::string& i_algo
} else {
throw IOException("The interpolation algorithm '"+algoname+"' is not implemented" , AT);
}
return NULL;
}
InterpolationAlgorithm::InterpolationAlgorithm(Meteo2DInterpolator& i_mi,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment