mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2024-12-13 19:50:34 +00:00
Cross-compilation fixes
This commit is contained in:
parent
3f5c8965c6
commit
06d58bcce1
@ -21,7 +21,7 @@
|
||||
# Project setup
|
||||
########################################################################
|
||||
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
|
||||
message(FATAL_ERROR "Prevented in-tree build. This is bad practice. Try 'cd build && cmake ../' ")
|
||||
message(WARNING "In-tree build is bad practice. Try 'cd build && cmake ../' ")
|
||||
endif(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
project(gnss-sdr CXX C)
|
||||
@ -398,11 +398,15 @@ if(OS_IS_MACOSX)
|
||||
endif(CMAKE_GENERATOR STREQUAL Xcode)
|
||||
endif(OS_IS_MACOSX)
|
||||
if(NOT VOLK_GNSSSDR_FOUND)
|
||||
set(VOLK_GNSSSDR_CMAKE_ARGS -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/volk_gnsssdr_module/install -DENABLE_STATIC_LIBS=ON ${STRIP_VOLK_GNSSSDR_PROFILE} ${USE_MACPORTS_PYTHON})
|
||||
if(CMAKE_TOOLCHAIN_FILE)
|
||||
set(VOLK_GNSSSDR_CMAKE_ARGS ${VOLK_GNSSSDR_CMAKE_ARGS} -DCMAKE_TOOLCHAIN_FILE ${CMAKE_TOOLCHAIN_FILE})
|
||||
endif(CMAKE_TOOLCHAIN_FILE)
|
||||
ExternalProject_Add(volk_gnsssdr_module
|
||||
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/volk_gnsssdr_module
|
||||
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr
|
||||
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/volk_gnsssdr_module/build
|
||||
CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/volk_gnsssdr_module/install -DENABLE_STATIC_LIBS=ON ${STRIP_VOLK_GNSSSDR_PROFILE} ${USE_MACPORTS_PYTHON}
|
||||
CMAKE_ARGS ${VOLK_GNSSSDR_CMAKE_ARGS}
|
||||
DOWNLOAD_COMMAND ""
|
||||
UPDATE_COMMAND ""
|
||||
PATCH_COMMAND ""
|
||||
@ -724,7 +728,7 @@ if(OS_IS_LINUX)
|
||||
else(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat")
|
||||
message(" sudo apt-get install gfortran")
|
||||
endif(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat")
|
||||
message(FATAL_ERROR "gfortran is required to build gnss-sdr")
|
||||
#message(FATAL_ERROR "gfortran is required to build gnss-sdr")
|
||||
endif(NOT GFORTRAN)
|
||||
endif(OS_IS_LINUX)
|
||||
|
||||
@ -1080,5 +1084,3 @@ add_subdirectory(src)
|
||||
if(ENABLE_PACKAGING)
|
||||
include(GnssSdrPackaging)
|
||||
endif(ENABLE_PACKAGING)
|
||||
|
||||
|
||||
|
@ -26,7 +26,7 @@ set (ARM_VERSION "")
|
||||
|
||||
if (CMAKE_COMPILER_IS_GNUCXX)
|
||||
execute_process(COMMAND echo "int main(){}"
|
||||
COMMAND ${CMAKE_CXX_COMPILER} -dM -E -
|
||||
COMMAND ${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1} -dM -E -
|
||||
OUTPUT_VARIABLE TEST_FOR_ARM_RESULTS)
|
||||
|
||||
string(REGEX MATCH "__arm" ARM_FOUND "${TEST_FOR_ARM_RESULTS}")
|
||||
|
@ -8,7 +8,7 @@
|
||||
function (test_for_sse h_file result_var name)
|
||||
if (NOT DEFINED ${result_var})
|
||||
execute_process(COMMAND echo "#include <${h_file}>"
|
||||
COMMAND ${CMAKE_CXX_COMPILER} -c -x c++ -
|
||||
COMMAND ${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1} -c -x c++ -
|
||||
RESULT_VARIABLE COMPILE_RESULT
|
||||
OUTPUT_QUIET ERROR_QUIET)
|
||||
set(detected 0)
|
||||
|
@ -38,6 +38,7 @@ set(CMAKE_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) #allows this to be a sub-proje
|
||||
set(CMAKE_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) #allows this to be a sub-project
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) #location for custom "Modules"
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
||||
|
||||
########################################################################
|
||||
# Environment setup
|
||||
|
@ -20,8 +20,7 @@
|
||||
#include "volk_gnsssdr/volk_gnsssdr_malloc.h"
|
||||
#include <pthread.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
#include <string.h>
|
||||
|
||||
/*
|
||||
* For #defines used to determine support for allocation functions,
|
||||
@ -52,12 +51,20 @@
|
||||
//#else // _ISOC11_SOURCE
|
||||
|
||||
// Otherwise, test if we are a POSIX or X/Open system
|
||||
// This only has a restriction that alignment be a power of 2.
|
||||
// This only has a restriction that alignment be a power of 2and a
|
||||
// multiple of sizeof(void *).
|
||||
#if _POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600 || HAVE_POSIX_MEMALIGN
|
||||
|
||||
void *volk_gnsssdr_malloc(size_t size, size_t alignment)
|
||||
{
|
||||
void *ptr;
|
||||
|
||||
// quoting posix_memalign() man page:
|
||||
// "alignment must be a power of two and a multiple of sizeof(void *)"
|
||||
// volk_get_alignment() could return 1 for some machines (e.g. generic_orc)
|
||||
if (alignment == 1)
|
||||
return malloc(size);
|
||||
|
||||
int err = posix_memalign(&ptr, alignment, size);
|
||||
if(err == 0)
|
||||
{
|
||||
@ -65,7 +72,9 @@ void *volk_gnsssdr_malloc(size_t size, size_t alignment)
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "VOLK: Error allocating memory (posix_memalign: %d)\n", err);
|
||||
fprintf(stderr,
|
||||
"VOLK: Error allocating memory "
|
||||
"(posix_memalign: error %d: %s)\n", err, strerror(err));
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user