1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-12-15 04:30:33 +00:00

Merge branch 'more-modern-cmake' into next

This commit is contained in:
Carles Fernandez 2019-02-24 19:32:13 +01:00
commit ccf575de86
No known key found for this signature in database
GPG Key ID: 4C583C52B0C3877D

View File

@ -418,25 +418,26 @@ if(NOT (CMAKE_VERSION VERSION_LESS "3.1"))
set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_CXX_EXTENSIONS OFF)
else() else()
add_compile_options("$<$<STREQUAL:$<TARGET_PROPERTY:LINKER_LANGUAGE>,C>:-std=gnu11>")
if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND NOT WIN32) if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") 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") add_compile_options("$<$<STREQUAL:$<TARGET_PROPERTY:LINKER_LANGUAGE>,CXX>:-std=c++11>")
else() else()
set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -std=c++14") add_compile_options("$<$<STREQUAL:$<TARGET_PROPERTY:LINKER_LANGUAGE>,CXX>:-std=c++14>")
endif() endif()
endif() endif()
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
if(OS_IS_MACOSX) if(OS_IS_MACOSX)
if(CLANG_VERSION VERSION_LESS "600") if(CLANG_VERSION VERSION_LESS "600")
set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -std=c++11") add_compile_options("$<$<STREQUAL:$<TARGET_PROPERTY:LINKER_LANGUAGE>,CXX>:-std=c++11>")
else() else()
set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -std=c++14") add_compile_options("$<$<STREQUAL:$<TARGET_PROPERTY:LINKER_LANGUAGE>,CXX>:-std=c++14>")
endif() endif()
else() else()
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") add_compile_options("$<$<STREQUAL:$<TARGET_PROPERTY:LINKER_LANGUAGE>,CXX>:-std=c++11>")
else() else()
set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -std=c++14") add_compile_options("$<$<STREQUAL:$<TARGET_PROPERTY:LINKER_LANGUAGE>,CXX>:-std=c++14>")
endif() endif()
endif() endif()
endif() endif()
@ -1834,10 +1835,10 @@ if(ENABLE_GPERFTOOLS)
# See https://github.com/gperftools/gperftools/blob/master/README # See https://github.com/gperftools/gperftools/blob/master/README
if(GPERFTOOLS_FOUND) if(GPERFTOOLS_FOUND)
if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND NOT WIN32) if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND NOT WIN32)
set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free") add_compile_options(-fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free)
endif() endif()
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -fno-builtin") add_compile_options(-fno-builtin)
endif() endif()
endif() endif()
endif() endif()
@ -1848,7 +1849,7 @@ endif()
# GNU gprof (OPTIONAL) - https://sourceware.org/binutils/docs/gprof/ # GNU gprof (OPTIONAL) - https://sourceware.org/binutils/docs/gprof/
######################################################################## ########################################################################
if(ENABLE_GPROF) if(ENABLE_GPROF)
set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -pg") add_compile_options(-pg)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pg") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pg")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -pg") set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -pg")
endif() endif()
@ -1858,35 +1859,39 @@ endif()
# Set compiler flags # Set compiler flags
######################################################################## ########################################################################
if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND NOT WIN32) if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND NOT WIN32)
set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -Wall -Wextra") #Add warning flags: For "-Wall" see https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html # Add warning flags
# For "-Wall" see https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
set(cxx_warning_flags -Wall -Wextra)
add_compile_options("$<$<STREQUAL:$<TARGET_PROPERTY:LINKER_LANGUAGE>,CXX>:${cxx_warning_flags}>")
if(CMAKE_CROSSCOMPILING)
add_compile_options(-Wno-psabi)
endif()
endif() endif()
# Processor-architecture related flags # Processor-architecture related flags
# See https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html # See https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html
if(NOT ARCH_COMPILER_FLAGS) if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND NOT WIN32)
if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND NOT WIN32) if(OS_IS_MACOSX)
if(OS_IS_MACOSX) add_compile_options(-march=corei7 -mfpmath=sse)
set(ARCH_COMPILER_FLAGS "-march=corei7 -mfpmath=sse") else()
else() if(NOT ENABLE_GENERIC_ARCH)
if(NOT ${ENABLE_GENERIC_ARCH}) if(IS_ARM)
if(IS_ARM) # ARM-specific options (https://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html) # ARM-specific options
if(NOT CMAKE_CROSSCOMPILING) # See https://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html
if(ARM_VERSION STREQUAL "arm") if(NOT CMAKE_CROSSCOMPILING)
# Unknown arm version - try our best to detect if(ARM_VERSION STREQUAL "arm")
set(ARCH_COMPILER_FLAGS "-mcpu=native") # Unknown arm version - try our best to detect
else() add_compile_options(-mcpu=native)
set(ARCH_COMPILER_FLAGS "-march=${ARM_VERSION}") else()
endif() add_compile_options(-march=${ARM_VERSION})
endif() endif()
else() endif()
set(ARCH_COMPILER_FLAGS "-march=native -mfpmath=sse") else()
endif() add_compile_options(-march=native -mfpmath=sse)
endif() endif()
endif() endif()
endif() endif()
endif() endif()
set(MY_CXX_FLAGS "${MY_CXX_FLAGS} ${ARCH_COMPILER_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MY_CXX_FLAGS}")