1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-11-06 01:56:25 +00:00
This commit is contained in:
Carles Fernandez 2018-04-07 17:03:53 +02:00
commit 9b7c7b7875
4 changed files with 117 additions and 22 deletions

View File

@ -360,7 +360,7 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
endif(CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${GNSSSDR_GCC_MIN_VERSION}) endif(CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${GNSSSDR_GCC_MIN_VERSION})
endif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") endif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
execute_process(COMMAND execute_process(COMMAND
${CMAKE_CXX_COMPILER} -v ${CMAKE_CXX_COMPILER} -v
RESULT_VARIABLE _res ERROR_VARIABLE _err RESULT_VARIABLE _res ERROR_VARIABLE _err
@ -387,7 +387,7 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
else(${_res} STREQUAL "0") else(${_res} STREQUAL "0")
message(WARNING "\nCannot determine the version of the compiler selected to build GNSS-SDR (${APPLE_STR}Clang : ${CMAKE_CXX_COMPILER}). This build may or not work. We highly recommend using Apple Clang version ${APPLECLANG_MIN_VERSION} or more recent, or Clang version ${CLANG_MIN_VERSION} or more recent.") message(WARNING "\nCannot determine the version of the compiler selected to build GNSS-SDR (${APPLE_STR}Clang : ${CMAKE_CXX_COMPILER}). This build may or not work. We highly recommend using Apple Clang version ${APPLECLANG_MIN_VERSION} or more recent, or Clang version ${CLANG_MIN_VERSION} or more recent.")
endif(${_res} STREQUAL "0") endif(${_res} STREQUAL "0")
endif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") endif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
@ -783,7 +783,7 @@ if (NOT GLOG_FOUND OR ${LOCAL_GFLAGS})
set(GFLAGS_LIBRARY_DIR_TO_LINK ${GFlags_LIBRARY_DIRS}) set(GFLAGS_LIBRARY_DIR_TO_LINK ${GFlags_LIBRARY_DIRS})
endif(${LOCAL_GFLAGS}) endif(${LOCAL_GFLAGS})
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/tmp/configure_with_gflags file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/tmp/configure_with_gflags
"#!/bin/sh "#!/bin/sh
export CPPFLAGS=-I${GFlags_INCLUDE_DIRS} export CPPFLAGS=-I${GFlags_INCLUDE_DIRS}
@ -799,7 +799,7 @@ autoreconf -vfi
cd ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION} cd ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}
${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/glog/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/configure") ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/glog/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/configure")
else("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") else(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/tmp/configure_with_gflags file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/tmp/configure_with_gflags
"#!/bin/sh "#!/bin/sh
export CPPFLAGS=-I${GFlags_INCLUDE_DIRS} export CPPFLAGS=-I${GFlags_INCLUDE_DIRS}
@ -812,7 +812,7 @@ autoreconf -vfi
cd ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION} cd ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}
${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/glog/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/configure") ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/glog/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/configure")
endif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") endif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
file(COPY ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/tmp/configure_with_gflags file(COPY ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/tmp/configure_with_gflags
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}
@ -1458,37 +1458,49 @@ endif(ENABLE_GPROF)
######################################################################## ########################################################################
# Set compiler flags # Set compiler flags
######################################################################## ########################################################################
# Enable C++14 support in GCC / Fallback to C++11 when using GCC < 6.1.1 # Enable C++17 support in GCC >= 8.0.0
# Enable C++14 support in 8.0.0 > GCC >= 6.1.1
# Fallback to C++11 when using GCC < 6.1.1
if(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32) if(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32)
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "6.1.1") if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "6.1.1")
set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -std=c++11") set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -std=c++11")
else(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "6.1.1") else(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "6.1.1")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "8.0.0")
set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -std=c++14") set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -std=c++14")
else(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "8.0.0")
set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -std=c++17")
endif(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "8.0.0")
endif(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "6.1.1") endif(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "6.1.1")
set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -Wall -Wextra") #Add warning flags: For "-Wall" see http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -Wall -Wextra") #Add warning flags: For "-Wall" see http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
endif(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32) endif(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32)
# Enable C++14 support in Clang from 3.5 / Fallback to C++11 if older version and use lib++ if working in macOS # Enable C++17 support in Clang >= 6.0.0 or AppleClang >= 900
# Enable C++14 support in 6.0.0 > Clang >= 3.5.0 or 900 > AppleClang >= 600
# Fallback to C++11 if older version
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
if(OS_IS_MACOSX) if(OS_IS_MACOSX)
# See https://trac.macports.org/wiki/XcodeVersionInfo for Apple Clang version equivalences # See https://trac.macports.org/wiki/XcodeVersionInfo for Apple Clang version equivalences
if(CLANG_VERSION VERSION_LESS "600") if(CLANG_VERSION VERSION_LESS "600")
set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -std=c++11") set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -std=c++11")
else(CLANG_VERSION VERSION_LESS "600") else(CLANG_VERSION VERSION_LESS "600")
if(CLANG_VERSION VERSION_LESS "900")
set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -std=c++14") set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -std=c++14")
else(CLANG_VERSION VERSION_LESS "900")
set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -std=c++17")
endif(CLANG_VERSION VERSION_LESS "900")
endif(CLANG_VERSION VERSION_LESS "600") endif(CLANG_VERSION VERSION_LESS "600")
set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -Wno-deprecated-declarations")
else(OS_IS_MACOSX) else(OS_IS_MACOSX)
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "3.5.0") if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "3.5.0")
set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -std=c++11") set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -std=c++11")
else(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "3.5.0") else(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "3.5.0")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "6.0.0")
set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -std=c++14") set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -std=c++14")
else(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "6.0.0")
set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -std=c++17")
endif(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "6.0.0")
endif(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "3.5.0") endif(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "3.5.0")
endif(OS_IS_MACOSX) endif(OS_IS_MACOSX)
if(CMAKE_BUILD_TYPE MATCHES "Release")
set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -Wno-unused-private-field")
endif(CMAKE_BUILD_TYPE MATCHES "Release")
if(OS_IS_MACOSX) if(OS_IS_MACOSX)
set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -stdlib=libc++") set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -stdlib=libc++")
endif(OS_IS_MACOSX) endif(OS_IS_MACOSX)

View File

@ -27,9 +27,91 @@ enable_language(CXX)
enable_language(C) enable_language(C)
enable_testing() enable_testing()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall") # Set compiler flags
set(GNSSSDR_CLANG_MIN_VERSION "3.4.0")
set(GNSSSDR_APPLECLANG_MIN_VERSION "500")
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
execute_process(COMMAND
${CMAKE_CXX_COMPILER} -v
RESULT_VARIABLE _res ERROR_VARIABLE _err
ERROR_STRIP_TRAILING_WHITESPACE)
if(${_res} STREQUAL "0")
# output is in error stream
string(REGEX MATCH "^Apple.*" IS_APPLE ${_err})
if("${IS_APPLE}" STREQUAL "")
set(MIN_VERSION ${GNSSSDR_CLANG_MIN_VERSION})
set(APPLE_STR "")
# retrieve the compiler's version from it
string(REGEX MATCH "clang version [0-9.]+" CLANG_OTHER_VERSION ${_err})
string(REGEX MATCH "[0-9.]+" CLANG_VERSION ${CLANG_OTHER_VERSION})
else("${IS_APPLE}" STREQUAL "")
set(MIN_VERSION ${GNSSSDR_APPLECLANG_MIN_VERSION})
set(APPLE_STR "Apple ")
# retrieve the compiler's version from it
string(REGEX MATCH "(clang-[0-9.]+)" CLANG_APPLE_VERSION ${_err})
string(REGEX MATCH "[0-9.]+" CLANG_VERSION ${CLANG_APPLE_VERSION})
endif("${IS_APPLE}" STREQUAL "")
if(${CLANG_VERSION} VERSION_LESS "${MIN_VERSION}")
message(WARNING "\nThe compiler selected to build VOLK-GNSSSDR (${APPLE_STR}Clang version ${CLANG_VERSION} : ${CMAKE_CXX_COMPILER}) is older than that officially supported (${MIN_VERSION} minimum). This build may or not work. We highly recommend using Apple Clang version ${APPLECLANG_MIN_VERSION} or more recent, or Clang version ${CLANG_MIN_VERSION} or more recent.")
endif(${CLANG_VERSION} VERSION_LESS "${MIN_VERSION}")
else(${_res} STREQUAL "0")
message(WARNING "\nCannot determine the version of the compiler selected to build VOLK-GNSSSDR (${APPLE_STR}Clang : ${CMAKE_CXX_COMPILER}). This build may or not work. We highly recommend using Apple Clang version ${APPLECLANG_MIN_VERSION} or more recent, or Clang version ${CLANG_MIN_VERSION} or more recent.")
endif(${_res} STREQUAL "0")
endif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# Enable C++17 support in GCC >= 8.0.0
# Enable C++14 support in 8.0.0 > GCC >= 6.1.1
# Fallback to C++11 when using GCC < 6.1.1
if(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32)
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "6.1.1")
set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -std=c++11")
else(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "6.1.1")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "8.0.0")
set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -std=c++14")
else(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "8.0.0")
set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -std=c++17")
endif(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "8.0.0")
endif(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "6.1.1")
set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -Wall -Wextra") #Add warning flags: For "-Wall" see http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
endif(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32)
# Enable C++17 support in Clang >= 6.0.0 or AppleClang >= 900
# Enable C++14 support in 6.0.0 > Clang >= 3.5.0 or 900 > AppleClang >= 600
# Fallback to C++11 if older version
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
# See https://trac.macports.org/wiki/XcodeVersionInfo for Apple Clang version equivalences
if(CLANG_VERSION VERSION_LESS "600")
set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -std=c++11")
else(CLANG_VERSION VERSION_LESS "600")
if(CLANG_VERSION VERSION_LESS "900")
set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -std=c++14")
else(CLANG_VERSION VERSION_LESS "900")
set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -std=c++17")
endif(CLANG_VERSION VERSION_LESS "900")
endif(CLANG_VERSION VERSION_LESS "600")
else(CMAKE_SYSTEM_NAME MATCHES "Darwin")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "3.5.0")
set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -std=c++11")
else(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "3.5.0")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "6.0.0")
set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -std=c++14")
else(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "6.0.0")
set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -std=c++17")
endif(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "6.0.0")
endif(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "3.5.0")
endif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
endif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
if(NOT (CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32) AND NOT (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
if(NOT (CMAKE_VERSION VERSION_LESS "3.1"))
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 11)
endif(NOT (CMAKE_VERSION VERSION_LESS "3.1"))
endif(NOT (CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32) AND NOT (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MY_CXX_FLAGS} -Wall")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
add_definitions(-D_GLIBCXX_USE_CXX11_ABI=1)
if(CMAKE_VERSION VERSION_GREATER "3.0") if(CMAKE_VERSION VERSION_GREATER "3.0")
cmake_policy(SET CMP0042 NEW) cmake_policy(SET CMP0042 NEW)

View File

@ -133,8 +133,8 @@ void signal_generator_c::init()
} }
} }
} }
random_ = new gr::random();
std::default_random_engine e1(r()); std::default_random_engine e1(r());
std::default_random_engine e2(r());
std::uniform_int_distribution<int> uniform_dist(0, RAND_MAX); std::uniform_int_distribution<int> uniform_dist(0, RAND_MAX);
} }
@ -271,7 +271,6 @@ signal_generator_c::~signal_generator_c()
} }
} */ } */
volk_gnsssdr_free(complex_phase_); volk_gnsssdr_free(complex_phase_);
delete random_;
} }
@ -433,7 +432,7 @@ int signal_generator_c::general_work(int noutput_items __attribute__((unused)),
{ {
for (out_idx = 0; out_idx < vector_length_; out_idx++) for (out_idx = 0; out_idx < vector_length_; out_idx++)
{ {
out[out_idx] += gr_complex(random_->gasdev(), random_->gasdev()); out[out_idx] += gr_complex(normal_dist(e1), normal_dist(e2));
} }
} }

View File

@ -33,7 +33,7 @@
#include "gnss_signal.h" #include "gnss_signal.h"
#include <boost/scoped_array.hpp> #include <boost/scoped_array.hpp>
#include <gnuradio/random.h> //#include <gnuradio/random.h>
#include <gnuradio/block.h> #include <gnuradio/block.h>
#include <string> #include <string>
#include <vector> #include <vector>
@ -120,13 +120,15 @@ private:
boost::scoped_array<gr_complex *> sampled_code_data_; boost::scoped_array<gr_complex *> sampled_code_data_;
boost::scoped_array<gr_complex *> sampled_code_pilot_; boost::scoped_array<gr_complex *> sampled_code_pilot_;
gr::random *random_; //gr::random *random_;
gr_complex *complex_phase_; gr_complex *complex_phase_;
unsigned int work_counter_; unsigned int work_counter_;
std::random_device r; std::random_device r;
std::default_random_engine e1; std::default_random_engine e1;
std::default_random_engine e2;
std::uniform_int_distribution<int> uniform_dist; std::uniform_int_distribution<int> uniform_dist;
std::normal_distribution<float> normal_dist;
public: public:
~signal_generator_c(); // public destructor ~signal_generator_c(); // public destructor