From bcecdf292baf36f332bf183b77a89b192f8f9038 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Wed, 31 May 2017 13:44:10 +0200 Subject: [PATCH] add C++ compile flags and enable useful warnings --- CMakeLists.txt | 19 +++++++++++++++++++ lib/CMakeLists.txt | 13 ------------- lib/src/asn1/CMakeLists.txt | 2 +- srsue/test/mac/CMakeLists.txt | 2 +- 4 files changed, 21 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d3eb7b76f..57bdb3f8b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -200,10 +200,12 @@ endif(CMAKE_COMPILER_IS_GNUCXX) if(CMAKE_COMPILER_IS_GNUCC) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wno-write-strings -Wno-format-extra-args -Winline -Wno-unused-result -Wno-format -std=c99 -D_GNU_SOURCE -g") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-reorder -Wno-unused-but-set-variable -Wno-unused-variable") if(${CMAKE_BUILD_TYPE} STREQUAL "Debug") find_package(SSE) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 -DDEBUG_MODE") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -std=c++03") if(HAVE_AVX) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native -mfpmath=sse -mavx -DLV_HAVE_AVX -DLV_HAVE_SSE") elseif(HAVE_SSE) @@ -211,14 +213,18 @@ if(CMAKE_COMPILER_IS_GNUCC) endif(HAVE_AVX) else(${CMAKE_BUILD_TYPE} STREQUAL "Debug") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -std=c++03") find_package(SSE) if (HAVE_AVX2) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native -mfpmath=sse -mavx2 -Ofast -funroll-loops -DLV_HAVE_AVX -DLV_HAVE_SSE") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -mfpmath=sse -mavx2 -DLV_HAVE_AVX -DLV_HAVE_SSE") else (HAVE_AVX2) if(HAVE_AVX) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native -mfpmath=sse -mavx -Ofast -funroll-loops -DLV_HAVE_AVX -DLV_HAVE_SSE") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -mfpmath=sse -mavx -DLV_HAVE_AVX -DLV_HAVE_SSE") elseif(HAVE_SSE) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native -mfpmath=sse -msse4.1 -Ofast -funroll-loops -DLV_HAVE_SSE") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -mfpmath=sse -msse4.1 -DLV_HAVE_SSE") endif(HAVE_AVX) endif (HAVE_AVX2) @@ -288,6 +294,19 @@ include_directories(${PROJECT_SOURCE_DIR}/lib/include) # Includes needed by all code previously resided in srsUE include_directories(${PROJECT_SOURCE_DIR}/lib/include/srslte) +######################################################################## +# Add headers to cmake project (useful for IDEs) +######################################################################## +set(HEADERS_ALL "") +file(GLOB headers *) +foreach(_header ${headers}) + if(IS_DIRECTORY ${_header}) + file(GLOB_RECURSE tmp "${_header}/*.h") + list(APPEND HEADERS_ALL ${tmp}) + endif(IS_DIRECTORY ${_header}) +endforeach() +add_custom_target(add_srslte_headers SOURCES ${HEADERS_ALL}) + ######################################################################## # Add the subdirectories ######################################################################## diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 1f30ed290..15aa4d635 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -26,19 +26,6 @@ INSTALL(DIRECTORY include/ FILES_MATCHING PATTERN "*.h" ) -######################################################################## -# Add headers to cmake project (useful for IDEs) -######################################################################## -set(HEADERS_ALL "") -file(GLOB headers *) -FOREACH (_header ${headers}) - if(IS_DIRECTORY ${_header}) - file(GLOB_RECURSE tmp "${_header}/*.h") - list(APPEND HEADERS_ALL ${tmp}) - endif(IS_DIRECTORY ${_header}) -ENDFOREACH() -add_custom_target (add_srslte_headers SOURCES ${HEADERS_ALL}) - ######################################################################## # Find Dependencies ######################################################################## diff --git a/lib/src/asn1/CMakeLists.txt b/lib/src/asn1/CMakeLists.txt index 83fe5e315..b9671177d 100644 --- a/lib/src/asn1/CMakeLists.txt +++ b/lib/src/asn1/CMakeLists.txt @@ -1,4 +1,4 @@ -include_directories(hdr) +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-switch -Wno-unused-but-set-variable -Wno-unused-variable -Wno-return-type -Wno-sign-compare -Wno-reorder -Wno-parantheses") add_library(srslte_asn1 SHARED liblte_common.cc liblte_rrc.cc diff --git a/srsue/test/mac/CMakeLists.txt b/srsue/test/mac/CMakeLists.txt index b1bf4e07f..e458b9362 100644 --- a/srsue/test/mac/CMakeLists.txt +++ b/srsue/test/mac/CMakeLists.txt @@ -16,7 +16,7 @@ # the LICENSE file in the top-level directory of this distribution # and at http://www.gnu.org/licenses/. # - +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-switch") add_executable(mac_test mac_test.cc) target_link_libraries(mac_test srsue_mac srsue_phy srslte_common srslte_phy srslte_radio srslte_asn1 ${SRSLTE_LIBRARIES} ${LIBLTE_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES})