mirror of
				https://github.com/gnss-sdr/gnss-sdr
				synced 2025-10-31 07:13:03 +00:00 
			
		
		
		
	Now GNSS-SDR also builds on Mac OS X 10.9 Mavericks using clang++ and libc++. Updated cmake scripts, some modification of code not accepted by clang. Updated README with instructions for Mavericks. Fixed file length computation in 64-bit architectures.
git-svn-id: https://svn.code.sf.net/p/gnss-sdr/code/trunk@435 64b25241-fba3-4117-9849-534c7e92360d
This commit is contained in:
		| @@ -68,6 +68,11 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") | ||||
|      set(OS_IS_MACOSX TRUE) | ||||
|      set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++11") | ||||
|      set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++") | ||||
|      exec_program(uname ARGS -v  OUTPUT_VARIABLE DARWIN_VERSION) | ||||
|      string(REGEX MATCH "[0-9]+" DARWIN_VERSION ${DARWIN_VERSION}) | ||||
|      if(${DARWIN_VERSION} MATCHES "13") | ||||
|          set(MACOSX_MAVERICKS TRUE) | ||||
|      endif(${DARWIN_VERSION} MATCHES "13") | ||||
| endif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") | ||||
|  | ||||
|  | ||||
| @@ -120,32 +125,6 @@ endif(NOT Boost_FOUND) | ||||
| # GNU Radio - http://gnuradio.org/redmine/projects/gnuradio/wiki | ||||
| ################################################################################ | ||||
|  | ||||
| if(INSTALL_GNURADIO) | ||||
|      if(OperatingSystem MATCHES "Linux") | ||||
|           message("Trying to install GNU Radio and all its dependencies.") | ||||
|           message("This process can take a long time.") | ||||
|           #set(GNURADIO_RELEASE "3.7.0") | ||||
|           #set(UHD_RELEASE "003_005_003") | ||||
|           set(INSTALL_GNURADIO CACHE BOOL OFF FORCE) | ||||
|           file(DOWNLOAD http://www.sbrac.org/files/build-gnuradio | ||||
|                ${CMAKE_CURRENT_BINARY_DIR}/download/build-gnuradio | ||||
|           ) | ||||
|           file(COPY ${CMAKE_CURRENT_BINARY_DIR}/download/build-gnuradio | ||||
|                DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty | ||||
|                FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE | ||||
|           ) | ||||
|           execute_process( | ||||
|                COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/build-gnuradio -l ${CMAKE_CURRENT_BINARY_DIR}/build-gnuradio.log | ||||
|                WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty | ||||
|           ) | ||||
|           #  The flags -gt v${GNURADIO_RELEASE} -ut release_${UHD_RELEASE} do not work :-(      | ||||
|      else(OperatingSystem MATCHES "Linux") | ||||
|           message( "The script http://www.sbrac.org/files/build-gnuradio does not work in your operating system.") | ||||
|           message( "Please visit http://gnuradio.org and find out how to install GNU Radio.") | ||||
|           message( "Once installed, run 'cmake ${RELATIVE_CMAKE_CALL}' again.") | ||||
|      endif(OperatingSystem MATCHES "Linux") | ||||
| endif(INSTALL_GNURADIO) | ||||
|  | ||||
|  | ||||
| find_package(GnuradioRuntime) | ||||
| find_package(GnuradioBlocks) | ||||
| @@ -156,25 +135,25 @@ find_package(GnuradioFilter) | ||||
| find_package(GnuradioFft) | ||||
| find_package(Volk) | ||||
| if(NOT GNURADIO_RUNTIME_FOUND) | ||||
|     message(FATAL_ERROR "gnuradio-runtime 3.7 or later is required to build gnss-sdr") | ||||
|    # message(FATAL_ERROR "gnuradio-runtime 3.7 or later is required to build gnss-sdr") | ||||
| endif() | ||||
| if(NOT GNURADIO_BLOCKS_FOUND) | ||||
|     message(FATAL_ERROR "gnuradio-blocks 3.7 or later is required to build gnss-sdr") | ||||
|     #message(FATAL_ERROR "gnuradio-blocks 3.7 or later is required to build gnss-sdr") | ||||
| endif() | ||||
| if(NOT UHD_FOUND) | ||||
|     message(FATAL_ERROR "UHD is required to build gnss-sdr") | ||||
|     #message(FATAL_ERROR "UHD is required to build gnss-sdr") | ||||
| endif() | ||||
| if(NOT GNURADIO_UHD_FOUND) | ||||
|     message(FATAL_ERROR "gnuradio-uhd 3.7 or later is required to build gnss-sdr") | ||||
|     #message(FATAL_ERROR "gnuradio-uhd 3.7 or later is required to build gnss-sdr") | ||||
| endif() | ||||
| if(NOT GNURADIO_FILTER_FOUND) | ||||
|     message(FATAL_ERROR "gnuradio-filter 3.7 or later is required to build gnss-sdr") | ||||
|     #message(FATAL_ERROR "gnuradio-filter 3.7 or later is required to build gnss-sdr") | ||||
| endif() | ||||
| if(NOT GNURADIO_FFT_FOUND) | ||||
|     message(FATAL_ERROR "gnuradio-fft 3.7 or later is required to build gnss-sdr") | ||||
|     #message(FATAL_ERROR "gnuradio-fft 3.7 or later is required to build gnss-sdr") | ||||
| endif() | ||||
| if(NOT VOLK_FOUND) | ||||
|     message(FATAL_ERROR "VOLK is required to build gnss-sdr") | ||||
|     #message(FATAL_ERROR "VOLK is required to build gnss-sdr") | ||||
| endif() | ||||
|  | ||||
|  | ||||
| @@ -470,7 +449,6 @@ endif($ENV{RTLSDR_DRIVER} ) | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| ######################################################################## | ||||
| # Set compiler flags | ||||
| ######################################################################## | ||||
| @@ -516,6 +494,7 @@ endif(GPERFTOOLS_FOUND) | ||||
| if( CMAKE_SIZEOF_VOID_P EQUAL 8 ) | ||||
|      # message("64-bits architecture detected.")  | ||||
|      #set(MY_CXX_FLAGS "${MY_CXX_FLAGS}  ...") | ||||
|      set(ARCH_64BITS TRUE) | ||||
|      # link_libraries(pthread) # Needed by Fedora 18 | ||||
| endif( CMAKE_SIZEOF_VOID_P EQUAL 8 ) | ||||
|  | ||||
|   | ||||
							
								
								
									
										63
									
								
								README
									
									
									
									
									
								
							
							
						
						
									
										63
									
								
								README
									
									
									
									
									
								
							| @@ -239,7 +239,68 @@ $ rm -rf gnss-sdr/build/* | ||||
|  | ||||
| Mac OS X  | ||||
| ------------------------------ | ||||
| Tested version: 10.8.5 (Mountain Lion) | ||||
| Tested versions: 10.8 (Mountain Lion) and 10.9 (Mavericks) | ||||
|  | ||||
|  | ||||
|  | ||||
| MAC OS X 10.9 Mavericks | ||||
| --------------------------- | ||||
| If you still have not installed Xcode, do it now from the App Store (it's free). Once installed, open a terminal and type: | ||||
|  | ||||
| $ xcode-select --install | ||||
|  | ||||
| and follow the instructions in the screen. | ||||
|  | ||||
| Install Macports: https://distfiles.macports.org/MacPorts/MacPorts-2.2.1-10.9-Mavericks.pkg | ||||
|  | ||||
| (if you are upgrading from a previous installation, please folloe the migration rules at http://trac.macports.org/wiki/Migration) | ||||
|  | ||||
| In a terminal, type: | ||||
|  | ||||
| $ sudo port selfupdate | ||||
| $ sudo port upgrade outdated | ||||
| $ sudo port install doxygen +latex | ||||
| $ sudo port install gnuradio | ||||
| $ sudo port install armadillo | ||||
|  | ||||
| Install GFlags manually from the trunk: | ||||
|  | ||||
| $ svn checkout http://gflags.googlecode.com/svn/trunk gflags-trunk | ||||
| $ cd gflags-trunk | ||||
| $ CXXFLAGS="-stdlib=libc++" CC=clang CXX=clang++ ./configure   | ||||
| $ make | ||||
| $ sudo make install | ||||
|  | ||||
| Install Glog manually from the trunk, after applying a patch: | ||||
|  | ||||
| $ svn checkout -r139 http://google-glog.googlecode.com/svn/trunk/ google-glog | ||||
| $ cd google-glog | ||||
|   | ||||
| Open your browser and go to: http://code.google.com/p/google-glog/issues/detail?id=121 | ||||
|  | ||||
| Download  libc++.diff (from comment #3) | ||||
|  | ||||
| $ mv $HOME/Downloads/libc++.diff . | ||||
| $ cd src | ||||
| $ patch  < ../libc++.diff | ||||
| $ cd .. | ||||
| $ CXXFLAGS="-stdlib=libc++" CC=clang CXX=clang++ ./configure  | ||||
| $ make | ||||
| $ sudo make install | ||||
|  | ||||
| Finally, you are ready to checkout the GNSS-SDR repository and build the software: | ||||
|  | ||||
| $ svn co http://svn.code.sf.net/p/gnss-sdr/code/trunk gnss-sdr | ||||
| $ cd gnss-sdr/build | ||||
| $ cmake ../ -DCMAKE_CXX_COMPILER=/usr/bin/clang++ | ||||
| $ make | ||||
| $ make install | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| MAC OS X 10.8 Mountain Lion  | ||||
| --------------------------- | ||||
|  | ||||
| If you still have not installed Xcode, do it now from the App Store (it's free). Once installed, download and install the command line tools: | ||||
|  | ||||
|   | ||||
| @@ -122,8 +122,8 @@ galileo_e1_gen(std::complex<float>* _dest, int* _prn, char _Signal[3]) | ||||
|     const float alpha = sqrt(10.0 / 11.0); | ||||
|     const float beta = sqrt(1.0 / 11.0); | ||||
|  | ||||
|     std::complex<float> sinboc_11[_codeLength]; // 12*4092 (_codeLength not accepted by Clang ) | ||||
|     std::complex<float> sinboc_61[_codeLength]; | ||||
|     std::complex<float> sinboc_11[12*4092]; //  _codeLength not accepted by Clang | ||||
|     std::complex<float> sinboc_61[12*4092]; | ||||
|  | ||||
|     galileo_e1_sinboc_11_gen(sinboc_11, _prn, _codeLength); //generate sinboc(1,1) 12 samples per chip | ||||
|     galileo_e1_sinboc_61_gen(sinboc_61, _prn, _codeLength); //generate sinboc(6,1) 12 samples per chip | ||||
| @@ -154,7 +154,7 @@ galileo_e1_code_gen_complex_sampled(std::complex<float>* _dest, char _Signal[3], | ||||
|         bool _secondary_flag) | ||||
| { | ||||
|  | ||||
|     // This function is based on the GNU software GPS for MATLAB in the Kay Borre bookç | ||||
|     // This function is based on the GNU software GPS for MATLAB in Kay Borre's book | ||||
|  | ||||
|     std::string _galileo_signal = _Signal; | ||||
|     unsigned int _samplesPerCode; | ||||
|   | ||||
| @@ -27,9 +27,6 @@ | ||||
|  * | ||||
|  * ------------------------------------------------------------------------- | ||||
|  */ | ||||
| //#ifdef HAVE_CONFIG_H | ||||
| //#include "config.h" | ||||
| //#endif | ||||
|  | ||||
| #include "signal_generator_c.h" | ||||
| #include <gnuradio/io_signature.h> | ||||
| @@ -143,7 +140,7 @@ void signal_generator_c::generate_codes() | ||||
|             if (posix_memalign((void**)&(sampled_code_data_[sat]), 16, | ||||
|                                vector_length_ * sizeof(gr_complex)) == 0){}; | ||||
|  | ||||
|             gr_complex code[samples_per_code_[sat]]; | ||||
|             gr_complex code[8000];//[samples_per_code_[sat]]; | ||||
|  | ||||
|             if (system_[sat] == "G") | ||||
|                 { | ||||
|   | ||||
| @@ -90,5 +90,9 @@ include_directories( | ||||
|      ${Boost_INCLUDE_DIRS} | ||||
| ) | ||||
|  | ||||
| if(ARCH_64BITS) | ||||
|     add_definitions(-DARCH_64BITS=1) | ||||
| endif(ARCH_64BITS) | ||||
|  | ||||
| add_library(signal_source_adapters ${SIGNAL_SOURCE_ADAPTER_SOURCES}) | ||||
| target_link_libraries(signal_source_adapters signal_source_gr_blocks ${Boost_LIBRARIES}  ${GNURADIO_PMT_LIBRARIES} ${GNURADIO_BLOCKS_LIBRARIES} ${UHD_LIBRARIES}  ${GNURADIO_UHD_LIBRARIES} ${OPT_LIBRARIES} gnss_sp_libs) | ||||
|   | ||||
| @@ -142,13 +142,16 @@ FileSignalSource::FileSignalSource(ConfigurationInterface* configuration, | ||||
|  | ||||
|             if (size > 0) | ||||
|                 { | ||||
|                     samples_ = floor((double)size / (double)item_size() - ceil(0.002 * (double)sampling_frequency_)); //process all the samples available in the file excluding the last 2 ms | ||||
|                     samples_ = floor((double)size / (double)item_size() - ceil(0.002 * (double)sampling_frequency_)); //process all the samples available in the file excluding at least the last 1 ms | ||||
|                 } | ||||
|         } | ||||
|  | ||||
|     CHECK(samples_ > 0) << "File does not contain enough samples to process."; | ||||
|     double signal_duration_s; | ||||
|     signal_duration_s = (double)samples_ * ( 1 /(double)sampling_frequency_); | ||||
| #ifdef ARCH_64BITS | ||||
|     signal_duration_s /= 2; | ||||
| #endif | ||||
|     DLOG(INFO) << "Total number samples to be processed= " << samples_ << " GNSS signal duration= " << signal_duration_s << " [s]"; | ||||
|     std::cout << "GNSS signal recorded time to be processed: " << signal_duration_s << " [s]" << std::endl; | ||||
|  | ||||
|   | ||||
| @@ -34,9 +34,13 @@ include_directories( | ||||
| add_definitions( -DGNSS_SDR_VERSION="${VERSION}" ) | ||||
|  | ||||
| if(OS_IS_MACOSX) | ||||
|      # Tell the linker where the libraries installed by MacPorts are | ||||
|      if (MACOSX_MAVERICKS) | ||||
|          link_directories( /opt/local/lib /usr/local/lib) # Not very elegant, to be fixed | ||||
|          set(MAC_LIBRARIES "-stdlib=libc++ -std=c++11 -lgnuradio-runtime -lgnuradio-pmt -lgnuradio-blocks -lgnuradio-fft -lgnuradio-filter -lgnuradio-uhd ${GFlags_LIBS} ${GLOG_LIBRARIES}") | ||||
|      else(MACOSX_MAVERICKS) | ||||
|          link_directories( /opt/local/lib )  # Not very elegant, to be fixed | ||||
|          set(MAC_LIBRARIES "-lstdc++") | ||||
|      endif(MACOSX_MAVERICKS) | ||||
| endif(OS_IS_MACOSX) | ||||
|  | ||||
| add_executable(gnss-sdr ${CMAKE_CURRENT_SOURCE_DIR}/main.cc) | ||||
|   | ||||
| @@ -25,6 +25,20 @@ endif(NOT EXISTS GTEST_DIR_LOCAL) | ||||
| if(NOT GTEST_DIR_LOCAL) | ||||
|      # if GTEST_DIR is not defined, we download and build it | ||||
|      set(gtest_RELEASE 1.7.0) | ||||
|      if(MACOSX_MAVERICKS) | ||||
|          ExternalProject_Add( | ||||
|               gtest-${gtest_RELEASE} | ||||
|               URL http://googletest.googlecode.com/files/gtest-${gtest_RELEASE}.zip | ||||
|               DOWNLOAD_DIR ${CMAKE_CURRENT_BINARY_DIR}/../../download/gtest-${gtest_RELEASE} | ||||
|               URL_MD5 "2d6ec8ccdf5c46b05ba54a9fd1d130d7" | ||||
|               SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/gtest/gtest-${gtest_RELEASE} | ||||
|               BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/../../gtest-${gtest_RELEASE} | ||||
|               CMAKE_ARGS -DCMAKE_CXX_COMPILER=/usr/bin/clang++ | ||||
|               UPDATE_COMMAND "" | ||||
|               PATCH_COMMAND "" | ||||
|               INSTALL_COMMAND "" | ||||
|          ) | ||||
|      else(MACOSX_MAVERICKS) | ||||
|          ExternalProject_Add( | ||||
|               gtest-${gtest_RELEASE} | ||||
|               URL http://googletest.googlecode.com/files/gtest-${gtest_RELEASE}.zip | ||||
| @@ -36,6 +50,7 @@ if(NOT GTEST_DIR_LOCAL) | ||||
|               PATCH_COMMAND "" | ||||
|               INSTALL_COMMAND "" | ||||
|          ) | ||||
|      endif(MACOSX_MAVERICKS) | ||||
|      # Set up variables | ||||
|      # Set recently downloaded and build Googletest root folder | ||||
|      set(GTEST_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/gtest/gtest-${gtest_RELEASE}") | ||||
| @@ -101,13 +116,17 @@ find_library( | ||||
|            /usr/lib64 | ||||
| ) | ||||
| if(OS_IS_MACOSX) | ||||
|      if(MACOSX_MAVERICKS) | ||||
|          # Tell the linker where the libraries installed by MacPorts are | ||||
|          link_directories(/opt/local/lib /usr/local/lib ) # not very elegant, to be fixed | ||||
|          set(MAC_LIBRARIES "-stdlib=libc++ -std=c++11 -lgnuradio-runtime -lgnuradio-pmt -lgnuradio-blocks -lgnuradio-fft -lgnuradio-filter -lgnuradio-uhd") | ||||
|      else(MACOSX_MAVERICKS) | ||||
|          link_directories( /opt/local/lib ) # not very elegant, to be fixed | ||||
|      # set(MAC_LIBRARIES sdtc++) | ||||
|      endif(MACOSX_MAVERICKS) | ||||
| endif(OS_IS_MACOSX) | ||||
|  | ||||
| add_executable(run_tests ${CMAKE_CURRENT_SOURCE_DIR}/test_main.cc) | ||||
| target_link_libraries(run_tests ${Boost_LIBRARIES}  ${GFLAGS_LIBS} ${GLOG_LIBRARIES} ${GTEST_LIBRARIES} ${GNURADIO_RUNTIME_LIBRARIES} ${GNURADIO_BLOCKS_LIBRARIES} ${GNURADIO_FILTER_LIBRARIES} ${GNURADIO_ANALOG_LIBRARIES} gnss_sp_libs gnss_rx) | ||||
| target_link_libraries(run_tests ${MAC_LIBRARIES} ${Boost_LIBRARIES}  ${GFLAGS_LIBS} ${GLOG_LIBRARIES} ${GTEST_LIBRARIES} ${GNURADIO_RUNTIME_LIBRARIES} ${GNURADIO_BLOCKS_LIBRARIES} ${GNURADIO_FILTER_LIBRARIES} ${GNURADIO_ANALOG_LIBRARIES} gnss_sp_libs gnss_rx  signal_generator_blocks) | ||||
|  | ||||
| install(TARGETS run_tests DESTINATION ${CMAKE_SOURCE_DIR}/install) | ||||
|  | ||||
| @@ -145,7 +164,7 @@ add_executable(gnss_block_test EXCLUDE_FROM_ALL | ||||
|      ${CMAKE_CURRENT_SOURCE_DIR}/gnss_block/file_output_filter_test.cc | ||||
|      ${CMAKE_CURRENT_SOURCE_DIR}/gnss_block/gnss_block_factory_test.cc    | ||||
| ) | ||||
| target_link_libraries(gnss_block_test ${Boost_LIBRARIES} ${GFLAGS_LIBS} ${GLOG_LIBRARIES} ${GTEST_LIBRARIES} gnss_sp_libs gnss_rx) | ||||
| target_link_libraries(gnss_block_test ${Boost_LIBRARIES} ${GFLAGS_LIBS} ${GLOG_LIBRARIES} ${GTEST_LIBRARIES} gnss_sp_libs gnss_rx signal_generator_blocks) | ||||
| add_test(gnss_block_test gnss_block_test) | ||||
|  | ||||
|   | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Carles Fernandez
					Carles Fernandez