2014-03-03 11:09:26 -08:00
|
|
|
#
|
2015-11-13 04:22:33 -08:00
|
|
|
# Copyright 2013-2015 Software Radio Systems Limited
|
2014-03-03 11:09:26 -08:00
|
|
|
#
|
2015-03-20 05:01:08 -07:00
|
|
|
# This file is part of the srsLTE library.
|
2014-03-03 11:09:26 -08:00
|
|
|
#
|
2015-03-20 05:01:08 -07:00
|
|
|
# srsLTE is free software: you can redistribute it and/or modify
|
2015-05-08 08:05:40 -07:00
|
|
|
# it under the terms of the GNU Affero General Public License as
|
2014-03-03 11:09:26 -08:00
|
|
|
# published by the Free Software Foundation, either version 3 of
|
|
|
|
# the License, or (at your option) any later version.
|
|
|
|
#
|
2015-03-20 05:01:08 -07:00
|
|
|
# srsLTE is distributed in the hope that it will be useful,
|
2014-03-03 11:09:26 -08:00
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2015-05-08 08:05:40 -07:00
|
|
|
# GNU Affero General Public License for more details.
|
2014-03-03 11:09:26 -08:00
|
|
|
#
|
2015-05-08 08:05:40 -07:00
|
|
|
# A copy of the GNU Affero General Public License can be found in
|
2014-03-03 11:09:26 -08:00
|
|
|
# the LICENSE file in the top-level directory of this distribution
|
|
|
|
# and at http://www.gnu.org/licenses/.
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
|
|
########################################################################
|
|
|
|
# Prevent in-tree builds
|
|
|
|
########################################################################
|
2014-01-28 03:41:17 -08:00
|
|
|
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
|
|
|
|
message(FATAL_ERROR "Prevented in-tree build. This is bad practice.")
|
|
|
|
endif(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
|
|
|
|
|
|
|
|
|
2014-03-03 11:09:26 -08:00
|
|
|
########################################################################
|
|
|
|
# Project setup
|
|
|
|
########################################################################
|
|
|
|
CMAKE_MINIMUM_REQUIRED (VERSION 2.6)
|
2015-03-20 05:01:08 -07:00
|
|
|
PROJECT (SRSLTE)
|
2016-09-27 02:12:49 -07:00
|
|
|
MESSAGE( STATUS "CMAKE_SYSTEM: " ${CMAKE_SYSTEM} )
|
|
|
|
MESSAGE( STATUS "CMAKE_SYSTEM_PROCESSOR: " ${CMAKE_SYSTEM_PROCESSOR} )
|
|
|
|
MESSAGE( STATUS "CMAKE_CXX_COMPILER: " ${CMAKE_CXX_COMPILER} )
|
2014-03-03 11:09:26 -08:00
|
|
|
|
2016-04-18 02:17:23 -07:00
|
|
|
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/modules")
|
|
|
|
include(SRSLTEVersion) #sets version information
|
|
|
|
include(SRSLTEPackage) #setup cpack
|
2014-03-03 11:09:26 -08:00
|
|
|
|
2014-03-08 03:46:19 -08:00
|
|
|
include(CTest)
|
|
|
|
set( CTEST_MEMORYCHECK_COMMAND valgrind )
|
2016-04-18 02:17:23 -07:00
|
|
|
configure_file(
|
2014-03-11 11:42:51 -07:00
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/CTestCustom.cmake.in"
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/CTestCustom.cmake"
|
|
|
|
IMMEDIATE @ONLY)
|
2014-03-08 03:46:19 -08:00
|
|
|
|
2015-03-11 03:10:29 -07:00
|
|
|
########################################################################
|
|
|
|
# Options
|
|
|
|
########################################################################
|
2017-01-18 16:06:28 -08:00
|
|
|
option(StaticMKL "StaticMKL" OFF)
|
|
|
|
option(DisableBladeRF "DisableBladeRF" OFF)
|
2015-03-11 03:10:29 -07:00
|
|
|
|
2014-03-03 11:09:26 -08:00
|
|
|
########################################################################
|
|
|
|
# Install Dirs
|
|
|
|
########################################################################
|
2016-01-06 07:54:46 -08:00
|
|
|
if (NOT CMAKE_INSTALL_LIBDIR)
|
|
|
|
include(GNUInstallDirs)
|
|
|
|
endif (NOT CMAKE_INSTALL_LIBDIR)
|
|
|
|
|
|
|
|
# Fall back to just "lib" if the item provided by GNUInstallDirs doesn't exist
|
|
|
|
if (NOT EXISTS "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
|
|
|
|
message(STATUS "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR} does not exist. Defaulting install location to ${CMAKE_INSTALL_PREFIX}/lib.")
|
|
|
|
set(CMAKE_INSTALL_LIBDIR lib)
|
|
|
|
endif()
|
|
|
|
|
2016-04-18 02:17:23 -07:00
|
|
|
set(RUNTIME_DIR bin)
|
|
|
|
set(LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR})
|
|
|
|
set(INCLUDE_DIR include)
|
|
|
|
set(DOC_DIR "share/doc/${CPACK_PACKAGE_NAME}")
|
|
|
|
set(DATA_DIR share/${CPACK_PACKAGE_NAME})
|
2014-03-03 11:09:26 -08:00
|
|
|
|
|
|
|
|
2016-04-18 02:17:23 -07:00
|
|
|
if(NOT CMAKE_BUILD_TYPE)
|
|
|
|
set(CMAKE_BUILD_TYPE Release)
|
|
|
|
message(STATUS "Build type not specified: defaulting to Release.")
|
|
|
|
endif(NOT CMAKE_BUILD_TYPE)
|
|
|
|
set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "")
|
2014-03-03 11:09:26 -08:00
|
|
|
|
|
|
|
########################################################################
|
|
|
|
# Compiler specific setup
|
|
|
|
########################################################################
|
2014-06-13 04:42:29 -07:00
|
|
|
macro(ADD_CXX_COMPILER_FLAG_IF_AVAILABLE flag have)
|
|
|
|
include(CheckCXXCompilerFlag)
|
2016-04-18 02:17:23 -07:00
|
|
|
check_cxx_compiler_flag(${flag} ${have})
|
2014-06-13 04:42:29 -07:00
|
|
|
if(${have})
|
2015-05-08 08:59:22 -07:00
|
|
|
add_definitions(${flag})
|
2014-06-13 04:42:29 -07:00
|
|
|
endif(${have})
|
|
|
|
endmacro(ADD_CXX_COMPILER_FLAG_IF_AVAILABLE)
|
|
|
|
|
2016-04-18 02:17:23 -07:00
|
|
|
if(CMAKE_COMPILER_IS_GNUCXX)
|
2014-06-13 04:42:29 -07:00
|
|
|
#Any additional flags for CXX
|
2016-04-18 02:17:23 -07:00
|
|
|
endif(CMAKE_COMPILER_IS_GNUCXX)
|
2014-03-03 11:09:26 -08:00
|
|
|
|
2015-10-16 02:05:13 -07:00
|
|
|
|
2016-04-18 02:17:23 -07:00
|
|
|
if(CMAKE_COMPILER_IS_GNUCC)
|
2015-10-18 03:34:30 -07:00
|
|
|
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")
|
2017-01-16 08:23:10 -08:00
|
|
|
|
2016-04-18 02:17:23 -07:00
|
|
|
if(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
|
2016-10-27 08:27:59 -07:00
|
|
|
find_package(SSE)
|
2017-03-08 02:53:55 -08:00
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 -DDEBUG_MODE")
|
2016-10-27 08:27:59 -07:00
|
|
|
if(HAVE_AVX)
|
2017-01-18 16:06:28 -08:00
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native -mfpmath=sse -mavx -DLV_HAVE_AVX -DLV_HAVE_SSE")
|
2016-10-27 08:27:59 -07:00
|
|
|
elseif(HAVE_SSE)
|
2017-01-18 16:06:28 -08:00
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native -mfpmath=sse -msse4.1 -DLV_HAVE_SSE")
|
2016-10-27 08:27:59 -07:00
|
|
|
endif(HAVE_AVX)
|
2016-04-18 02:17:23 -07:00
|
|
|
else(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
|
2017-01-18 16:06:28 -08:00
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3")
|
2016-04-18 02:17:23 -07:00
|
|
|
find_package(SSE)
|
2017-01-19 09:30:45 -08:00
|
|
|
if (HAVE_AVX2)
|
2017-01-19 10:28:13 -08:00
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native -mfpmath=sse -mavx2 -Ofast -funroll-loops -DLV_HAVE_AVX -DLV_HAVE_SSE")
|
2017-01-20 02:55:20 -08:00
|
|
|
else (HAVE_AVX2)
|
2017-01-19 09:30:45 -08:00
|
|
|
if(HAVE_AVX)
|
2017-01-19 10:28:13 -08:00
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native -mfpmath=sse -mavx -Ofast -funroll-loops -DLV_HAVE_AVX -DLV_HAVE_SSE")
|
2017-01-19 09:30:45 -08:00
|
|
|
elseif(HAVE_SSE)
|
2017-01-19 10:28:13 -08:00
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native -mfpmath=sse -msse4.1 -Ofast -funroll-loops -DLV_HAVE_SSE")
|
2017-01-19 09:30:45 -08:00
|
|
|
endif(HAVE_AVX)
|
|
|
|
endif (HAVE_AVX2)
|
|
|
|
|
2016-04-18 02:17:23 -07:00
|
|
|
endif(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
|
2015-10-18 03:34:30 -07:00
|
|
|
|
2017-02-15 03:47:45 -08:00
|
|
|
IF(${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm")
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfpu=neon -march=native -DIS_ARM -DHAVE_NEON")
|
|
|
|
message(STATUS "have ARM")
|
|
|
|
ELSE(${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm")
|
|
|
|
ENDIF(${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm")
|
|
|
|
|
|
|
|
set(CMAKE_REQUIRED_FLAGS ${CMAKE_C_FLAGS})
|
|
|
|
|
2016-04-18 02:17:23 -07:00
|
|
|
if(NOT WIN32)
|
2015-10-18 03:34:30 -07:00
|
|
|
ADD_CXX_COMPILER_FLAG_IF_AVAILABLE(-fvisibility=hidden HAVE_VISIBILITY_HIDDEN)
|
2016-04-18 02:17:23 -07:00
|
|
|
endif(NOT WIN32)
|
|
|
|
endif(CMAKE_COMPILER_IS_GNUCC)
|
|
|
|
|
|
|
|
if(MSVC)
|
|
|
|
include_directories(${PROJECT_SOURCE_DIR}/msvc) #missing headers
|
|
|
|
add_definitions(-D_WIN32_WINNT=0x0501) #minimum version required is windows xp
|
|
|
|
add_definitions(-DNOMINMAX) #disables stupidity and enables std::min and std::max
|
|
|
|
add_definitions( #stop all kinds of compatibility warnings
|
2014-03-03 11:09:26 -08:00
|
|
|
-D_SCL_SECURE_NO_WARNINGS
|
|
|
|
-D_CRT_SECURE_NO_WARNINGS
|
|
|
|
-D_CRT_SECURE_NO_DEPRECATE
|
|
|
|
-D_CRT_NONSTDC_NO_DEPRECATE
|
|
|
|
)
|
2016-04-18 02:17:23 -07:00
|
|
|
add_definitions(/MP) #build with multiple processors
|
|
|
|
endif(MSVC)
|
2014-03-03 11:09:26 -08:00
|
|
|
|
2016-04-18 02:17:23 -07:00
|
|
|
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
2014-03-03 11:09:26 -08:00
|
|
|
# The following is needed for weak linking to work under OS X
|
2016-04-18 02:17:23 -07:00
|
|
|
set(CMAKE_SHARED_LINKER_FLAGS "-undefined dynamic_lookup")
|
|
|
|
endif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
2014-03-03 11:09:26 -08:00
|
|
|
|
|
|
|
########################################################################
|
|
|
|
# Create uninstall targets
|
|
|
|
########################################################################
|
2016-04-18 02:17:23 -07:00
|
|
|
configure_file(
|
2014-03-03 11:09:26 -08:00
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
|
|
|
|
IMMEDIATE @ONLY)
|
|
|
|
|
2016-04-18 02:17:23 -07:00
|
|
|
add_custom_target(uninstall
|
2014-03-03 11:09:26 -08:00
|
|
|
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
|
|
|
|
|
|
|
|
########################################################################
|
|
|
|
# Macro to add -fPIC property to static libs
|
|
|
|
########################################################################
|
2016-04-18 02:17:23 -07:00
|
|
|
macro(SRSLTE_SET_PIC)
|
2016-09-27 02:12:49 -07:00
|
|
|
set_target_properties(${ARGV} PROPERTIES COMPILE_FLAGS -fPIC)
|
2016-04-18 02:17:23 -07:00
|
|
|
endmacro(SRSLTE_SET_PIC)
|
2014-03-03 11:09:26 -08:00
|
|
|
|
|
|
|
########################################################################
|
|
|
|
# Print summary
|
|
|
|
########################################################################
|
2016-04-18 02:17:23 -07:00
|
|
|
message(STATUS "Using install prefix: ${CMAKE_INSTALL_PREFIX}")
|
|
|
|
message(STATUS "Building for version: ${VERSION}")
|
2014-01-28 03:41:17 -08:00
|
|
|
|
2014-03-03 11:09:26 -08:00
|
|
|
########################################################################
|
|
|
|
# Add general includes and dependencies
|
|
|
|
########################################################################
|
2016-04-18 02:17:23 -07:00
|
|
|
include_directories(${PROJECT_BINARY_DIR}/srslte/include/)
|
|
|
|
include_directories(${PROJECT_SOURCE_DIR}/srslte/include/)
|
2014-01-28 03:41:17 -08:00
|
|
|
|
2014-03-03 11:09:26 -08:00
|
|
|
########################################################################
|
|
|
|
# Add the subdirectories
|
|
|
|
########################################################################
|
2016-04-18 02:17:23 -07:00
|
|
|
add_subdirectory(srslte)
|