From 7739ee4dc40394fdf7a31f2245c45050e3c5130f Mon Sep 17 00:00:00 2001 From: Johannes Demel Date: Sat, 10 Feb 2024 19:24:49 +0100 Subject: [PATCH 1/2] cmake: Add .cmake-format.py We want to use this to auto-format our cmake files. Signed-off-by: Johannes Demel --- .cmake-format.py | 98 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 .cmake-format.py diff --git a/.cmake-format.py b/.cmake-format.py new file mode 100644 index 00000000..df0f5f3d --- /dev/null +++ b/.cmake-format.py @@ -0,0 +1,98 @@ +# Copyright 2021 Marcus Müller, 2024 Johannes Demel +# SPDX-License-Identifier: LGPL-3.0-or-later + +class _clang_format_options: + def __init__(self, clangfile=None): + if not clangfile: + clangfile = ".clang-format" + self.lines = [] + with open(clangfile, encoding="utf-8") as opened: + for line in opened: + if line.strip().startswith("#"): + continue + self.lines.append(line.rstrip().split(":")) + + def __getitem__(self, string): + path = string.split(".") + value = None + for crumble in path: + for line in self.lines: + if line[0].strip() == crumble: + if len(line) > 1: + value = line[1].strip().rstrip() + break + return value + + +_clang_format = _clang_format_options() + +# ---------------------------------- +# Options affecting listfile parsing +# ---------------------------------- +with section("parse"): + additional_commands = { + 'gr_python_install': { + 'flags': [], + 'kwargs': { + "PROGRAMS": "*", + "FILES": "*", + "DESTINATION": "*" + } + }, + } + +with section("markup"): + first_comment_is_literal = True + enable_markup = False + +with section("format"): + # Disable formatting entirely, making cmake-format a no-op + disable = False + + # How wide to allow formatted cmake files + line_width = int(_clang_format["ColumnLimit"]) + + # How many spaces to tab for indent + tab_size = int(_clang_format["IndentWidth"]) + + # If true, lines are indented using tab characters (utf-8 0x09) instead of + # space characters (utf-8 0x20). In cases where the layout would + # require a fractional tab character, the behavior of the fractional + # indentation is governed by + use_tabchars = _clang_format["UseTab"] in ("ForIndentation", + "ForContinuationAndIndentation", + "Always") + + # If true, separate flow control names from their parentheses with a space + separate_ctrl_name_with_space = False + + # If true, separate function names from parentheses with a space + separate_fn_name_with_space = False + + # If a statement is wrapped to more than one line, than dangle the closing + # parenthesis on its own line. + dangle_parens = False + + # If the statement spelling length (including space and parenthesis) is + # smaller than this amount, then force reject nested layouts. + min_prefix_chars = tab_size + + # If the statement spelling length (including space and parenthesis) is larger + # than the tab width by more than this amount, then force reject un-nested + # layouts. + max_prefix_chars = 3 * tab_size + + # What style line endings to use in the output. + line_ending = "unix" + + # Format command names consistently as 'lower' or 'upper' case + command_case = "canonical" + + # Format keywords consistently as 'lower' or 'upper' case + keyword_case = "upper" + + +with section("lint"): + max_arguments = 6 + max_localvars = 20 + max_statements = 75 From e165c926623530a8de48747cc62b0ac100f9c52c Mon Sep 17 00:00:00 2001 From: Johannes Demel Date: Sat, 10 Feb 2024 19:49:06 +0100 Subject: [PATCH 2/2] cmake: Apply .cmake-format.py Run: ``` cmake-format -c .cmake-format.py -i $(git ls-files | grep CMakeLists.txt) $(git ls-files cmake/ | grep .cmake) ``` This applies the cmake formatting as defined in all files. In order to install `cmake-format`, you might want to run `pip install cmakelang` Or use another package manager of your choice. Signed-off-by: Johannes Demel --- CMakeLists.txt | 271 ++++++----- apps/CMakeLists.txt | 44 +- cmake/Modules/CMakeParseArgumentsCopy.cmake | 109 +++-- cmake/Modules/FindFILESYSTEM.cmake | 37 +- cmake/Modules/FindORC.cmake | 86 ++-- cmake/Modules/VolkAddTest.cmake | 333 ++++++------- cmake/Modules/VolkBuildTypes.cmake | 189 ++++---- cmake/Modules/VolkConfig.cmake.in | 36 +- cmake/Modules/VolkConfigVersion.cmake.in | 10 +- cmake/Modules/VolkPython.cmake | 90 ++-- cmake/Modules/VolkVersion.cmake | 29 +- cmake/Toolchains/aarch64-linux-gnu.cmake | 23 +- cmake/Toolchains/arm-linux-gnueabihf.cmake | 33 +- .../arm_cortex_a15_hardfp_native.cmake | 15 +- .../arm_cortex_a53_hardfp_native.cmake | 14 +- .../arm_cortex_a72_hardfp_native.cmake | 14 +- .../arm_cortex_a8_hardfp_native.cmake | 14 +- .../arm_cortex_a8_softfp_native.cmake | 14 +- .../arm_cortex_a9_hardfp_native.cmake | 14 +- cmake/Toolchains/intel-sde.cmake | 3 +- cmake/Toolchains/oe-sdk_cross.cmake | 31 +- cmake/cmake_uninstall.cmake.in | 61 +-- docs/CMakeLists.txt | 19 +- lib/CMakeLists.txt | 449 +++++++++--------- python/volk_modtool/CMakeLists.txt | 17 +- 25 files changed, 1049 insertions(+), 906 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b238e534..6d58464f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,7 +11,9 @@ # Project setup ######################################################################## cmake_minimum_required(VERSION 3.8) -set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "Choose build type: None Debug Release RelWithDebInfo MinSizeRel") +set(CMAKE_BUILD_TYPE + ${CMAKE_BUILD_TYPE} + CACHE STRING "Choose build type: None Debug Release RelWithDebInfo MinSizeRel") project(volk) enable_language(CXX) @@ -22,7 +24,6 @@ set(CMAKE_CXX_STANDARD 17) enable_testing() - ######################################################################## # Common compile flags ######################################################################## @@ -54,12 +55,14 @@ if(CMAKE_C_COMPILER_ID MATCHES "Clang|GNU") # are defined. Note the different data type of the first argument). By # default 'incompatible-pointer-types' is a warning only and 'pointer-sign' # is a warning enabled by '-Wall'. These warnings are only applicable to C. - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror=incompatible-pointer-types -Werror=pointer-sign") + set(CMAKE_C_FLAGS + "${CMAKE_C_FLAGS} -Werror=incompatible-pointer-types -Werror=pointer-sign") endif() set(CMAKE_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) #allows this to be a sub-project set(CMAKE_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) #allows this to be a sub-project -list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules) #location for custom "Modules" +list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules +)#location for custom "Modules" include(VolkBuildTypes) #select the release build type by default to get optimization flags @@ -67,8 +70,10 @@ if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "Release") message(STATUS "Build type not specified: defaulting to release.") endif() -VOLK_CHECK_BUILD_TYPE(${CMAKE_BUILD_TYPE}) -set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "") +volk_check_build_type(${CMAKE_BUILD_TYPE}) +set(CMAKE_BUILD_TYPE + ${CMAKE_BUILD_TYPE} + CACHE STRING "") message(STATUS "Build type set to ${CMAKE_BUILD_TYPE}.") ######################################################################## @@ -80,26 +85,29 @@ set(VERSION_INFO_MINOR_VERSION 1) set(VERSION_INFO_MAINT_VERSION 1) include(VolkVersion) #setup version info -math(EXPR VOLK_VERSION_DECIMAL - "${VERSION_INFO_MAJOR_VERSION} * 10000 +math(EXPR VOLK_VERSION_DECIMAL "${VERSION_INFO_MAJOR_VERSION} * 10000 + ${VERSION_INFO_MINOR_VERSION} * 100 + ${VERSION_INFO_MAINT_VERSION}") -configure_file( - ${CMAKE_SOURCE_DIR}/include/volk/volk_version.h.in - ${CMAKE_BINARY_DIR}/include/volk/volk_version.h -@ONLY) +configure_file(${CMAKE_SOURCE_DIR}/include/volk/volk_version.h.in + ${CMAKE_BINARY_DIR}/include/volk/volk_version.h @ONLY) ######################################################################## # Environment setup ######################################################################## -IF(NOT DEFINED CROSSCOMPILE_MULTILIB) - SET(CROSSCOMPILE_MULTILIB "") -ENDIF() -SET(CROSSCOMPILE_MULTILIB ${CROSSCOMPILE_MULTILIB} CACHE STRING "Define \"true\" if you have and want to use multiple C development libs installed for cross compile") +if(NOT DEFINED CROSSCOMPILE_MULTILIB) + set(CROSSCOMPILE_MULTILIB "") +endif() +set(CROSSCOMPILE_MULTILIB + ${CROSSCOMPILE_MULTILIB} + CACHE + STRING + "Define \"true\" if you have and want to use multiple C development libs installed for cross compile" +) if(MSVC) - add_definitions(-D_USE_MATH_DEFINES) #enables math constants on all supported versions of MSVC + add_definitions(-D_USE_MATH_DEFINES + )#enables math constants on all supported versions of MSVC add_compile_options(/W1) #reduce warnings add_compile_options(/wo4309) add_compile_options(/wd4752) @@ -113,41 +121,48 @@ endif(MSVC) # cpu_features - sensible defaults, user settable option if(CMAKE_SYSTEM_PROCESSOR MATCHES - "(^mips)|(^arm)|(^aarch64)|(x86_64)|(AMD64|amd64)|(^i.86$)|(^powerpc)|(^ppc)|(^riscv)") - option(VOLK_CPU_FEATURES "Volk uses cpu_features" ON) + "(^mips)|(^arm)|(^aarch64)|(x86_64)|(AMD64|amd64)|(^i.86$)|(^powerpc)|(^ppc)|(^riscv)") + option(VOLK_CPU_FEATURES "Volk uses cpu_features" ON) else() - option(VOLK_CPU_FEATURES "Volk uses cpu_features" OFF) + option(VOLK_CPU_FEATURES "Volk uses cpu_features" OFF) endif() -if (VOLK_CPU_FEATURES) - find_package(CpuFeatures QUIET) - if(NOT CpuFeatures_FOUND) - message(STATUS "cpu_features package not found. Requiring cpu_features submodule ...") - if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/cpu_features/CMakeLists.txt" ) - message(FATAL_ERROR "cpu_features/CMakeLists.txt not found. Did you forget to git clone recursively?\nFix with: git submodule update --init") +if(VOLK_CPU_FEATURES) + find_package(CpuFeatures QUIET) + if(NOT CpuFeatures_FOUND) + message( + STATUS "cpu_features package not found. Requiring cpu_features submodule ...") + if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/cpu_features/CMakeLists.txt") + message( + FATAL_ERROR + "cpu_features/CMakeLists.txt not found. Did you forget to git clone recursively?\nFix with: git submodule update --init" + ) + endif() + message(STATUS "Building Volk with cpu_features") + set(BUILD_TESTING + OFF + CACHE BOOL "Build cpu_features without tests." FORCE) + set(BUILD_PIC + ON + CACHE BOOL "Build cpu_features with Position Independent Code (PIC)." FORCE) + set(CMAKE_POSITION_INDEPENDENT_CODE + ON + CACHE BOOL "Build cpu_features with Position Independent Code (PIC)." FORCE) + set(BUILD_SHARED_LIBS_SAVED "${BUILD_SHARED_LIBS}") + set(BUILD_SHARED_LIBS OFF) + set(ENABLE_INSTALL OFF) + add_subdirectory(cpu_features) + set(BUILD_SHARED_LIBS "${BUILD_SHARED_LIBS_SAVED}") endif() - message(STATUS "Building Volk with cpu_features") - set(BUILD_TESTING OFF CACHE BOOL "Build cpu_features without tests." FORCE) - set(BUILD_PIC ON CACHE BOOL - "Build cpu_features with Position Independent Code (PIC)." - FORCE) - set(CMAKE_POSITION_INDEPENDENT_CODE ON CACHE BOOL - "Build cpu_features with Position Independent Code (PIC)." - FORCE) - set(BUILD_SHARED_LIBS_SAVED "${BUILD_SHARED_LIBS}") - set(BUILD_SHARED_LIBS OFF) - set(ENABLE_INSTALL OFF) - add_subdirectory(cpu_features) - set(BUILD_SHARED_LIBS "${BUILD_SHARED_LIBS_SAVED}") - endif() else() - message(STATUS "Building Volk without cpu_features") + message(STATUS "Building Volk without cpu_features") endif() # Python include(VolkPython) #sets PYTHON_EXECUTABLE and PYTHON_DASH_B -VOLK_PYTHON_CHECK_MODULE("python >= 3.4" sys "sys.version_info >= (3, 4)" PYTHON_MIN_VER_FOUND) -VOLK_PYTHON_CHECK_MODULE("mako >= 0.4.2" mako "mako.__version__ >= '0.4.2'" MAKO_FOUND) +volk_python_check_module("python >= 3.4" sys "sys.version_info >= (3, 4)" + PYTHON_MIN_VER_FOUND) +volk_python_check_module("mako >= 0.4.2" mako "mako.__version__ >= '0.4.2'" MAKO_FOUND) if(NOT PYTHON_MIN_VER_FOUND) message(FATAL_ERROR "Python 3.4 or greater required to build VOLK") @@ -159,12 +174,14 @@ if(NOT MAKO_FOUND) endif() # Check if we have std::filesystem -find_package(FILESYSTEM COMPONENTS Final Experimental REQUIRED) +find_package( + FILESYSTEM + COMPONENTS Final Experimental + REQUIRED) set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_CXX_STANDARD_REQUIRED ON) - ######################################################################## # check for aligned_alloc, since some compilers lack this C11 feature. # For Apple-clang use `posix_memalign` @@ -172,10 +189,10 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) ######################################################################## include(CheckSymbolExists) if(NOT (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")) - CHECK_SYMBOL_EXISTS(aligned_alloc stdlib.h USE_ALIGNED_ALLOC) + check_symbol_exists(aligned_alloc stdlib.h USE_ALIGNED_ALLOC) endif() if(NOT USE_ALIGNED_ALLOC) - CHECK_SYMBOL_EXISTS(posix_memalign stdlib.h HAVE_POSIX_MEMALIGN) + check_symbol_exists(posix_memalign stdlib.h HAVE_POSIX_MEMALIGN) endif() ######################################################################## @@ -183,9 +200,9 @@ endif() ######################################################################## option(ENABLE_ORC "Enable Orc" True) if(ENABLE_ORC) - find_package(ORC) + find_package(ORC) else(ENABLE_ORC) - message(STATUS "Disabling use of ORC") + message(STATUS "Disabling use of ORC") endif(ENABLE_ORC) ######################################################################## @@ -207,52 +224,49 @@ set(exec_prefix "\${prefix}") set(libdir "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}") set(includedir "\${prefix}/include") -configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/tmpl/volk.pc.in - ${CMAKE_CURRENT_BINARY_DIR}/volk.pc -@ONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tmpl/volk.pc.in + ${CMAKE_CURRENT_BINARY_DIR}/volk.pc @ONLY) install( FILES ${CMAKE_CURRENT_BINARY_DIR}/volk.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig - COMPONENT "volk_devel" -) + COMPONENT "volk_devel") ######################################################################## # Install all headers in the include directories ######################################################################## -set(VOLK_RUNTIME_DIR bin) -set(VOLK_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}) -set(VOLK_INCLUDE_DIR include) +set(VOLK_RUNTIME_DIR bin) +set(VOLK_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}) +set(VOLK_INCLUDE_DIR include) install( DIRECTORY ${CMAKE_SOURCE_DIR}/kernels/volk - DESTINATION include COMPONENT "volk_devel" - FILES_MATCHING PATTERN "*.h" -) + DESTINATION include + COMPONENT "volk_devel" + FILES_MATCHING + PATTERN "*.h") -install(FILES - ${CMAKE_SOURCE_DIR}/include/volk/volk_prefs.h - ${CMAKE_SOURCE_DIR}/include/volk/volk_alloc.hh - ${CMAKE_SOURCE_DIR}/include/volk/volk_complex.h - ${CMAKE_SOURCE_DIR}/include/volk/volk_common.h - ${CMAKE_SOURCE_DIR}/include/volk/saturation_arithmetic.h - ${CMAKE_SOURCE_DIR}/include/volk/volk_avx_intrinsics.h - ${CMAKE_SOURCE_DIR}/include/volk/volk_avx2_intrinsics.h - ${CMAKE_SOURCE_DIR}/include/volk/volk_avx2_fma_intrinsics.h - ${CMAKE_SOURCE_DIR}/include/volk/volk_sse_intrinsics.h - ${CMAKE_SOURCE_DIR}/include/volk/volk_sse3_intrinsics.h - ${CMAKE_SOURCE_DIR}/include/volk/volk_neon_intrinsics.h - ${CMAKE_BINARY_DIR}/include/volk/volk.h - ${CMAKE_BINARY_DIR}/include/volk/volk_cpu.h - ${CMAKE_BINARY_DIR}/include/volk/volk_config_fixed.h - ${CMAKE_BINARY_DIR}/include/volk/volk_typedefs.h - ${CMAKE_SOURCE_DIR}/include/volk/volk_malloc.h - ${CMAKE_BINARY_DIR}/include/volk/volk_version.h - ${CMAKE_SOURCE_DIR}/include/volk/constants.h +install( + FILES ${CMAKE_SOURCE_DIR}/include/volk/volk_prefs.h + ${CMAKE_SOURCE_DIR}/include/volk/volk_alloc.hh + ${CMAKE_SOURCE_DIR}/include/volk/volk_complex.h + ${CMAKE_SOURCE_DIR}/include/volk/volk_common.h + ${CMAKE_SOURCE_DIR}/include/volk/saturation_arithmetic.h + ${CMAKE_SOURCE_DIR}/include/volk/volk_avx_intrinsics.h + ${CMAKE_SOURCE_DIR}/include/volk/volk_avx2_intrinsics.h + ${CMAKE_SOURCE_DIR}/include/volk/volk_avx2_fma_intrinsics.h + ${CMAKE_SOURCE_DIR}/include/volk/volk_sse_intrinsics.h + ${CMAKE_SOURCE_DIR}/include/volk/volk_sse3_intrinsics.h + ${CMAKE_SOURCE_DIR}/include/volk/volk_neon_intrinsics.h + ${CMAKE_BINARY_DIR}/include/volk/volk.h + ${CMAKE_BINARY_DIR}/include/volk/volk_cpu.h + ${CMAKE_BINARY_DIR}/include/volk/volk_config_fixed.h + ${CMAKE_BINARY_DIR}/include/volk/volk_typedefs.h + ${CMAKE_SOURCE_DIR}/include/volk/volk_malloc.h + ${CMAKE_BINARY_DIR}/include/volk/volk_version.h + ${CMAKE_SOURCE_DIR}/include/volk/constants.h DESTINATION include/volk - COMPONENT "volk_devel" -) + COMPONENT "volk_devel") ######################################################################## # On Apple only, set install name and use rpath correctly, if not already set @@ -260,52 +274,44 @@ install(FILES if(APPLE) if(NOT CMAKE_INSTALL_NAME_DIR) set(CMAKE_INSTALL_NAME_DIR - ${CMAKE_INSTALL_PREFIX}/${VOLK_LIBRARY_DIR} CACHE - PATH "Library Install Name Destination Directory" FORCE) + ${CMAKE_INSTALL_PREFIX}/${VOLK_LIBRARY_DIR} + CACHE PATH "Library Install Name Destination Directory" FORCE) endif(NOT CMAKE_INSTALL_NAME_DIR) if(NOT CMAKE_INSTALL_RPATH) set(CMAKE_INSTALL_RPATH - ${CMAKE_INSTALL_PREFIX}/${VOLK_LIBRARY_DIR} CACHE - PATH "Library Install RPath" FORCE) + ${CMAKE_INSTALL_PREFIX}/${VOLK_LIBRARY_DIR} + CACHE PATH "Library Install RPath" FORCE) endif(NOT CMAKE_INSTALL_RPATH) if(NOT CMAKE_BUILD_WITH_INSTALL_RPATH) - set(CMAKE_BUILD_WITH_INSTALL_RPATH ON CACHE - BOOL "Do Build Using Library Install RPath" FORCE) + set(CMAKE_BUILD_WITH_INSTALL_RPATH + ON + CACHE BOOL "Do Build Using Library Install RPath" FORCE) endif(NOT CMAKE_BUILD_WITH_INSTALL_RPATH) endif(APPLE) ######################################################################## # Create uninstall target ######################################################################## -configure_file( - ${CMAKE_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in - ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake -@ONLY) +configure_file(${CMAKE_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake @ONLY) # Only add the target if there isn't one defined already if(NOT TARGET uninstall) - add_custom_target(uninstall - ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake - ) + add_custom_target(uninstall ${CMAKE_COMMAND} -P + ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake) endif() - ######################################################################## # Install our Cmake modules into $prefix/lib/cmake/volk # See "Package Configuration Files" on page: # http://www.cmake.org/Wiki/CMake/Tutorials/Packaging ######################################################################## -configure_file( - ${CMAKE_SOURCE_DIR}/cmake/Modules/VolkConfig.cmake.in - ${CMAKE_BINARY_DIR}/cmake/Modules/VolkConfig.cmake -@ONLY) - -configure_file( - ${CMAKE_SOURCE_DIR}/cmake/Modules/VolkConfigVersion.cmake.in - ${CMAKE_BINARY_DIR}/cmake/Modules/VolkConfigVersion.cmake -@ONLY) +configure_file(${CMAKE_SOURCE_DIR}/cmake/Modules/VolkConfig.cmake.in + ${CMAKE_BINARY_DIR}/cmake/Modules/VolkConfig.cmake @ONLY) +configure_file(${CMAKE_SOURCE_DIR}/cmake/Modules/VolkConfigVersion.cmake.in + ${CMAKE_BINARY_DIR}/cmake/Modules/VolkConfigVersion.cmake @ONLY) ######################################################################## # Install cmake search routine for external use @@ -316,48 +322,51 @@ if(NOT CMAKE_MODULES_DIR) endif(NOT CMAKE_MODULES_DIR) install( - FILES - ${CMAKE_CURRENT_BINARY_DIR}/cmake/Modules/VolkConfig.cmake - ${CMAKE_CURRENT_BINARY_DIR}/cmake/Modules/VolkConfigVersion.cmake + FILES ${CMAKE_CURRENT_BINARY_DIR}/cmake/Modules/VolkConfig.cmake + ${CMAKE_CURRENT_BINARY_DIR}/cmake/Modules/VolkConfigVersion.cmake DESTINATION ${CMAKE_MODULES_DIR}/volk - COMPONENT "volk_devel" ) + COMPONENT "volk_devel") -install(EXPORT VOLK-export FILE VolkTargets.cmake - NAMESPACE Volk:: DESTINATION ${CMAKE_MODULES_DIR}/volk ) +install( + EXPORT VOLK-export + FILE VolkTargets.cmake + NAMESPACE Volk:: + DESTINATION ${CMAKE_MODULES_DIR}/volk) ######################################################################## # Option to enable QA testing, on by default ######################################################################## -OPTION(ENABLE_TESTING "Enable QA testing" ON) +option(ENABLE_TESTING "Enable QA testing" ON) if(ENABLE_TESTING) - message(STATUS "QA Testing is enabled.") + message(STATUS "QA Testing is enabled.") else() - message(STATUS "QA Testing is disabled.") + message(STATUS "QA Testing is disabled.") endif() message(STATUS " Modify using: -DENABLE_TESTING=ON/OFF") ######################################################################## # Option to enable post-build profiling using volk_profile, off by default ######################################################################## -OPTION(ENABLE_PROFILING "Launch system profiler after build" OFF) +option(ENABLE_PROFILING "Launch system profiler after build" OFF) if(ENABLE_PROFILING) - if(DEFINED VOLK_CONFIGPATH) - get_filename_component(VOLK_CONFIGPATH ${VOLK_CONFIGPATH} ABSOLUTE) - set(VOLK_CONFIGPATH "${VOLK_CONFIGPATH}/volk") - message(STATUS "System profiling is enabled, using path: ${VOLK_CONFIGPATH}") - elseif(DEFINED ENV{VOLK_CONFIGPATH}) - set(VOLK_CONFIGPATH "$ENV{VOLK_CONFIGPATH}/volk") - message(STATUS "System profiling is enabled, using env path: $ENV{VOLK_CONFIGPATH}") - else() - message(STATUS "System profiling is enabled with default paths.") - if(DEFINED ENV{HOME}) - set(VOLK_CONFIGPATH "$ENV{HOME}/.volk") - elseif(DEFINED ENV{APPDATA}) - set(VOLK_CONFIGPATH "$ENV{APPDATA}/.volk") + if(DEFINED VOLK_CONFIGPATH) + get_filename_component(VOLK_CONFIGPATH ${VOLK_CONFIGPATH} ABSOLUTE) + set(VOLK_CONFIGPATH "${VOLK_CONFIGPATH}/volk") + message(STATUS "System profiling is enabled, using path: ${VOLK_CONFIGPATH}") + elseif(DEFINED ENV{VOLK_CONFIGPATH}) + set(VOLK_CONFIGPATH "$ENV{VOLK_CONFIGPATH}/volk") + message( + STATUS "System profiling is enabled, using env path: $ENV{VOLK_CONFIGPATH}") + else() + message(STATUS "System profiling is enabled with default paths.") + if(DEFINED ENV{HOME}) + set(VOLK_CONFIGPATH "$ENV{HOME}/.volk") + elseif(DEFINED ENV{APPDATA}) + set(VOLK_CONFIGPATH "$ENV{APPDATA}/.volk") + endif() endif() - endif() else() - message(STATUS "System profiling is disabled.") + message(STATUS "System profiling is disabled.") endif() message(STATUS " Modify using: -DENABLE_PROFILING=ON/OFF") @@ -372,7 +381,7 @@ add_subdirectory(lib) add_subdirectory(apps) option(ENABLE_MODTOOL "Enable volk_modtool python utility" True) if(ENABLE_MODTOOL) - add_subdirectory(python/volk_modtool) + add_subdirectory(python/volk_modtool) endif() ######################################################################## diff --git a/apps/CMakeLists.txt b/apps/CMakeLists.txt index db6ab50f..98d002af 100644 --- a/apps/CMakeLists.txt +++ b/apps/CMakeLists.txt @@ -17,26 +17,24 @@ if(HAVE_POSIX_MEMALIGN) endif(HAVE_POSIX_MEMALIGN) # MAKE volk_profile -add_executable(volk_profile - ${CMAKE_CURRENT_SOURCE_DIR}/volk_profile.cc - ${PROJECT_SOURCE_DIR}/lib/qa_utils.cc - ${CMAKE_CURRENT_SOURCE_DIR}/volk_option_helpers.cc -) +add_executable( + volk_profile + ${CMAKE_CURRENT_SOURCE_DIR}/volk_profile.cc ${PROJECT_SOURCE_DIR}/lib/qa_utils.cc + ${CMAKE_CURRENT_SOURCE_DIR}/volk_option_helpers.cc) if(MSVC) - target_include_directories(volk_profile - PRIVATE $ - ) + target_include_directories( + volk_profile PRIVATE $) endif(MSVC) -target_include_directories(volk_profile +target_include_directories( + volk_profile PRIVATE $ PRIVATE $ PRIVATE $ PRIVATE $ PRIVATE ${CMAKE_CURRENT_BINARY_DIR} - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} -) + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) add_definitions(-DHAS_STD_FILESYSTEM=1) if(${find_experimental}) @@ -54,12 +52,11 @@ endif() install( TARGETS volk_profile DESTINATION bin - COMPONENT "volk" -) + COMPONENT "volk") # MAKE volk-config-info -add_executable(volk-config-info volk-config-info.cc ${CMAKE_CURRENT_SOURCE_DIR}/volk_option_helpers.cc - ) +add_executable(volk-config-info volk-config-info.cc + ${CMAKE_CURRENT_SOURCE_DIR}/volk_option_helpers.cc) if(ENABLE_STATIC_LIBS) target_link_libraries(volk-config-info volk_static) @@ -71,21 +68,20 @@ endif() install( TARGETS volk-config-info DESTINATION bin - COMPONENT "volk" -) + COMPONENT "volk") # Launch volk_profile if requested to do so if(ENABLE_PROFILING) - if(DEFINED VOLK_CONFIGPATH) - set( VOLK_CONFIG_ARG "-p${VOLK_CONFIGPATH}" ) - set( VOLK_CONFIG "${VOLK_CONFIGPATH}/volk_config" ) - endif() + if(DEFINED VOLK_CONFIGPATH) + set(VOLK_CONFIG_ARG "-p${VOLK_CONFIGPATH}") + set(VOLK_CONFIG "${VOLK_CONFIGPATH}/volk_config") + endif() - add_custom_command(OUTPUT ${VOLK_CONFIG} + add_custom_command( + OUTPUT ${VOLK_CONFIG} COMMAND volk_profile "${VOLK_CONFIG_ARG}" DEPENDS volk_profile - COMMENT "Launching profiler, this may take a few minutes..." - ) + COMMENT "Launching profiler, this may take a few minutes...") add_custom_target(volk-profile-run ALL DEPENDS ${VOLK_CONFIG}) endif() diff --git a/cmake/Modules/CMakeParseArgumentsCopy.cmake b/cmake/Modules/CMakeParseArgumentsCopy.cmake index a8b8b314..9d3afedc 100644 --- a/cmake/Modules/CMakeParseArgumentsCopy.cmake +++ b/cmake/Modules/CMakeParseArgumentsCopy.cmake @@ -80,66 +80,77 @@ # (To distribute this file outside of CMake, substitute the full # License text for the above reference.) - if(__CMAKE_PARSE_ARGUMENTS_INCLUDED) - return() + return() endif() set(__CMAKE_PARSE_ARGUMENTS_INCLUDED TRUE) - function(CMAKE_PARSE_ARGUMENTS prefix _optionNames _singleArgNames _multiArgNames) - # first set all result variables to empty/FALSE - foreach(arg_name ${_singleArgNames} ${_multiArgNames}) - set(${prefix}_${arg_name}) - endforeach(arg_name) + # first set all result variables to empty/FALSE + foreach(arg_name ${_singleArgNames} ${_multiArgNames}) + set(${prefix}_${arg_name}) + endforeach(arg_name) - foreach(option ${_optionNames}) - set(${prefix}_${option} FALSE) - endforeach(option) + foreach(option ${_optionNames}) + set(${prefix}_${option} FALSE) + endforeach(option) - set(${prefix}_UNPARSED_ARGUMENTS) + set(${prefix}_UNPARSED_ARGUMENTS) - set(insideValues FALSE) - set(currentArgName) + set(insideValues FALSE) + set(currentArgName) - # now iterate over all arguments and fill the result variables - foreach(currentArg ${ARGN}) - list(FIND _optionNames "${currentArg}" optionIndex) # ... then this marks the end of the arguments belonging to this keyword - list(FIND _singleArgNames "${currentArg}" singleArgIndex) # ... then this marks the end of the arguments belonging to this keyword - list(FIND _multiArgNames "${currentArg}" multiArgIndex) # ... then this marks the end of the arguments belonging to this keyword + # now iterate over all arguments and fill the result variables + foreach(currentArg ${ARGN}) + list(FIND _optionNames "${currentArg}" optionIndex + )# ... then this marks the end of the arguments belonging to this keyword + list(FIND _singleArgNames "${currentArg}" singleArgIndex + )# ... then this marks the end of the arguments belonging to this keyword + list(FIND _multiArgNames "${currentArg}" multiArgIndex + )# ... then this marks the end of the arguments belonging to this keyword - if(${optionIndex} EQUAL -1 AND ${singleArgIndex} EQUAL -1 AND ${multiArgIndex} EQUAL -1) - if(insideValues) - if("${insideValues}" STREQUAL "SINGLE") - set(${prefix}_${currentArgName} ${currentArg}) - set(insideValues FALSE) - elseif("${insideValues}" STREQUAL "MULTI") - list(APPEND ${prefix}_${currentArgName} ${currentArg}) + if(${optionIndex} EQUAL -1 + AND ${singleArgIndex} EQUAL -1 + AND ${multiArgIndex} EQUAL -1) + if(insideValues) + if("${insideValues}" STREQUAL "SINGLE") + set(${prefix}_${currentArgName} ${currentArg}) + set(insideValues FALSE) + elseif("${insideValues}" STREQUAL "MULTI") + list(APPEND ${prefix}_${currentArgName} ${currentArg}) + endif() + else(insideValues) + list(APPEND ${prefix}_UNPARSED_ARGUMENTS ${currentArg}) + endif(insideValues) + else() + if(NOT ${optionIndex} EQUAL -1) + set(${prefix}_${currentArg} TRUE) + set(insideValues FALSE) + elseif(NOT ${singleArgIndex} EQUAL -1) + set(currentArgName ${currentArg}) + set(${prefix}_${currentArgName}) + set(insideValues "SINGLE") + elseif(NOT ${multiArgIndex} EQUAL -1) + set(currentArgName ${currentArg}) + set(${prefix}_${currentArgName}) + set(insideValues "MULTI") + endif() endif() - else(insideValues) - list(APPEND ${prefix}_UNPARSED_ARGUMENTS ${currentArg}) - endif(insideValues) - else() - if(NOT ${optionIndex} EQUAL -1) - set(${prefix}_${currentArg} TRUE) - set(insideValues FALSE) - elseif(NOT ${singleArgIndex} EQUAL -1) - set(currentArgName ${currentArg}) - set(${prefix}_${currentArgName}) - set(insideValues "SINGLE") - elseif(NOT ${multiArgIndex} EQUAL -1) - set(currentArgName ${currentArg}) - set(${prefix}_${currentArgName}) - set(insideValues "MULTI") - endif() - endif() - endforeach(currentArg) + endforeach(currentArg) - # propagate the result variables to the caller: - foreach(arg_name ${_singleArgNames} ${_multiArgNames} ${_optionNames}) - set(${prefix}_${arg_name} ${${prefix}_${arg_name}} PARENT_SCOPE) - endforeach(arg_name) - set(${prefix}_UNPARSED_ARGUMENTS ${${prefix}_UNPARSED_ARGUMENTS} PARENT_SCOPE) + # propagate the result variables to the caller: + foreach(arg_name ${_singleArgNames} ${_multiArgNames} ${_optionNames}) + set(${prefix}_${arg_name} + ${${prefix}_${arg_name}} + PARENT_SCOPE) + endforeach(arg_name) + set(${prefix}_UNPARSED_ARGUMENTS + ${${prefix}_UNPARSED_ARGUMENTS} + PARENT_SCOPE) -endfunction(CMAKE_PARSE_ARGUMENTS _options _singleArgs _multiArgs) +endfunction( + CMAKE_PARSE_ARGUMENTS + _options + _singleArgs + _multiArgs) diff --git a/cmake/Modules/FindFILESYSTEM.cmake b/cmake/Modules/FindFILESYSTEM.cmake index 6b92a82a..874f6bc2 100644 --- a/cmake/Modules/FindFILESYSTEM.cmake +++ b/cmake/Modules/FindFILESYSTEM.cmake @@ -104,7 +104,6 @@ Using `find_package(FILESYSTEM)` with no component arguments: #]=======================================================================] - if(TARGET std::filesystem) # This module has already been processed. Don't do it again. return() @@ -121,16 +120,19 @@ set(CMAKE_REQUIRED_QUIET ${FILESYSTEM_FIND_QUIETLY}) # All of our tests require C++17 or later set(OLD_CMAKE_CXX_STANDARD ${CMAKE_CXX_STANDARD}) set(CMAKE_CXX_STANDARD 17) -if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "8.0.0")) +if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER + "8.0.0")) if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "8.99") set(UNDEFINED_BEHAVIOR_WITHOUT_LINKING TRUE) endif() set(CMAKE_REQUIRED_FLAGS "-std=c++17") endif() -if((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") AND NOT (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "8.99")) +if((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") AND NOT (CMAKE_CXX_COMPILER_VERSION + VERSION_LESS "8.99")) set(CMAKE_REQUIRED_FLAGS "-std=c++17") endif() -if((CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") AND NOT (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "11")) +if((CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") AND NOT (CMAKE_CXX_COMPILER_VERSION + VERSION_LESS "11")) set(CMAKE_REQUIRED_FLAGS "-std=c++17") endif() if(MSVC AND NOT (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "18")) @@ -173,7 +175,8 @@ else() endif() if(find_experimental) - check_include_file_cxx("experimental/filesystem" _CXX_FILESYSTEM_HAVE_EXPERIMENTAL_HEADER) + check_include_file_cxx("experimental/filesystem" + _CXX_FILESYSTEM_HAVE_EXPERIMENTAL_HEADER) mark_as_advanced(_CXX_FILESYSTEM_HAVE_EXPERIMENTAL_HEADER) else() set(_CXX_FILESYSTEM_HAVE_EXPERIMENTAL_HEADER FALSE) @@ -191,22 +194,32 @@ else() set(_have_fs FALSE) endif() -set(CXX_FILESYSTEM_HAVE_FS ${_have_fs} CACHE BOOL "TRUE if we have the C++ filesystem headers") -set(CXX_FILESYSTEM_HEADER ${_fs_header} CACHE STRING "The header that should be included to obtain the filesystem APIs") -set(CXX_FILESYSTEM_NAMESPACE ${_fs_namespace} CACHE STRING "The C++ namespace that contains the filesystem APIs") +set(CXX_FILESYSTEM_HAVE_FS + ${_have_fs} + CACHE BOOL "TRUE if we have the C++ filesystem headers") +set(CXX_FILESYSTEM_HEADER + ${_fs_header} + CACHE STRING "The header that should be included to obtain the filesystem APIs") +set(CXX_FILESYSTEM_NAMESPACE + ${_fs_namespace} + CACHE STRING "The C++ namespace that contains the filesystem APIs") set(_found FALSE) if(CXX_FILESYSTEM_HAVE_FS) # We have some filesystem library available. Do link checks - string(CONFIGURE [[ + string( + CONFIGURE + [[ #include <@CXX_FILESYSTEM_HEADER@> int main() { auto cwd = @CXX_FILESYSTEM_NAMESPACE@::current_path(); return static_cast(cwd.string().size()); } - ]] code @ONLY) + ]] + code + @ONLY) # Try to compile a simple filesystem program without any linker flags if(NOT UNDEFINED_BEHAVIOR_WITHOUT_LINKING) @@ -254,7 +267,9 @@ endif() cmake_pop_check_state() -set(FILESYSTEM_FOUND ${_found} CACHE BOOL "TRUE if we can compile and link a program using std::filesystem" FORCE) +set(FILESYSTEM_FOUND + ${_found} + CACHE BOOL "TRUE if we can compile and link a program using std::filesystem" FORCE) if(FILESYSTEM_FIND_REQUIRED AND NOT FILESYSTEM_FOUND) message(FATAL_ERROR "Cannot compile a simple program using std::filesystem") diff --git a/cmake/Modules/FindORC.cmake b/cmake/Modules/FindORC.cmake index 57fef384..7cd2a056 100644 --- a/cmake/Modules/FindORC.cmake +++ b/cmake/Modules/FindORC.cmake @@ -5,45 +5,51 @@ # SPDX-License-Identifier: LGPL-3.0-or-later # -FIND_PACKAGE(PkgConfig) -PKG_CHECK_MODULES(PC_ORC "orc-0.4 > 0.4.11") - -INCLUDE(GNUInstallDirs) - - -FIND_PROGRAM(ORCC_EXECUTABLE orcc - HINTS ${PC_ORC_TOOLSDIR} - PATHS ${ORC_ROOT}/bin ${CMAKE_INSTALL_PREFIX}/bin) - -FIND_PATH(ORC_INCLUDE_DIR NAMES orc/orc.h - HINTS ${PC_ORC_INCLUDEDIR} - PATHS ${ORC_ROOT}/include ${CMAKE_INSTALL_PREFIX}/include - PATH_SUFFIXES orc-0.4) - - -FIND_PATH(ORC_LIBRARY_DIR NAMES ${CMAKE_SHARED_LIBRARY_PREFIX}orc-0.4${CMAKE_SHARED_LIBRARY_SUFFIX} - HINTS ${PC_ORC_LIBDIR} - PATHS ${ORC_ROOT}/${CMAKE_INSTALL_LIBDIR} ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}) - -FIND_LIBRARY(ORC_LIB orc-0.4 - HINTS ${PC_ORC_LIBRARY_DIRS} - PATHS ${ORC_ROOT}/${CMAKE_INSTALL_LIBDIR} ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}) - -FIND_LIBRARY(ORC_LIBRARY_STATIC liborc-0.4.a - HINTS ${PC_ORC_LIBRARY_DIRS} - PATHS ${ORC_ROOT}/${CMAKE_INSTALL_LIBDIR} ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}) - -LIST(APPEND ORC_LIBRARY - ${ORC_LIB} -) - - -SET(ORC_INCLUDE_DIRS ${ORC_INCLUDE_DIR}) -SET(ORC_LIBRARIES ${ORC_LIBRARY}) -SET(ORC_LIBRARY_DIRS ${ORC_LIBRARY_DIR}) -SET(ORC_LIBRARIES_STATIC ${ORC_LIBRARY_STATIC}) - -INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(ORC "orc files" ORC_LIBRARY ORC_INCLUDE_DIR ORCC_EXECUTABLE) +find_package(PkgConfig) +pkg_check_modules(PC_ORC "orc-0.4 > 0.4.11") + +include(GNUInstallDirs) + +find_program( + ORCC_EXECUTABLE orcc + HINTS ${PC_ORC_TOOLSDIR} + PATHS ${ORC_ROOT}/bin ${CMAKE_INSTALL_PREFIX}/bin) + +find_path( + ORC_INCLUDE_DIR + NAMES orc/orc.h + HINTS ${PC_ORC_INCLUDEDIR} + PATHS ${ORC_ROOT}/include ${CMAKE_INSTALL_PREFIX}/include + PATH_SUFFIXES orc-0.4) + +find_path( + ORC_LIBRARY_DIR + NAMES ${CMAKE_SHARED_LIBRARY_PREFIX}orc-0.4${CMAKE_SHARED_LIBRARY_SUFFIX} + HINTS ${PC_ORC_LIBDIR} + PATHS ${ORC_ROOT}/${CMAKE_INSTALL_LIBDIR} + ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}) + +find_library( + ORC_LIB orc-0.4 + HINTS ${PC_ORC_LIBRARY_DIRS} + PATHS ${ORC_ROOT}/${CMAKE_INSTALL_LIBDIR} + ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}) + +find_library( + ORC_LIBRARY_STATIC liborc-0.4.a + HINTS ${PC_ORC_LIBRARY_DIRS} + PATHS ${ORC_ROOT}/${CMAKE_INSTALL_LIBDIR} + ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}) + +list(APPEND ORC_LIBRARY ${ORC_LIB}) + +set(ORC_INCLUDE_DIRS ${ORC_INCLUDE_DIR}) +set(ORC_LIBRARIES ${ORC_LIBRARY}) +set(ORC_LIBRARY_DIRS ${ORC_LIBRARY_DIR}) +set(ORC_LIBRARIES_STATIC ${ORC_LIBRARY_STATIC}) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(ORC "orc files" ORC_LIBRARY ORC_INCLUDE_DIR + ORCC_EXECUTABLE) mark_as_advanced(ORC_INCLUDE_DIR ORC_LIBRARY ORCC_EXECUTABLE) diff --git a/cmake/Modules/VolkAddTest.cmake b/cmake/Modules/VolkAddTest.cmake index f0a0f47a..653a9e5c 100644 --- a/cmake/Modules/VolkAddTest.cmake +++ b/cmake/Modules/VolkAddTest.cmake @@ -20,7 +20,8 @@ set(__INCLUDED_VOLK_ADD_TEST TRUE) function(VOLK_GEN_TEST executable_name) include(CMakeParseArgumentsCopy) - CMAKE_PARSE_ARGUMENTS(VOLK_TEST "" "" "SOURCES;TARGET_DEPS;EXTRA_LIB_DIRS;ENVIRONS;ARGS" ${ARGN}) + cmake_parse_arguments(VOLK_TEST "" "" + "SOURCES;TARGET_DEPS;EXTRA_LIB_DIRS;ENVIRONS;ARGS" ${ARGN}) add_executable(${executable_name} ${VOLK_TEST_SOURCES}) target_link_libraries(${executable_name} ${VOLK_TEST_TARGET_DEPS}) endfunction() @@ -41,168 +42,172 @@ endfunction() ######################################################################## function(VOLK_ADD_TEST test_name executable_name) - #parse the arguments for component names - include(CMakeParseArgumentsCopy) - CMAKE_PARSE_ARGUMENTS(VOLK_TEST "" "" "TARGET_DEPS;EXTRA_LIB_DIRS;ENVIRONS;ARGS" ${ARGN}) - - #set the initial environs to use - set(environs ${VOLK_TEST_ENVIRONS}) - - #create the initial library path - file(TO_NATIVE_PATH "${VOLK_TEST_EXTRA_LIB_DIRS}" libpath) - - #set the source directory, which is mostly FYI - file(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR} srcdir) - list(APPEND environs "srcdir=\"${srcdir}\"") - - #http://www.cmake.org/pipermail/cmake/2009-May/029464.html - #Replaced this add test + set environs code with the shell script generation. - #Its nicer to be able to manually run the shell script to diagnose problems. - if(UNIX) - if(APPLE) - set(LD_PATH_VAR "DYLD_LIBRARY_PATH") - else() - set(LD_PATH_VAR "LD_LIBRARY_PATH") - endif() - - #create a list of target directories to be determined by the - #"add_test" command, via the $ operator; make sure the - #test's directory is first, since it ($1) is prepended to PATH. - unset(TARGET_DIR_LIST) - foreach(target ${executable_name} ${VOLK_TEST_TARGET_DEPS}) - list(APPEND TARGET_DIR_LIST "\$") - endforeach() - - #augment the PATH to start with the directory of the test - set(binpath "\"$1:\$PATH\"") - list(APPEND environs "PATH=${binpath}") - - #set the shell to use - if(CMAKE_CROSSCOMPILING) - set(SHELL "/bin/sh") - else() - find_program(SHELL sh) - endif() - - #check to see if the shell supports "$*" expansion with IFS - if(NOT TESTED_SHELL_SUPPORTS_IFS) - set(TESTED_SHELL_SUPPORTS_IFS TRUE CACHE BOOL "") - set(sh_file ${CMAKE_CURRENT_BINARY_DIR}/ifs_test.sh) - file(WRITE ${sh_file} "#!${SHELL}\n") - file(APPEND ${sh_file} "export IFS=:\n") - file(APPEND ${sh_file} "echo \"$*\"\n") - #make the shell file executable - execute_process(COMMAND chmod +x ${sh_file}) - - #execute the shell script - execute_process(COMMAND ${sh_file} "a" "b" "c" - OUTPUT_VARIABLE output OUTPUT_STRIP_TRAILING_WHITESPACE - ) - - #check the output to see if it is correct - string(COMPARE EQUAL ${output} "a:b:c" SHELL_SUPPORTS_IFS) - set(SHELL_SUPPORTS_IFS ${SHELL_SUPPORTS_IFS} CACHE BOOL - "Set this value to TRUE if the shell supports IFS argument expansion" - ) - endif() - unset(testlibpath) - if(SHELL_SUPPORTS_IFS) - #"$*" expands in the shell into a list of all of the arguments - #to the shell script, concatenated using the character provided - #in ${IFS}. - list(APPEND testlibpath "$*") - else() - #shell does not support IFS expansion; use a loop instead - list(APPEND testlibpath "\${LL}") - endif() - - #finally: add in the current library path variable - list(INSERT libpath 0 ${testlibpath}) - list(APPEND libpath "$${LD_PATH_VAR}") - - #replace list separator with the path separator - string(REPLACE ";" ":" libpath "${libpath}") - list(APPEND environs "${LD_PATH_VAR}=\"${libpath}\"") - - #generate a shell script file that sets the environment and runs the test - set(sh_file ${CMAKE_CURRENT_BINARY_DIR}/${test_name}_test.sh) - file(WRITE ${sh_file} "#!${SHELL}\n") - if(SHELL_SUPPORTS_IFS) - file(APPEND ${sh_file} "export IFS=:\n") - else() - file(APPEND ${sh_file} "LL=\"$1\" && for tf in \"\$@\"; do LL=\"\${LL}:\${tf}\"; done\n") - endif() - - #each line sets an environment variable - foreach(environ ${environs}) - file(APPEND ${sh_file} "export ${environ}\n") - endforeach(environ) - - set(VOLK_TEST_ARGS "${test_name}") - - #redo the test args to have a space between each - string(REPLACE ";" " " VOLK_TEST_ARGS "${VOLK_TEST_ARGS}") - - #finally: append the test name to execute - file(APPEND ${sh_file} "${CMAKE_CROSSCOMPILING_EMULATOR} ${executable_name} ${VOLK_TEST_ARGS}\n") - - #make the shell file executable - execute_process(COMMAND chmod +x ${sh_file}) - - #add the shell file as the test to execute; - #use the form that allows for $ substitutions, - #then combine the script arguments inside the script. - add_test(NAME qa_${test_name} - COMMAND ${SHELL} ${sh_file} ${TARGET_DIR_LIST} - ) - - endif(UNIX) - - if(WIN32) - #In the land of windows, all libraries must be in the PATH. Since - #the dependent libraries are not yet installed, we must manually - #set them in the PATH to run tests. The following appends the - #path of a target dependency. - # - #create a list of target directories to be determined by the - #"add_test" command, via the $ operator; make sure the - #test's directory is first, since it ($1) is prepended to PATH. - unset(TARGET_DIR_LIST) - foreach(target ${executable_name} ${VOLK_TEST_TARGET_DEPS}) - list(APPEND TARGET_DIR_LIST "$") - endforeach() - #replace list separator with the path separator (escaped) - string(REPLACE ";" "\\\\;" TARGET_DIR_LIST "${TARGET_DIR_LIST}") - - #add command line argument (TARGET_DIR_LIST) to path and append current path - list(INSERT libpath 0 "%1") - list(APPEND libpath "%PATH%") - - #replace list separator with the path separator (escaped) - string(REPLACE ";" "\\;" libpath "${libpath}") - list(APPEND environs "PATH=${libpath}") - - #generate a bat file that sets the environment and runs the test - set(bat_file ${CMAKE_CURRENT_BINARY_DIR}/${test_name}_test.bat) - file(WRITE ${bat_file} "@echo off\n") - - #each line sets an environment variable - foreach(environ ${environs}) - file(APPEND ${bat_file} "SET ${environ}\n") - endforeach(environ) - - set(VOLK_TEST_ARGS "${test_name}") - - #redo the test args to have a space between each - string(REPLACE ";" " " VOLK_TEST_ARGS "${VOLK_TEST_ARGS}") - - #finally: append the test name to execute - file(APPEND ${bat_file} "${executable_name} ${VOLK_TEST_ARGS}\n") - file(APPEND ${bat_file} "\n") - - add_test(NAME qa_${test_name} - COMMAND ${bat_file} ${TARGET_DIR_LIST} - ) - endif(WIN32) + #parse the arguments for component names + include(CMakeParseArgumentsCopy) + cmake_parse_arguments(VOLK_TEST "" "" "TARGET_DEPS;EXTRA_LIB_DIRS;ENVIRONS;ARGS" + ${ARGN}) + + #set the initial environs to use + set(environs ${VOLK_TEST_ENVIRONS}) + + #create the initial library path + file(TO_NATIVE_PATH "${VOLK_TEST_EXTRA_LIB_DIRS}" libpath) + + #set the source directory, which is mostly FYI + file(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR} srcdir) + list(APPEND environs "srcdir=\"${srcdir}\"") + + #http://www.cmake.org/pipermail/cmake/2009-May/029464.html + #Replaced this add test + set environs code with the shell script generation. + #Its nicer to be able to manually run the shell script to diagnose problems. + if(UNIX) + if(APPLE) + set(LD_PATH_VAR "DYLD_LIBRARY_PATH") + else() + set(LD_PATH_VAR "LD_LIBRARY_PATH") + endif() + + #create a list of target directories to be determined by the + #"add_test" command, via the $ operator; make sure the + #test's directory is first, since it ($1) is prepended to PATH. + unset(TARGET_DIR_LIST) + foreach(target ${executable_name} ${VOLK_TEST_TARGET_DEPS}) + list(APPEND TARGET_DIR_LIST "\$") + endforeach() + + #augment the PATH to start with the directory of the test + set(binpath "\"$1:\$PATH\"") + list(APPEND environs "PATH=${binpath}") + + #set the shell to use + if(CMAKE_CROSSCOMPILING) + set(SHELL "/bin/sh") + else() + find_program(SHELL sh) + endif() + + #check to see if the shell supports "$*" expansion with IFS + if(NOT TESTED_SHELL_SUPPORTS_IFS) + set(TESTED_SHELL_SUPPORTS_IFS + TRUE + CACHE BOOL "") + set(sh_file ${CMAKE_CURRENT_BINARY_DIR}/ifs_test.sh) + file(WRITE ${sh_file} "#!${SHELL}\n") + file(APPEND ${sh_file} "export IFS=:\n") + file(APPEND ${sh_file} "echo \"$*\"\n") + #make the shell file executable + execute_process(COMMAND chmod +x ${sh_file}) + + #execute the shell script + execute_process( + COMMAND ${sh_file} "a" "b" "c" + OUTPUT_VARIABLE output + OUTPUT_STRIP_TRAILING_WHITESPACE) + + #check the output to see if it is correct + string(COMPARE EQUAL ${output} "a:b:c" SHELL_SUPPORTS_IFS) + set(SHELL_SUPPORTS_IFS + ${SHELL_SUPPORTS_IFS} + CACHE + BOOL + "Set this value to TRUE if the shell supports IFS argument expansion") + endif() + unset(testlibpath) + if(SHELL_SUPPORTS_IFS) + #"$*" expands in the shell into a list of all of the arguments + #to the shell script, concatenated using the character provided + #in ${IFS}. + list(APPEND testlibpath "$*") + else() + #shell does not support IFS expansion; use a loop instead + list(APPEND testlibpath "\${LL}") + endif() + + #finally: add in the current library path variable + list(INSERT libpath 0 ${testlibpath}) + list(APPEND libpath "$${LD_PATH_VAR}") + + #replace list separator with the path separator + string(REPLACE ";" ":" libpath "${libpath}") + list(APPEND environs "${LD_PATH_VAR}=\"${libpath}\"") + + #generate a shell script file that sets the environment and runs the test + set(sh_file ${CMAKE_CURRENT_BINARY_DIR}/${test_name}_test.sh) + file(WRITE ${sh_file} "#!${SHELL}\n") + if(SHELL_SUPPORTS_IFS) + file(APPEND ${sh_file} "export IFS=:\n") + else() + file(APPEND ${sh_file} + "LL=\"$1\" && for tf in \"\$@\"; do LL=\"\${LL}:\${tf}\"; done\n") + endif() + + #each line sets an environment variable + foreach(environ ${environs}) + file(APPEND ${sh_file} "export ${environ}\n") + endforeach(environ) + + set(VOLK_TEST_ARGS "${test_name}") + + #redo the test args to have a space between each + string(REPLACE ";" " " VOLK_TEST_ARGS "${VOLK_TEST_ARGS}") + + #finally: append the test name to execute + file(APPEND ${sh_file} + "${CMAKE_CROSSCOMPILING_EMULATOR} ${executable_name} ${VOLK_TEST_ARGS}\n") + + #make the shell file executable + execute_process(COMMAND chmod +x ${sh_file}) + + #add the shell file as the test to execute; + #use the form that allows for $ substitutions, + #then combine the script arguments inside the script. + add_test(NAME qa_${test_name} COMMAND ${SHELL} ${sh_file} ${TARGET_DIR_LIST}) + + endif(UNIX) + + if(WIN32) + #In the land of windows, all libraries must be in the PATH. Since + #the dependent libraries are not yet installed, we must manually + #set them in the PATH to run tests. The following appends the + #path of a target dependency. + # + #create a list of target directories to be determined by the + #"add_test" command, via the $ operator; make sure the + #test's directory is first, since it ($1) is prepended to PATH. + unset(TARGET_DIR_LIST) + foreach(target ${executable_name} ${VOLK_TEST_TARGET_DEPS}) + list(APPEND TARGET_DIR_LIST "$") + endforeach() + #replace list separator with the path separator (escaped) + string(REPLACE ";" "\\\\;" TARGET_DIR_LIST "${TARGET_DIR_LIST}") + + #add command line argument (TARGET_DIR_LIST) to path and append current path + list(INSERT libpath 0 "%1") + list(APPEND libpath "%PATH%") + + #replace list separator with the path separator (escaped) + string(REPLACE ";" "\\;" libpath "${libpath}") + list(APPEND environs "PATH=${libpath}") + + #generate a bat file that sets the environment and runs the test + set(bat_file ${CMAKE_CURRENT_BINARY_DIR}/${test_name}_test.bat) + file(WRITE ${bat_file} "@echo off\n") + + #each line sets an environment variable + foreach(environ ${environs}) + file(APPEND ${bat_file} "SET ${environ}\n") + endforeach(environ) + + set(VOLK_TEST_ARGS "${test_name}") + + #redo the test args to have a space between each + string(REPLACE ";" " " VOLK_TEST_ARGS "${VOLK_TEST_ARGS}") + + #finally: append the test name to execute + file(APPEND ${bat_file} "${executable_name} ${VOLK_TEST_ARGS}\n") + file(APPEND ${bat_file} "\n") + + add_test(NAME qa_${test_name} COMMAND ${bat_file} ${TARGET_DIR_LIST}) + endif(WIN32) endfunction(VOLK_ADD_TEST) diff --git a/cmake/Modules/VolkBuildTypes.cmake b/cmake/Modules/VolkBuildTypes.cmake index 7cd93840..90f28d01 100644 --- a/cmake/Modules/VolkBuildTypes.cmake +++ b/cmake/Modules/VolkBuildTypes.cmake @@ -25,11 +25,19 @@ set(__INCLUDED_VOLK_BUILD_TYPES_CMAKE TRUE) # Defines the list of acceptable cmake build types. When adding a new # build type below, make sure to add it to this list. -list(APPEND AVAIL_BUILDTYPES - None Debug Release RelWithDebInfo MinSizeRel - DebugParanoid NoOptWithASM O2WithASM O3WithASM - ASAN -) +list( + APPEND + AVAIL_BUILDTYPES + None + Debug + Release + RelWithDebInfo + MinSizeRel + DebugParanoid + NoOptWithASM + O2WithASM + O3WithASM + ASAN) ######################################################################## # VOLK_CHECK_BUILD_TYPE(build type) @@ -43,15 +51,17 @@ list(APPEND AVAIL_BUILDTYPES # the available build types. ######################################################################## function(VOLK_CHECK_BUILD_TYPE settype) - STRING(TOUPPER ${settype} _settype) - foreach(btype ${AVAIL_BUILDTYPES}) - STRING(TOUPPER ${btype} _btype) - if(${_settype} STREQUAL ${_btype}) - return() # found it; exit cleanly - endif(${_settype} STREQUAL ${_btype}) - endforeach(btype) - # Build type not found; error out - message(FATAL_ERROR "Build type '${settype}' not valid, must be one of: ${AVAIL_BUILDTYPES}") + string(TOUPPER ${settype} _settype) + foreach(btype ${AVAIL_BUILDTYPES}) + string(TOUPPER ${btype} _btype) + if(${_settype} STREQUAL ${_btype}) + return() # found it; exit cleanly + endif(${_settype} STREQUAL ${_btype}) + endforeach(btype) + # Build type not found; error out + message( + FATAL_ERROR + "Build type '${settype}' not valid, must be one of: ${AVAIL_BUILDTYPES}") endfunction(VOLK_CHECK_BUILD_TYPE) ######################################################################## @@ -64,25 +74,25 @@ endfunction(VOLK_CHECK_BUILD_TYPE) # NOTE: This is not defined on Windows systems. ######################################################################## if(NOT WIN32) - SET(CMAKE_CXX_FLAGS_DEBUGPARANOID "-Wall -Wextra -g -O0" CACHE STRING - "Flags used by the C++ compiler during DebugParanoid builds." FORCE) - SET(CMAKE_C_FLAGS_DEBUGPARANOID "-Wall -Wextra -g -O0" CACHE STRING - "Flags used by the C compiler during DebugParanoid builds." FORCE) - SET(CMAKE_EXE_LINKER_FLAGS_DEBUGPARANOID - "-Wl,--warn-unresolved-symbols,--warn-once" CACHE STRING - "Flags used for linking binaries during NoOptWithASM builds." FORCE) - SET(CMAKE_SHARED_LINKER_FLAGS_DEBUGPARANOID - "-Wl,--warn-unresolved-symbols,--warn-once" CACHE STRING - "Flags used by the shared lib linker during NoOptWithASM builds." FORCE) - - MARK_AS_ADVANCED( - CMAKE_CXX_FLAGS_DEBUGPARANOID - CMAKE_C_FLAGS_DEBUGPARANOID - CMAKE_EXE_LINKER_FLAGS_DEBUGPARANOID - CMAKE_SHARED_LINKER_DEBUGPARANOID) + set(CMAKE_CXX_FLAGS_DEBUGPARANOID + "-Wall -Wextra -g -O0" + CACHE STRING "Flags used by the C++ compiler during DebugParanoid builds." FORCE) + set(CMAKE_C_FLAGS_DEBUGPARANOID + "-Wall -Wextra -g -O0" + CACHE STRING "Flags used by the C compiler during DebugParanoid builds." FORCE) + set(CMAKE_EXE_LINKER_FLAGS_DEBUGPARANOID + "-Wl,--warn-unresolved-symbols,--warn-once" + CACHE STRING "Flags used for linking binaries during NoOptWithASM builds." FORCE) + set(CMAKE_SHARED_LINKER_FLAGS_DEBUGPARANOID + "-Wl,--warn-unresolved-symbols,--warn-once" + CACHE STRING "Flags used by the shared lib linker during NoOptWithASM builds." + FORCE) + + mark_as_advanced( + CMAKE_CXX_FLAGS_DEBUGPARANOID CMAKE_C_FLAGS_DEBUGPARANOID + CMAKE_EXE_LINKER_FLAGS_DEBUGPARANOID CMAKE_SHARED_LINKER_DEBUGPARANOID) endif(NOT WIN32) - ######################################################################## # For GCC and Clang, we can set a build type: # @@ -95,25 +105,25 @@ endif(NOT WIN32) # NOTE: This is not defined on Windows systems. ######################################################################## if(NOT WIN32) - SET(CMAKE_CXX_FLAGS_NOOPTWITHASM "-save-temps -g -O0" CACHE STRING - "Flags used by the C++ compiler during NoOptWithASM builds." FORCE) - SET(CMAKE_C_FLAGS_NOOPTWITHASM "-save-temps -g -O0" CACHE STRING - "Flags used by the C compiler during NoOptWithASM builds." FORCE) - SET(CMAKE_EXE_LINKER_FLAGS_NOOPTWITHASM - "-Wl,--warn-unresolved-symbols,--warn-once" CACHE STRING - "Flags used for linking binaries during NoOptWithASM builds." FORCE) - SET(CMAKE_SHARED_LINKER_FLAGS_NOOPTWITHASM - "-Wl,--warn-unresolved-symbols,--warn-once" CACHE STRING - "Flags used by the shared lib linker during NoOptWithASM builds." FORCE) - - MARK_AS_ADVANCED( - CMAKE_CXX_FLAGS_NOOPTWITHASM - CMAKE_C_FLAGS_NOOPTWITHASM - CMAKE_EXE_LINKER_FLAGS_NOOPTWITHASM - CMAKE_SHARED_LINKER_FLAGS_NOOPTWITHASM) + set(CMAKE_CXX_FLAGS_NOOPTWITHASM + "-save-temps -g -O0" + CACHE STRING "Flags used by the C++ compiler during NoOptWithASM builds." FORCE) + set(CMAKE_C_FLAGS_NOOPTWITHASM + "-save-temps -g -O0" + CACHE STRING "Flags used by the C compiler during NoOptWithASM builds." FORCE) + set(CMAKE_EXE_LINKER_FLAGS_NOOPTWITHASM + "-Wl,--warn-unresolved-symbols,--warn-once" + CACHE STRING "Flags used for linking binaries during NoOptWithASM builds." FORCE) + set(CMAKE_SHARED_LINKER_FLAGS_NOOPTWITHASM + "-Wl,--warn-unresolved-symbols,--warn-once" + CACHE STRING "Flags used by the shared lib linker during NoOptWithASM builds." + FORCE) + + mark_as_advanced( + CMAKE_CXX_FLAGS_NOOPTWITHASM CMAKE_C_FLAGS_NOOPTWITHASM + CMAKE_EXE_LINKER_FLAGS_NOOPTWITHASM CMAKE_SHARED_LINKER_FLAGS_NOOPTWITHASM) endif(NOT WIN32) - ######################################################################## # For GCC and Clang, we can set a build type: # @@ -127,25 +137,23 @@ endif(NOT WIN32) ######################################################################## if(NOT WIN32) - SET(CMAKE_CXX_FLAGS_O2WITHASM "-save-temps -g -O2" CACHE STRING - "Flags used by the C++ compiler during O2WithASM builds." FORCE) - SET(CMAKE_C_FLAGS_O2WITHASM "-save-temps -g -O2" CACHE STRING - "Flags used by the C compiler during O2WithASM builds." FORCE) - SET(CMAKE_EXE_LINKER_FLAGS_O2WITHASM - "-Wl,--warn-unresolved-symbols,--warn-once" CACHE STRING - "Flags used for linking binaries during O2WithASM builds." FORCE) - SET(CMAKE_SHARED_LINKER_FLAGS_O2WITHASM - "-Wl,--warn-unresolved-symbols,--warn-once" CACHE STRING - "Flags used by the shared lib linker during O2WithASM builds." FORCE) - - MARK_AS_ADVANCED( - CMAKE_CXX_FLAGS_O2WITHASM - CMAKE_C_FLAGS_O2WITHASM - CMAKE_EXE_LINKER_FLAGS_O2WITHASM - CMAKE_SHARED_LINKER_FLAGS_O2WITHASM) + set(CMAKE_CXX_FLAGS_O2WITHASM + "-save-temps -g -O2" + CACHE STRING "Flags used by the C++ compiler during O2WithASM builds." FORCE) + set(CMAKE_C_FLAGS_O2WITHASM + "-save-temps -g -O2" + CACHE STRING "Flags used by the C compiler during O2WithASM builds." FORCE) + set(CMAKE_EXE_LINKER_FLAGS_O2WITHASM + "-Wl,--warn-unresolved-symbols,--warn-once" + CACHE STRING "Flags used for linking binaries during O2WithASM builds." FORCE) + set(CMAKE_SHARED_LINKER_FLAGS_O2WITHASM + "-Wl,--warn-unresolved-symbols,--warn-once" + CACHE STRING "Flags used by the shared lib linker during O2WithASM builds." FORCE) + + mark_as_advanced(CMAKE_CXX_FLAGS_O2WITHASM CMAKE_C_FLAGS_O2WITHASM + CMAKE_EXE_LINKER_FLAGS_O2WITHASM CMAKE_SHARED_LINKER_FLAGS_O2WITHASM) endif(NOT WIN32) - ######################################################################## # For GCC and Clang, we can set a build type: # @@ -159,22 +167,21 @@ endif(NOT WIN32) ######################################################################## if(NOT WIN32) - SET(CMAKE_CXX_FLAGS_O3WITHASM "-save-temps -g -O3" CACHE STRING - "Flags used by the C++ compiler during O3WithASM builds." FORCE) - SET(CMAKE_C_FLAGS_O3WITHASM "-save-temps -g -O3" CACHE STRING - "Flags used by the C compiler during O3WithASM builds." FORCE) - SET(CMAKE_EXE_LINKER_FLAGS_O3WITHASM - "-Wl,--warn-unresolved-symbols,--warn-once" CACHE STRING - "Flags used for linking binaries during O3WithASM builds." FORCE) - SET(CMAKE_SHARED_LINKER_FLAGS_O3WITHASM - "-Wl,--warn-unresolved-symbols,--warn-once" CACHE STRING - "Flags used by the shared lib linker during O3WithASM builds." FORCE) - - MARK_AS_ADVANCED( - CMAKE_CXX_FLAGS_O3WITHASM - CMAKE_C_FLAGS_O3WITHASM - CMAKE_EXE_LINKER_FLAGS_O3WITHASM - CMAKE_SHARED_LINKER_FLAGS_O3WITHASM) + set(CMAKE_CXX_FLAGS_O3WITHASM + "-save-temps -g -O3" + CACHE STRING "Flags used by the C++ compiler during O3WithASM builds." FORCE) + set(CMAKE_C_FLAGS_O3WITHASM + "-save-temps -g -O3" + CACHE STRING "Flags used by the C compiler during O3WithASM builds." FORCE) + set(CMAKE_EXE_LINKER_FLAGS_O3WITHASM + "-Wl,--warn-unresolved-symbols,--warn-once" + CACHE STRING "Flags used for linking binaries during O3WithASM builds." FORCE) + set(CMAKE_SHARED_LINKER_FLAGS_O3WITHASM + "-Wl,--warn-unresolved-symbols,--warn-once" + CACHE STRING "Flags used by the shared lib linker during O3WithASM builds." FORCE) + + mark_as_advanced(CMAKE_CXX_FLAGS_O3WITHASM CMAKE_C_FLAGS_O3WITHASM + CMAKE_EXE_LINKER_FLAGS_O3WITHASM CMAKE_SHARED_LINKER_FLAGS_O3WITHASM) endif(NOT WIN32) ######################################################################## @@ -187,13 +194,15 @@ endif(NOT WIN32) # NOTE: This is not defined on Windows systems. ######################################################################## if(NOT WIN32) - SET(CMAKE_CXX_FLAGS_ASAN "-Wall -Wextra -g -O2 -fsanitize=address -fsanitize=undefined -fno-omit-frame-pointer" CACHE STRING - "Flags used by the C++ compiler during Address Sanitized builds." FORCE) - SET(CMAKE_C_FLAGS_ASAN "-Wall -Wextra -g -O2 -fsanitize=address -fsanitize=undefined -fno-omit-frame-pointer" CACHE STRING - "Flags used by the C compiler during Address Sanitized builds." FORCE) - MARK_AS_ADVANCED( - CMAKE_CXX_FLAGS_ASAN - CMAKE_C_FLAGS_ASAN - CMAKE_EXE_LINKER_FLAGS_DEBUGPARANOID - CMAKE_SHARED_LINKER_DEBUGPARANOID) + set(CMAKE_CXX_FLAGS_ASAN + "-Wall -Wextra -g -O2 -fsanitize=address -fsanitize=undefined -fno-omit-frame-pointer" + CACHE STRING "Flags used by the C++ compiler during Address Sanitized builds." + FORCE) + set(CMAKE_C_FLAGS_ASAN + "-Wall -Wextra -g -O2 -fsanitize=address -fsanitize=undefined -fno-omit-frame-pointer" + CACHE STRING "Flags used by the C compiler during Address Sanitized builds." + FORCE) + mark_as_advanced( + CMAKE_CXX_FLAGS_ASAN CMAKE_C_FLAGS_ASAN CMAKE_EXE_LINKER_FLAGS_DEBUGPARANOID + CMAKE_SHARED_LINKER_DEBUGPARANOID) endif(NOT WIN32) diff --git a/cmake/Modules/VolkConfig.cmake.in b/cmake/Modules/VolkConfig.cmake.in index f18e07fa..042f58e7 100644 --- a/cmake/Modules/VolkConfig.cmake.in +++ b/cmake/Modules/VolkConfig.cmake.in @@ -8,34 +8,40 @@ get_filename_component(VOLK_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) if(NOT TARGET Volk::volk) - include("${VOLK_CMAKE_DIR}/VolkTargets.cmake") + include("${VOLK_CMAKE_DIR}/VolkTargets.cmake") endif() # set VOLK_FOUND to be set globally, for whether a compatible Volk was # found -- could be a correct enough version or any version depending # on how find_package was called. if(NOT TARGET Volk::volk) - set(VOLK_FOUND FALSE) + set(VOLK_FOUND FALSE) else() - set(VOLK_FOUND TRUE) + set(VOLK_FOUND TRUE) endif() # cache whether a compatible Volk was found for # use anywhere in the calling project -set(VOLK_FOUND ${VOLK_FOUND} CACHE BOOL "Whether a compatible Volk was found" FORCE) +set(VOLK_FOUND + ${VOLK_FOUND} + CACHE BOOL "Whether a compatible Volk was found" FORCE) if(VOLK_FOUND) - # use the new target library, regardless of whether new or old style - # we still need to set a variable with the library name so that there - # is a variable to reference in the using-project's cmake scripts! - set(VOLK_LIBRARIES Volk::volk CACHE STRING "Volk Library" FORCE) + # use the new target library, regardless of whether new or old style + # we still need to set a variable with the library name so that there + # is a variable to reference in the using-project's cmake scripts! + set(VOLK_LIBRARIES + Volk::volk + CACHE STRING "Volk Library" FORCE) - # INTERFACE_INCLUDE_DIRECTORIES should always be set - get_target_property(VOLK_INCLUDE_DIRS Volk::volk INTERFACE_INCLUDE_DIRECTORIES) - set(VOLK_INCLUDE_DIRS ${VOLK_INCLUDE_DIRS} CACHE STRING "Volk Include Directories" FORCE) + # INTERFACE_INCLUDE_DIRECTORIES should always be set + get_target_property(VOLK_INCLUDE_DIRS Volk::volk INTERFACE_INCLUDE_DIRECTORIES) + set(VOLK_INCLUDE_DIRS + ${VOLK_INCLUDE_DIRS} + CACHE STRING "Volk Include Directories" FORCE) - # for backward compatibility with old-CMake non-target project finding - include(FindPackageHandleStandardArgs) - find_package_handle_standard_args(Volk DEFAULT_MSG VOLK_LIBRARIES VOLK_INCLUDE_DIRS) - mark_as_advanced(VOLK_LIBRARIES VOLK_INCLUDE_DIRS) + # for backward compatibility with old-CMake non-target project finding + include(FindPackageHandleStandardArgs) + find_package_handle_standard_args(Volk DEFAULT_MSG VOLK_LIBRARIES VOLK_INCLUDE_DIRS) + mark_as_advanced(VOLK_LIBRARIES VOLK_INCLUDE_DIRS) endif(VOLK_FOUND) diff --git a/cmake/Modules/VolkConfigVersion.cmake.in b/cmake/Modules/VolkConfigVersion.cmake.in index b97d25d9..d55f127f 100644 --- a/cmake/Modules/VolkConfigVersion.cmake.in +++ b/cmake/Modules/VolkConfigVersion.cmake.in @@ -12,10 +12,10 @@ set(MAINT_VERSION @VERSION_INFO_MAINT_VERSION@) set(PACKAGE_VERSION ${MAJOR_VERSION}.${MINOR_VERSION}.${MAINT_VERSION}) if(${PACKAGE_FIND_VERSION_MAJOR} EQUAL ${MAJOR_VERSION}) - if(${PACKAGE_FIND_VERSION_MINOR} EQUAL ${MINOR_VERSION}) - if(NOT ${PACKAGE_FIND_VERSION_PATCH} GREATER ${MAINT_VERSION}) - set(PACKAGE_VERSION_EXACT 1) # exact match for API version - set(PACKAGE_VERSION_COMPATIBLE 1) # compat for minor/patch version + if(${PACKAGE_FIND_VERSION_MINOR} EQUAL ${MINOR_VERSION}) + if(NOT ${PACKAGE_FIND_VERSION_PATCH} GREATER ${MAINT_VERSION}) + set(PACKAGE_VERSION_EXACT 1) # exact match for API version + set(PACKAGE_VERSION_COMPATIBLE 1) # compat for minor/patch version + endif() endif() - endif() endif() diff --git a/cmake/Modules/VolkPython.cmake b/cmake/Modules/VolkPython.cmake index b58519d5..73bc2914 100644 --- a/cmake/Modules/VolkPython.cmake +++ b/cmake/Modules/VolkPython.cmake @@ -37,7 +37,7 @@ if(PYTHON_EXECUTABLE) set(PYTHONINTERP_FOUND TRUE) -#otherwise if not set, try to automatically find it + #otherwise if not set, try to automatically find it else(PYTHON_EXECUTABLE) #use the built-in find script @@ -55,8 +55,9 @@ else(PYTHON_EXECUTABLE) endif(PYTHON_EXECUTABLE) #make the path to the executable appear in the cmake gui -set(PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE} CACHE FILEPATH "python interpreter") - +set(PYTHON_EXECUTABLE + ${PYTHON_EXECUTABLE} + CACHE FILEPATH "python interpreter") ######################################################################## # Check for the existence of a python module: @@ -69,7 +70,8 @@ macro(VOLK_PYTHON_CHECK_MODULE desc mod cmd have) message(STATUS "") message(STATUS "Python checking for ${desc}") execute_process( - COMMAND ${PYTHON_EXECUTABLE} -c " + COMMAND + ${PYTHON_EXECUTABLE} -c " ######################################### try: import ${mod} except: @@ -78,8 +80,7 @@ except: try: assert ${cmd} except: exit(-1) #########################################" - RESULT_VARIABLE ${have} - ) + RESULT_VARIABLE ${have}) if(${have} EQUAL 0) message(STATUS "Python checking for ${desc} - found") set(${have} TRUE) @@ -96,8 +97,9 @@ endmacro(VOLK_PYTHON_CHECK_MODULE) # https://github.com/pothosware/SoapySDR/blob/master/LICENSE_1_0.txt ######################################################################## if(NOT DEFINED VOLK_PYTHON_DIR) -execute_process( - COMMAND ${PYTHON_EXECUTABLE} -c "import os + execute_process( + COMMAND + ${PYTHON_EXECUTABLE} -c "import os import sysconfig import site @@ -128,9 +130,8 @@ if not install_dir: #strip the prefix to return a relative path print(os.path.relpath(install_dir, prefix))" - OUTPUT_STRIP_TRAILING_WHITESPACE - OUTPUT_VARIABLE VOLK_PYTHON_DIR -) + OUTPUT_STRIP_TRAILING_WHITESPACE + OUTPUT_VARIABLE VOLK_PYTHON_DIR) endif() file(TO_CMAKE_PATH ${VOLK_PYTHON_DIR} VOLK_PYTHON_DIR) @@ -140,10 +141,12 @@ file(TO_CMAKE_PATH ${VOLK_PYTHON_DIR} VOLK_PYTHON_DIR) ######################################################################## function(VOLK_UNIQUE_TARGET desc) file(RELATIVE_PATH reldir ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import re, hashlib + execute_process( + COMMAND ${PYTHON_EXECUTABLE} -c "import re, hashlib unique = hashlib.sha256(b'${reldir}${ARGN}').hexdigest()[:5] print(re.sub('\\W', '_', '${desc} ${reldir} ' + unique))" - OUTPUT_VARIABLE _target OUTPUT_STRIP_TRAILING_WHITESPACE) + OUTPUT_VARIABLE _target + OUTPUT_STRIP_TRAILING_WHITESPACE) add_custom_target(${_target} ALL DEPENDS ${ARGN}) endfunction(VOLK_UNIQUE_TARGET) @@ -152,11 +155,12 @@ endfunction(VOLK_UNIQUE_TARGET) ######################################################################## function(VOLK_PYTHON_INSTALL) include(CMakeParseArgumentsCopy) - CMAKE_PARSE_ARGUMENTS(VOLK_PYTHON_INSTALL "" "DESTINATION;COMPONENT" "FILES;PROGRAMS" ${ARGN}) + cmake_parse_arguments(VOLK_PYTHON_INSTALL "" "DESTINATION;COMPONENT" "FILES;PROGRAMS" + ${ARGN}) #################################################################### if(VOLK_PYTHON_INSTALL_FILES) - #################################################################### + #################################################################### install(${ARGN}) #installs regular python files #create a list of all generated files @@ -190,49 +194,52 @@ function(VOLK_PYTHON_INSTALL) #the command to generate the pyc files add_custom_command( - DEPENDS ${pysrcfiles} OUTPUT ${pycfiles} - COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_BINARY_DIR}/python_compile_helper.py ${pysrcfiles} ${pycfiles} - ) + DEPENDS ${pysrcfiles} + OUTPUT ${pycfiles} + COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_BINARY_DIR}/python_compile_helper.py + ${pysrcfiles} ${pycfiles}) #the command to generate the pyo files add_custom_command( - DEPENDS ${pysrcfiles} OUTPUT ${pyofiles} - COMMAND ${PYTHON_EXECUTABLE} -O ${CMAKE_BINARY_DIR}/python_compile_helper.py ${pysrcfiles} ${pyofiles} - ) + DEPENDS ${pysrcfiles} + OUTPUT ${pyofiles} + COMMAND ${PYTHON_EXECUTABLE} -O ${CMAKE_BINARY_DIR}/python_compile_helper.py + ${pysrcfiles} ${pyofiles}) #create install rule and add generated files to target list set(python_install_gen_targets ${pycfiles} ${pyofiles}) - install(FILES ${python_install_gen_targets} + install( + FILES ${python_install_gen_targets} DESTINATION ${VOLK_PYTHON_INSTALL_DESTINATION} - COMPONENT ${VOLK_PYTHON_INSTALL_COMPONENT} - ) + COMPONENT ${VOLK_PYTHON_INSTALL_COMPONENT}) - - #################################################################### + #################################################################### elseif(VOLK_PYTHON_INSTALL_PROGRAMS) - #################################################################### + #################################################################### file(TO_NATIVE_PATH ${PYTHON_EXECUTABLE} pyexe_native) - if (CMAKE_CROSSCOMPILING) - set(pyexe_native "/usr/bin/env python") + if(CMAKE_CROSSCOMPILING) + set(pyexe_native "/usr/bin/env python") endif() foreach(pyfile ${VOLK_PYTHON_INSTALL_PROGRAMS}) get_filename_component(pyfile_name ${pyfile} NAME) get_filename_component(pyfile ${pyfile} ABSOLUTE) - string(REPLACE "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" pyexefile "${pyfile}.exe") + string(REPLACE "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" pyexefile + "${pyfile}.exe") list(APPEND python_install_gen_targets ${pyexefile}) get_filename_component(pyexefile_path ${pyexefile} PATH) file(MAKE_DIRECTORY ${pyexefile_path}) add_custom_command( - OUTPUT ${pyexefile} DEPENDS ${pyfile} - COMMAND ${PYTHON_EXECUTABLE} -c - "open('${pyexefile}','w').write(r'\#!${pyexe_native}'+'\\n'+open('${pyfile}').read())" + OUTPUT ${pyexefile} + DEPENDS ${pyfile} + COMMAND + ${PYTHON_EXECUTABLE} -c + "open('${pyexefile}','w').write(r'\#!${pyexe_native}'+'\\n'+open('${pyfile}').read())" COMMENT "Shebangin ${pyfile_name}" - VERBATIM - ) + VERBATIM) #on windows, python files need an extension to execute get_filename_component(pyfile_ext ${pyfile} EXT) @@ -240,22 +247,25 @@ function(VOLK_PYTHON_INSTALL) set(pyfile_name "${pyfile_name}.py") endif() - install(PROGRAMS ${pyexefile} RENAME ${pyfile_name} + install( + PROGRAMS ${pyexefile} + RENAME ${pyfile_name} DESTINATION ${VOLK_PYTHON_INSTALL_DESTINATION} - COMPONENT ${VOLK_PYTHON_INSTALL_COMPONENT} - ) + COMPONENT ${VOLK_PYTHON_INSTALL_COMPONENT}) endforeach(pyfile) endif() - VOLK_UNIQUE_TARGET("pygen" ${python_install_gen_targets}) + volk_unique_target("pygen" ${python_install_gen_targets}) endfunction(VOLK_PYTHON_INSTALL) ######################################################################## # Write the python helper script that generates byte code files ######################################################################## -file(WRITE ${CMAKE_BINARY_DIR}/python_compile_helper.py " +file( + WRITE ${CMAKE_BINARY_DIR}/python_compile_helper.py + " import sys, py_compile files = sys.argv[1:] srcs, gens = files[:len(files)//2], files[len(files)//2:] diff --git a/cmake/Modules/VolkVersion.cmake b/cmake/Modules/VolkVersion.cmake index 8be9d253..b9f7932e 100644 --- a/cmake/Modules/VolkVersion.cmake +++ b/cmake/Modules/VolkVersion.cmake @@ -24,19 +24,20 @@ if(GIT_FOUND AND EXISTS ${CMAKE_SOURCE_DIR}/.git) message(STATUS "Extracting version information from git describe...") execute_process( COMMAND ${GIT_EXECUTABLE} describe --always --abbrev=8 --long - OUTPUT_VARIABLE GIT_DESCRIBE OUTPUT_STRIP_TRAILING_WHITESPACE - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - ) + OUTPUT_VARIABLE GIT_DESCRIBE + OUTPUT_STRIP_TRAILING_WHITESPACE + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) else() - if(NOT VOLK_GIT_COUNT) - set(VOLK_GIT_COUNT "0") - endif() + if(NOT VOLK_GIT_COUNT) + set(VOLK_GIT_COUNT "0") + endif() - if(NOT VOLK_GIT_HASH) - set(VOLK_GIT_HASH "unknown") - endif() + if(NOT VOLK_GIT_HASH) + set(VOLK_GIT_HASH "unknown") + endif() - set(GIT_DESCRIBE "v${MAJOR_VERSION}.${MINOR_VERSION}-${VOLK_GIT_COUNT}-${VOLK_GIT_HASH}") + set(GIT_DESCRIBE + "v${MAJOR_VERSION}.${MINOR_VERSION}-${VOLK_GIT_COUNT}-${VOLK_GIT_HASH}") endif() ######################################################################## @@ -47,8 +48,8 @@ if("${MINOR_VERSION}" STREQUAL "git") # DOCVER: 1.0git # SOVERSION: 1.0git set(VERSION "${GIT_DESCRIBE}") - set(DOCVER "${MAJOR_VERSION}.0${MINOR_VERSION}") - set(SOVERSION "${MAJOR_VERSION}.0${MINOR_VERSION}") + set(DOCVER "${MAJOR_VERSION}.0${MINOR_VERSION}") + set(SOVERSION "${MAJOR_VERSION}.0${MINOR_VERSION}") set(RC_MINOR_VERSION "0") set(RC_MAINT_VERSION "0") elseif("${MAINT_VERSION}" STREQUAL "git") @@ -56,8 +57,8 @@ elseif("${MAINT_VERSION}" STREQUAL "git") # DOCVER: 1.xgit # SOVERSION: 1.xgit set(VERSION "${GIT_DESCRIBE}") - set(DOCVER "${MAJOR_VERSION}.${MINOR_VERSION}${MAINT_VERSION}") - set(SOVERSION "${MAJOR_VERSION}.${MINOR_VERSION}${MAINT_VERSION}") + set(DOCVER "${MAJOR_VERSION}.${MINOR_VERSION}${MAINT_VERSION}") + set(SOVERSION "${MAJOR_VERSION}.${MINOR_VERSION}${MAINT_VERSION}") math(EXPR RC_MINOR_VERSION "${MINOR_VERSION} - 1") set(RC_MAINT_VERSION "0") else() diff --git a/cmake/Toolchains/aarch64-linux-gnu.cmake b/cmake/Toolchains/aarch64-linux-gnu.cmake index d6e53959..052380fa 100644 --- a/cmake/Toolchains/aarch64-linux-gnu.cmake +++ b/cmake/Toolchains/aarch64-linux-gnu.cmake @@ -9,19 +9,20 @@ set(CMAKE_SYSTEM_NAME Linux) set(CMAKE_SYSTEM_PROCESSOR aarch64) -if(MINGW OR CYGWIN OR WIN32) - set(UTIL_SEARCH_CMD where) +if(MINGW + OR CYGWIN + OR WIN32) + set(UTIL_SEARCH_CMD where) elseif(UNIX OR APPLE) - set(UTIL_SEARCH_CMD which) + set(UTIL_SEARCH_CMD which) endif() set(TOOLCHAIN_PREFIX aarch64-linux-gnu-) execute_process( - COMMAND ${UTIL_SEARCH_CMD} ${TOOLCHAIN_PREFIX}gcc - OUTPUT_VARIABLE BINUTILS_PATH - OUTPUT_STRIP_TRAILING_WHITESPACE - ) + COMMAND ${UTIL_SEARCH_CMD} ${TOOLCHAIN_PREFIX}gcc + OUTPUT_VARIABLE BINUTILS_PATH + OUTPUT_STRIP_TRAILING_WHITESPACE) get_filename_component(ARM_TOOLCHAIN_DIR ${BINUTILS_PATH} DIRECTORY) @@ -33,8 +34,12 @@ set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}gcc) set(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER}) set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}g++) -set(CMAKE_OBJCOPY ${ARM_TOOLCHAIN_DIR}/${TOOLCHAIN_PREFIX}objcopy CACHE INTERNAL "objcopy tool") -set(CMAKE_SIZE_UTIL ${ARM_TOOLCHAIN_DIR}/${TOOLCHAIN_PREFIX}size CACHE INTERNAL "size tool") +set(CMAKE_OBJCOPY + ${ARM_TOOLCHAIN_DIR}/${TOOLCHAIN_PREFIX}objcopy + CACHE INTERNAL "objcopy tool") +set(CMAKE_SIZE_UTIL + ${ARM_TOOLCHAIN_DIR}/${TOOLCHAIN_PREFIX}size + CACHE INTERNAL "size tool") set(CMAKE_FIND_ROOT_PATH ${BINUTILS_PATH}) diff --git a/cmake/Toolchains/arm-linux-gnueabihf.cmake b/cmake/Toolchains/arm-linux-gnueabihf.cmake index e7ed3cf7..9c39e356 100644 --- a/cmake/Toolchains/arm-linux-gnueabihf.cmake +++ b/cmake/Toolchains/arm-linux-gnueabihf.cmake @@ -9,19 +9,20 @@ set(CMAKE_SYSTEM_NAME Linux) set(CMAKE_SYSTEM_PROCESSOR arm) -if(MINGW OR CYGWIN OR WIN32) - set(UTIL_SEARCH_CMD where) +if(MINGW + OR CYGWIN + OR WIN32) + set(UTIL_SEARCH_CMD where) elseif(UNIX OR APPLE) - set(UTIL_SEARCH_CMD which) + set(UTIL_SEARCH_CMD which) endif() set(TOOLCHAIN_PREFIX arm-linux-gnueabihf-) execute_process( - COMMAND ${UTIL_SEARCH_CMD} ${TOOLCHAIN_PREFIX}gcc - OUTPUT_VARIABLE BINUTILS_PATH - OUTPUT_STRIP_TRAILING_WHITESPACE - ) + COMMAND ${UTIL_SEARCH_CMD} ${TOOLCHAIN_PREFIX}gcc + OUTPUT_VARIABLE BINUTILS_PATH + OUTPUT_STRIP_TRAILING_WHITESPACE) get_filename_component(ARM_TOOLCHAIN_DIR ${BINUTILS_PATH} DIRECTORY) @@ -33,11 +34,19 @@ set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}gcc) set(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER}) set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}g++) ## the following is needed for CheckCSourceCompiles used in lib/CMakeLists.txt -set(CMAKE_C_FLAGS "-mfpu=neon" CACHE STRING "" FORCE) -set(CMAKE_ASM_FLAGS "${CMAKE_C_FLAGS}" CACHE STRING "" FORCE) - -set(CMAKE_OBJCOPY ${ARM_TOOLCHAIN_DIR}/${TOOLCHAIN_PREFIX}objcopy CACHE INTERNAL "objcopy tool") -set(CMAKE_SIZE_UTIL ${ARM_TOOLCHAIN_DIR}/${TOOLCHAIN_PREFIX}size CACHE INTERNAL "size tool") +set(CMAKE_C_FLAGS + "-mfpu=neon" + CACHE STRING "" FORCE) +set(CMAKE_ASM_FLAGS + "${CMAKE_C_FLAGS}" + CACHE STRING "" FORCE) + +set(CMAKE_OBJCOPY + ${ARM_TOOLCHAIN_DIR}/${TOOLCHAIN_PREFIX}objcopy + CACHE INTERNAL "objcopy tool") +set(CMAKE_SIZE_UTIL + ${ARM_TOOLCHAIN_DIR}/${TOOLCHAIN_PREFIX}size + CACHE INTERNAL "size tool") set(CMAKE_FIND_ROOT_PATH ${BINUTILS_PATH}) diff --git a/cmake/Toolchains/arm_cortex_a15_hardfp_native.cmake b/cmake/Toolchains/arm_cortex_a15_hardfp_native.cmake index 05f4c771..6e0ef4ac 100644 --- a/cmake/Toolchains/arm_cortex_a15_hardfp_native.cmake +++ b/cmake/Toolchains/arm_cortex_a15_hardfp_native.cmake @@ -6,13 +6,18 @@ # SPDX-License-Identifier: LGPL-3.0-or-later # - ######################################################################## # Toolchain file for building native on a ARM Cortex A8 w/ NEON # Usage: cmake -DCMAKE_TOOLCHAIN_FILE= ######################################################################## set(CMAKE_CXX_COMPILER g++) -set(CMAKE_C_COMPILER gcc) -set(CMAKE_CXX_FLAGS "-march=armv7-a -mtune=cortex-a15 -mfpu=neon -mfloat-abi=hard" CACHE STRING "" FORCE) -set(CMAKE_C_FLAGS ${CMAKE_CXX_FLAGS} CACHE STRING "" FORCE) #same flags for C sources -set(CMAKE_ASM_FLAGS "${CMAKE_CXX_FLAGS} -g" CACHE STRING "" FORCE) #same flags for asm sources \ No newline at end of file +set(CMAKE_C_COMPILER gcc) +set(CMAKE_CXX_FLAGS + "-march=armv7-a -mtune=cortex-a15 -mfpu=neon -mfloat-abi=hard" + CACHE STRING "" FORCE) +set(CMAKE_C_FLAGS + ${CMAKE_CXX_FLAGS} + CACHE STRING "" FORCE) #same flags for C sources +set(CMAKE_ASM_FLAGS + "${CMAKE_CXX_FLAGS} -g" + CACHE STRING "" FORCE) #same flags for asm sources diff --git a/cmake/Toolchains/arm_cortex_a53_hardfp_native.cmake b/cmake/Toolchains/arm_cortex_a53_hardfp_native.cmake index 636025a3..becdc426 100644 --- a/cmake/Toolchains/arm_cortex_a53_hardfp_native.cmake +++ b/cmake/Toolchains/arm_cortex_a53_hardfp_native.cmake @@ -11,7 +11,13 @@ # Usage: cmake -DCMAKE_TOOLCHAIN_FILE= ######################################################################## set(CMAKE_CXX_COMPILER g++) -set(CMAKE_C_COMPILER gcc) -set(CMAKE_CXX_FLAGS "-march=armv8-a -mtune=cortex-a53 -mfpu=neon-fp-armv8 -mfloat-abi=hard" CACHE STRING "" FORCE) -set(CMAKE_C_FLAGS ${CMAKE_CXX_FLAGS} CACHE STRING "" FORCE) #same flags for C sources -set(CMAKE_ASM_FLAGS "${CMAKE_CXX_FLAGS} -mthumb -g" CACHE STRING "" FORCE) #same flags for asm sources +set(CMAKE_C_COMPILER gcc) +set(CMAKE_CXX_FLAGS + "-march=armv8-a -mtune=cortex-a53 -mfpu=neon-fp-armv8 -mfloat-abi=hard" + CACHE STRING "" FORCE) +set(CMAKE_C_FLAGS + ${CMAKE_CXX_FLAGS} + CACHE STRING "" FORCE) #same flags for C sources +set(CMAKE_ASM_FLAGS + "${CMAKE_CXX_FLAGS} -mthumb -g" + CACHE STRING "" FORCE) #same flags for asm sources diff --git a/cmake/Toolchains/arm_cortex_a72_hardfp_native.cmake b/cmake/Toolchains/arm_cortex_a72_hardfp_native.cmake index 2551e1b5..97ca3256 100644 --- a/cmake/Toolchains/arm_cortex_a72_hardfp_native.cmake +++ b/cmake/Toolchains/arm_cortex_a72_hardfp_native.cmake @@ -11,7 +11,13 @@ # Usage: cmake -DCMAKE_TOOLCHAIN_FILE= ######################################################################## set(CMAKE_CXX_COMPILER g++) -set(CMAKE_C_COMPILER gcc) -set(CMAKE_CXX_FLAGS "-march=armv8-a -mtune=cortex-a72 -mfpu=neon-fp-armv8 -mfloat-abi=hard" CACHE STRING "" FORCE) -set(CMAKE_C_FLAGS ${CMAKE_CXX_FLAGS} CACHE STRING "" FORCE) #same flags for C sources -set(CMAKE_ASM_FLAGS "${CMAKE_CXX_FLAGS} -mthumb -g" CACHE STRING "" FORCE) #same flags for asm sources +set(CMAKE_C_COMPILER gcc) +set(CMAKE_CXX_FLAGS + "-march=armv8-a -mtune=cortex-a72 -mfpu=neon-fp-armv8 -mfloat-abi=hard" + CACHE STRING "" FORCE) +set(CMAKE_C_FLAGS + ${CMAKE_CXX_FLAGS} + CACHE STRING "" FORCE) #same flags for C sources +set(CMAKE_ASM_FLAGS + "${CMAKE_CXX_FLAGS} -mthumb -g" + CACHE STRING "" FORCE) #same flags for asm sources diff --git a/cmake/Toolchains/arm_cortex_a8_hardfp_native.cmake b/cmake/Toolchains/arm_cortex_a8_hardfp_native.cmake index 588bb0c3..4002baff 100644 --- a/cmake/Toolchains/arm_cortex_a8_hardfp_native.cmake +++ b/cmake/Toolchains/arm_cortex_a8_hardfp_native.cmake @@ -11,7 +11,13 @@ # Usage: cmake -DCMAKE_TOOLCHAIN_FILE= ######################################################################## set(CMAKE_CXX_COMPILER g++) -set(CMAKE_C_COMPILER gcc) -set(CMAKE_CXX_FLAGS "-march=armv7-a -mtune=cortex-a8 -mfpu=neon -mfloat-abi=hard" CACHE STRING "" FORCE) -set(CMAKE_C_FLAGS ${CMAKE_CXX_FLAGS} CACHE STRING "" FORCE) #same flags for C sources -set(CMAKE_ASM_FLAGS "${CMAKE_CXX_FLAGS} -g" CACHE STRING "" FORCE) #same flags for asm sources \ No newline at end of file +set(CMAKE_C_COMPILER gcc) +set(CMAKE_CXX_FLAGS + "-march=armv7-a -mtune=cortex-a8 -mfpu=neon -mfloat-abi=hard" + CACHE STRING "" FORCE) +set(CMAKE_C_FLAGS + ${CMAKE_CXX_FLAGS} + CACHE STRING "" FORCE) #same flags for C sources +set(CMAKE_ASM_FLAGS + "${CMAKE_CXX_FLAGS} -g" + CACHE STRING "" FORCE) #same flags for asm sources diff --git a/cmake/Toolchains/arm_cortex_a8_softfp_native.cmake b/cmake/Toolchains/arm_cortex_a8_softfp_native.cmake index 5cb2018d..95161a27 100644 --- a/cmake/Toolchains/arm_cortex_a8_softfp_native.cmake +++ b/cmake/Toolchains/arm_cortex_a8_softfp_native.cmake @@ -11,7 +11,13 @@ # Usage: cmake -DCMAKE_TOOLCHAIN_FILE= ######################################################################## set(CMAKE_CXX_COMPILER g++) -set(CMAKE_C_COMPILER gcc) -set(CMAKE_CXX_FLAGS "-march=armv7-a -mtune=cortex-a8 -mfpu=neon -mfloat-abi=softfp" CACHE STRING "" FORCE) -set(CMAKE_C_FLAGS ${CMAKE_CXX_FLAGS} CACHE STRING "" FORCE) #same flags for C sources -set(CMAKE_ASM_FLAGS "${CMAKE_CXX_FLAGS} -g" CACHE STRING "" FORCE) #same flags for asm sources \ No newline at end of file +set(CMAKE_C_COMPILER gcc) +set(CMAKE_CXX_FLAGS + "-march=armv7-a -mtune=cortex-a8 -mfpu=neon -mfloat-abi=softfp" + CACHE STRING "" FORCE) +set(CMAKE_C_FLAGS + ${CMAKE_CXX_FLAGS} + CACHE STRING "" FORCE) #same flags for C sources +set(CMAKE_ASM_FLAGS + "${CMAKE_CXX_FLAGS} -g" + CACHE STRING "" FORCE) #same flags for asm sources diff --git a/cmake/Toolchains/arm_cortex_a9_hardfp_native.cmake b/cmake/Toolchains/arm_cortex_a9_hardfp_native.cmake index 7cca24f1..3afa18d1 100644 --- a/cmake/Toolchains/arm_cortex_a9_hardfp_native.cmake +++ b/cmake/Toolchains/arm_cortex_a9_hardfp_native.cmake @@ -11,7 +11,13 @@ # Usage: cmake -DCMAKE_TOOLCHAIN_FILE= ######################################################################## set(CMAKE_CXX_COMPILER g++) -set(CMAKE_C_COMPILER gcc) -set(CMAKE_CXX_FLAGS "-march=armv7-a -mtune=cortex-a9 -mfpu=neon -mfloat-abi=hard" CACHE STRING "" FORCE) -set(CMAKE_C_FLAGS ${CMAKE_CXX_FLAGS} CACHE STRING "" FORCE) #same flags for C sources -set(CMAKE_ASM_FLAGS "${CMAKE_CXX_FLAGS} -g" CACHE STRING "" FORCE) #same flags for asm sources \ No newline at end of file +set(CMAKE_C_COMPILER gcc) +set(CMAKE_CXX_FLAGS + "-march=armv7-a -mtune=cortex-a9 -mfpu=neon -mfloat-abi=hard" + CACHE STRING "" FORCE) +set(CMAKE_C_FLAGS + ${CMAKE_CXX_FLAGS} + CACHE STRING "" FORCE) #same flags for C sources +set(CMAKE_ASM_FLAGS + "${CMAKE_CXX_FLAGS} -g" + CACHE STRING "" FORCE) #same flags for asm sources diff --git a/cmake/Toolchains/intel-sde.cmake b/cmake/Toolchains/intel-sde.cmake index 04f90657..19ae731b 100644 --- a/cmake/Toolchains/intel-sde.cmake +++ b/cmake/Toolchains/intel-sde.cmake @@ -8,4 +8,5 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=knl") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=knl") -set(CMAKE_CROSSCOMPILING_EMULATOR "$ENV{TRAVIS_BUILD_DIR}/cache/$ENV{SDE_VERSION}/sde64 -knl --") +set(CMAKE_CROSSCOMPILING_EMULATOR + "$ENV{TRAVIS_BUILD_DIR}/cache/$ENV{SDE_VERSION}/sde64 -knl --") diff --git a/cmake/Toolchains/oe-sdk_cross.cmake b/cmake/Toolchains/oe-sdk_cross.cmake index b41463a9..e518058e 100644 --- a/cmake/Toolchains/oe-sdk_cross.cmake +++ b/cmake/Toolchains/oe-sdk_cross.cmake @@ -6,18 +6,25 @@ # SPDX-License-Identifier: LGPL-3.0-or-later # -set( CMAKE_SYSTEM_NAME Linux ) +set(CMAKE_SYSTEM_NAME Linux) #set( CMAKE_C_COMPILER $ENV{CC} ) #set( CMAKE_CXX_COMPILER $ENV{CXX} ) -string(REGEX MATCH "sysroots/([a-zA-Z0-9]+)" CMAKE_SYSTEM_PROCESSOR $ENV{SDKTARGETSYSROOT}) +string(REGEX MATCH "sysroots/([a-zA-Z0-9]+)" CMAKE_SYSTEM_PROCESSOR + $ENV{SDKTARGETSYSROOT}) string(REGEX REPLACE "sysroots/" "" CMAKE_SYSTEM_PROCESSOR ${CMAKE_SYSTEM_PROCESSOR}) -set( CMAKE_CXX_FLAGS $ENV{CXXFLAGS} CACHE STRING "" FORCE ) -set( CMAKE_C_FLAGS $ENV{CFLAGS} CACHE STRING "" FORCE ) #same flags for C sources -set( CMAKE_LDFLAGS_FLAGS ${CMAKE_CXX_FLAGS} CACHE STRING "" FORCE ) #same flags for C sources -set( CMAKE_LIBRARY_PATH ${OECORE_TARGET_SYSROOT}/usr/lib ) -set( CMAKE_FIND_ROOT_PATH $ENV{OECORE_TARGET_SYSROOT} $ENV{OECORE_NATIVE_SYSROOT} ) -set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER ) -set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY ) -set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY ) -set ( ORC_INCLUDE_DIRS $ENV{OECORE_TARGET_SYSROOT}/usr/include/orc-0.4 ) -set ( ORC_LIBRARY_DIRS $ENV{OECORE_TARGET_SYSROOT}/usr/lib ) +set(CMAKE_CXX_FLAGS + $ENV{CXXFLAGS} + CACHE STRING "" FORCE) +set(CMAKE_C_FLAGS + $ENV{CFLAGS} + CACHE STRING "" FORCE) #same flags for C sources +set(CMAKE_LDFLAGS_FLAGS + ${CMAKE_CXX_FLAGS} + CACHE STRING "" FORCE) #same flags for C sources +set(CMAKE_LIBRARY_PATH ${OECORE_TARGET_SYSROOT}/usr/lib) +set(CMAKE_FIND_ROOT_PATH $ENV{OECORE_TARGET_SYSROOT} $ENV{OECORE_NATIVE_SYSROOT}) +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +set(ORC_INCLUDE_DIRS $ENV{OECORE_TARGET_SYSROOT}/usr/include/orc-0.4) +set(ORC_LIBRARY_DIRS $ENV{OECORE_TARGET_SYSROOT}/usr/lib) diff --git a/cmake/cmake_uninstall.cmake.in b/cmake/cmake_uninstall.cmake.in index 7ffbc902..1c11ba74 100644 --- a/cmake/cmake_uninstall.cmake.in +++ b/cmake/cmake_uninstall.cmake.in @@ -7,33 +7,36 @@ # http://www.vtk.org/Wiki/CMake_FAQ#Can_I_do_.22make_uninstall.22_with_CMake.3F -IF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") - MESSAGE(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"") -ENDIF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") +if(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") + message( + FATAL_ERROR + "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"" + ) +endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") -FILE(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files) -STRING(REGEX REPLACE "\n" ";" files "${files}") -FOREACH(file ${files}) - MESSAGE(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"") - IF(EXISTS "$ENV{DESTDIR}${file}") - EXEC_PROGRAM( - "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" - OUTPUT_VARIABLE rm_out - RETURN_VALUE rm_retval - ) - IF(NOT "${rm_retval}" STREQUAL 0) - MESSAGE(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"") - ENDIF(NOT "${rm_retval}" STREQUAL 0) - ELSEIF(IS_SYMLINK "$ENV{DESTDIR}${file}") - EXEC_PROGRAM( - "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" - OUTPUT_VARIABLE rm_out - RETURN_VALUE rm_retval - ) - IF(NOT "${rm_retval}" STREQUAL 0) - MESSAGE(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"") - ENDIF(NOT "${rm_retval}" STREQUAL 0) - ELSE(EXISTS "$ENV{DESTDIR}${file}") - MESSAGE(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.") - ENDIF(EXISTS "$ENV{DESTDIR}${file}") -ENDFOREACH(file) +file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files) +string(REGEX REPLACE "\n" ";" files "${files}") +foreach(file ${files}) + message(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"") + if(EXISTS "$ENV{DESTDIR}${file}") + exec_program( + "@CMAKE_COMMAND@" ARGS + "-E remove \"$ENV{DESTDIR}${file}\"" + OUTPUT_VARIABLE rm_out + RETURN_VALUE rm_retval) + if(NOT "${rm_retval}" STREQUAL 0) + message(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"") + endif(NOT "${rm_retval}" STREQUAL 0) + elseif(IS_SYMLINK "$ENV{DESTDIR}${file}") + exec_program( + "@CMAKE_COMMAND@" ARGS + "-E remove \"$ENV{DESTDIR}${file}\"" + OUTPUT_VARIABLE rm_out + RETURN_VALUE rm_retval) + if(NOT "${rm_retval}" STREQUAL 0) + message(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"") + endif(NOT "${rm_retval}" STREQUAL 0) + else(EXISTS "$ENV{DESTDIR}${file}") + message(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.") + endif(EXISTS "$ENV{DESTDIR}${file}") +endforeach(file) diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt index 7c4c5e08..108d5c07 100644 --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt @@ -8,17 +8,16 @@ find_package(Doxygen) if(DOXYGEN_FOUND) -message(STATUS "Doxygen found. Building docs ...") + message(STATUS "Doxygen found. Building docs ...") -configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in - ${CMAKE_BINARY_DIR}/Doxyfile -@ONLY) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_BINARY_DIR}/Doxyfile + @ONLY) -add_custom_target(volk_doc - ${DOXYGEN_EXECUTABLE} ${CMAKE_BINARY_DIR}/Doxyfile - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - COMMENT "Generating documentation with Doxygen" VERBATIM -) + add_custom_target( + volk_doc + ${DOXYGEN_EXECUTABLE} ${CMAKE_BINARY_DIR}/Doxyfile + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + COMMENT "Generating documentation with Doxygen" + VERBATIM) endif(DOXYGEN_FOUND) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 9c4fc134..074f46f8 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -10,22 +10,22 @@ # header file detection ######################################################################## include(CheckIncludeFile) -CHECK_INCLUDE_FILE(cpuid.h HAVE_CPUID_H) +check_include_file(cpuid.h HAVE_CPUID_H) if(HAVE_CPUID_H) add_definitions(-DHAVE_CPUID_H) endif() -CHECK_INCLUDE_FILE(intrin.h HAVE_INTRIN_H) +check_include_file(intrin.h HAVE_INTRIN_H) if(HAVE_INTRIN_H) add_definitions(-DHAVE_INTRIN_H) endif() -CHECK_INCLUDE_FILE(fenv.h HAVE_FENV_H) +check_include_file(fenv.h HAVE_FENV_H) if(HAVE_FENV_H) add_definitions(-DHAVE_FENV_H) endif() -CHECK_INCLUDE_FILE(dlfcn.h HAVE_DLFCN_H) +check_include_file(dlfcn.h HAVE_DLFCN_H) if(HAVE_DLFCN_H) add_definitions(-DHAVE_DLFCN_H) list(APPEND volk_libraries ${CMAKE_DL_LIBS}) @@ -49,7 +49,8 @@ endif() message(STATUS "Compiler name: ${COMPILER_NAME}") if(NOT DEFINED COMPILER_NAME) - message(FATAL_ERROR "COMPILER_NAME undefined. Volk build may not support this compiler.") + message( + FATAL_ERROR "COMPILER_NAME undefined. Volk build may not support this compiler.") endif() ######################################################################## @@ -57,7 +58,8 @@ endif() ######################################################################## if(COMPILER_NAME MATCHES "GNU") include(CheckCXXCompilerFlag) - CHECK_CXX_COMPILER_FLAG("-Werror=unused-command-line-argument" HAVE_WERROR_UNUSED_CMD_LINE_ARG) + check_cxx_compiler_flag("-Werror=unused-command-line-argument" + HAVE_WERROR_UNUSED_CMD_LINE_ARG) if(HAVE_WERROR_UNUSED_CMD_LINE_ARG) set(VOLK_FLAG_CHECK_FLAGS "-Werror=unused-command-line-argument") endif() @@ -75,7 +77,7 @@ endif(HAVE_POSIX_MEMALIGN) ######################################################################## # detect x86 flavor of CPU ######################################################################## -if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "^(i.86|x86|x86_64|amd64|AMD64)$") +if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "^(i.86|x86|x86_64|amd64|AMD64)$") message(STATUS "x86* CPU detected") set(CPU_IS_x86 TRUE) endif() @@ -84,37 +86,39 @@ endif() # determine passing architectures based on compile flag tests ######################################################################## execute_process( - COMMAND ${PYTHON_EXECUTABLE} ${PYTHON_DASH_B} - ${PROJECT_SOURCE_DIR}/gen/volk_compile_utils.py - --mode "arch_flags" --compiler "${COMPILER_NAME}" - OUTPUT_VARIABLE arch_flag_lines OUTPUT_STRIP_TRAILING_WHITESPACE -) + COMMAND + ${PYTHON_EXECUTABLE} ${PYTHON_DASH_B} + ${PROJECT_SOURCE_DIR}/gen/volk_compile_utils.py --mode "arch_flags" --compiler + "${COMPILER_NAME}" + OUTPUT_VARIABLE arch_flag_lines + OUTPUT_STRIP_TRAILING_WHITESPACE) macro(check_arch arch_name) set(flags ${ARGN}) set(have_${arch_name} TRUE) foreach(flag ${flags}) - if (MSVC AND (${flag} STREQUAL "/arch:SSE2" OR ${flag} STREQUAL "/arch:SSE" )) + if(MSVC AND (${flag} STREQUAL "/arch:SSE2" OR ${flag} STREQUAL "/arch:SSE")) # SSE/SSE2 is supported in MSVC since VS 2005 but flag not available when compiling 64-bit so do not check else() include(CheckCXXCompilerFlag) set(have_flag have${flag}) #make the have_flag have nice alphanum chars (just for looks/not necessary) execute_process( - COMMAND ${PYTHON_EXECUTABLE} -c "import re; print(re.sub('\\W', '_', '${have_flag}'))" - OUTPUT_VARIABLE have_flag OUTPUT_STRIP_TRAILING_WHITESPACE - ) + COMMAND ${PYTHON_EXECUTABLE} -c + "import re; print(re.sub('\\W', '_', '${have_flag}'))" + OUTPUT_VARIABLE have_flag + OUTPUT_STRIP_TRAILING_WHITESPACE) if(VOLK_FLAG_CHECK_FLAGS) set(CMAKE_REQUIRED_FLAGS ${VOLK_FLAG_CHECK_FLAGS}) endif() - CHECK_CXX_COMPILER_FLAG(${flag} ${have_flag}) + check_cxx_compiler_flag(${flag} ${have_flag}) unset(CMAKE_REQUIRED_FLAGS) - if (NOT ${have_flag}) + if(NOT ${have_flag}) set(have_${arch_name} FALSE) endif() endif() endforeach() - if (have_${arch_name}) + if(have_${arch_name}) list(APPEND available_archs ${arch_name}) endif() endmacro(check_arch) @@ -130,8 +134,8 @@ macro(OVERRULE_ARCH arch reason) endmacro(OVERRULE_ARCH) macro(FORCE_ARCH arch reason) - message(STATUS "${reason}, Forced arch ${arch}") - list(APPEND available_archs ${arch}) + message(STATUS "${reason}, Forced arch ${arch}") + list(APPEND available_archs ${arch}) endmacro(FORCE_ARCH) ######################################################################## @@ -146,32 +150,36 @@ if(CPU_IS_x86) ######################################################################### # check to see if the compiler/linker works with cvtpi32_ps instrinsic when using AVX - if (CMAKE_SIZEOF_VOID_P EQUAL 4) - file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/test_cvtpi32_ps.c "#include \nint main (void) {__m128 __a; __m64 __b; __m128 foo = _mm_cvtpi32_ps(__a, __b); return (0); }") - execute_process(COMMAND ${CMAKE_C_COMPILER} -mavx -o - ${CMAKE_CURRENT_BINARY_DIR}/test_cvtpi32_ps - ${CMAKE_CURRENT_BINARY_DIR}/test_cvtpi32_ps.c - OUTPUT_QUIET ERROR_QUIET - RESULT_VARIABLE avx_compile_result) + if(CMAKE_SIZEOF_VOID_P EQUAL 4) + file( + WRITE ${CMAKE_CURRENT_BINARY_DIR}/test_cvtpi32_ps.c + "#include \nint main (void) {__m128 __a; __m64 __b; __m128 foo = _mm_cvtpi32_ps(__a, __b); return (0); }" + ) + execute_process( + COMMAND + ${CMAKE_C_COMPILER} -mavx -o ${CMAKE_CURRENT_BINARY_DIR}/test_cvtpi32_ps + ${CMAKE_CURRENT_BINARY_DIR}/test_cvtpi32_ps.c + OUTPUT_QUIET ERROR_QUIET + RESULT_VARIABLE avx_compile_result) if(NOT ${avx_compile_result} EQUAL 0) - OVERRULE_ARCH(avx "Compiler missing cvtpi32_ps instrinsic") + overrule_arch(avx "Compiler missing cvtpi32_ps instrinsic") else() - set(HAVE_AVX_CVTPI32_PS 1) + set(HAVE_AVX_CVTPI32_PS 1) endif() file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/test_cvtpi32_ps - ${CMAKE_CURRENT_BINARY_DIR}/test_cvtpi32_ps.c) + ${CMAKE_CURRENT_BINARY_DIR}/test_cvtpi32_ps.c) else(CMAKE_SIZEOF_VOID_P EQUAL 4) - # 64-bit compilations won't need this command so don't overrule AVX - set(HAVE_AVX_CVTPI32_PS 0) + # 64-bit compilations won't need this command so don't overrule AVX + set(HAVE_AVX_CVTPI32_PS 0) endif(CMAKE_SIZEOF_VOID_P EQUAL 4) # Disable SSE4a if Clang is less than version 3.2 if("${CMAKE_C_COMPILER_ID}" MATCHES "Clang") - # Figure out the version of Clang + # Figure out the version of Clang - if(CMAKE_C_COMPILER_VERSION VERSION_LESS "3.2") - OVERRULE_ARCH(sse4_a "Clang >= 3.2 required for SSE4a") - endif(CMAKE_C_COMPILER_VERSION VERSION_LESS "3.2") + if(CMAKE_C_COMPILER_VERSION VERSION_LESS "3.2") + overrule_arch(sse4_a "Clang >= 3.2 required for SSE4a") + endif(CMAKE_C_COMPILER_VERSION VERSION_LESS "3.2") endif("${CMAKE_C_COMPILER_ID}" MATCHES "Clang") endif(CPU_IS_x86) @@ -185,18 +193,18 @@ endif() ######################################################################## if(NOT CPU_IS_x86) - OVERRULE_ARCH(3dnow "Architecture is not x86 or x86_64") - OVERRULE_ARCH(mmx "Architecture is not x86 or x86_64") - OVERRULE_ARCH(sse "Architecture is not x86 or x86_64") - OVERRULE_ARCH(sse2 "Architecture is not x86 or x86_64") - OVERRULE_ARCH(sse3 "Architecture is not x86 or x86_64") - OVERRULE_ARCH(ssse3 "Architecture is not x86 or x86_64") - OVERRULE_ARCH(sse4_a "Architecture is not x86 or x86_64") - OVERRULE_ARCH(sse4_1 "Architecture is not x86 or x86_64") - OVERRULE_ARCH(sse4_2 "Architecture is not x86 or x86_64") - OVERRULE_ARCH(avx "Architecture is not x86 or x86_64") - OVERRULE_ARCH(avx512f "Architecture is not x86 or x86_64") - OVERRULE_ARCH(avx512cd "Architecture is not x86 or x86_64") + overrule_arch(3dnow "Architecture is not x86 or x86_64") + overrule_arch(mmx "Architecture is not x86 or x86_64") + overrule_arch(sse "Architecture is not x86 or x86_64") + overrule_arch(sse2 "Architecture is not x86 or x86_64") + overrule_arch(sse3 "Architecture is not x86 or x86_64") + overrule_arch(ssse3 "Architecture is not x86 or x86_64") + overrule_arch(sse4_a "Architecture is not x86 or x86_64") + overrule_arch(sse4_1 "Architecture is not x86 or x86_64") + overrule_arch(sse4_2 "Architecture is not x86 or x86_64") + overrule_arch(avx "Architecture is not x86 or x86_64") + overrule_arch(avx512f "Architecture is not x86 or x86_64") + overrule_arch(avx512cd "Architecture is not x86 or x86_64") endif(NOT CPU_IS_x86) ######################################################################## @@ -207,27 +215,30 @@ endif(NOT CPU_IS_x86) include(CheckCSourceCompiles) -check_c_source_compiles("#include \nint main(){ uint8_t *dest; uint8x8_t res; vst1_u8(dest, res); }" - neon_compile_result) +check_c_source_compiles( + "#include \nint main(){ uint8_t *dest; uint8x8_t res; vst1_u8(dest, res); }" + neon_compile_result) if(neon_compile_result) set(CMAKE_REQUIRED_INCLUDES ${PROJECT_SOURCE_DIR}/include) - check_c_source_compiles("#include \n int main(){__VOLK_ASM(\"vrev32.8 q0, q0\");}" - have_neonv7_result ) - check_c_source_compiles("#include \n int main(){__VOLK_ASM(\"sub v1.4s,v1.4s,v1.4s\");}" - have_neonv8_result ) - - if (NOT have_neonv7_result) - OVERRULE_ARCH(neonv7 "Compiler doesn't support neonv7") + check_c_source_compiles( + "#include \n int main(){__VOLK_ASM(\"vrev32.8 q0, q0\");}" + have_neonv7_result) + check_c_source_compiles( + "#include \n int main(){__VOLK_ASM(\"sub v1.4s,v1.4s,v1.4s\");}" + have_neonv8_result) + + if(NOT have_neonv7_result) + overrule_arch(neonv7 "Compiler doesn't support neonv7") endif() - if (NOT have_neonv8_result) - OVERRULE_ARCH(neonv8 "Compiler doesn't support neonv8") + if(NOT have_neonv8_result) + overrule_arch(neonv8 "Compiler doesn't support neonv8") endif() else(neon_compile_result) - OVERRULE_ARCH(neon "Compiler doesn't support NEON") - OVERRULE_ARCH(neonv7 "Compiler doesn't support NEON") - OVERRULE_ARCH(neonv8 "Compiler doesn't support NEON") + overrule_arch(neon "Compiler doesn't support NEON") + overrule_arch(neonv7 "Compiler doesn't support NEON") + overrule_arch(neonv8 "Compiler doesn't support NEON") endif(neon_compile_result) ######################################################################## @@ -235,7 +246,7 @@ endif(neon_compile_result) # since ORC always passes flag detection ######################################################################## if(NOT ORC_FOUND) - OVERRULE_ARCH(orc "ORC support not found") + overrule_arch(orc "ORC support not found") endif() ######################################################################## @@ -245,36 +256,35 @@ endif() if(NOT CROSSCOMPILE_MULTILIB AND CPU_IS_x86) include(CheckTypeSize) check_type_size("void*[8]" SIZEOF_CPU BUILTIN_TYPES_ONLY) - if (${SIZEOF_CPU} EQUAL 64) - OVERRULE_ARCH(32 "CPU width is 64 bits") + if(${SIZEOF_CPU} EQUAL 64) + overrule_arch(32 "CPU width is 64 bits") endif() - if (${SIZEOF_CPU} EQUAL 32) - OVERRULE_ARCH(64 "CPU width is 32 bits") + if(${SIZEOF_CPU} EQUAL 32) + overrule_arch(64 "CPU width is 32 bits") endif() #MSVC 64 bit does not have MMX, overrule it - if (MSVC) - if (${SIZEOF_CPU} EQUAL 64) - OVERRULE_ARCH(mmx "No MMX for Win64") - endif() - FORCE_ARCH(sse "Built-in for MSVC > 2013") - FORCE_ARCH(sse2 "Built-in for MSVC > 2013") + if(MSVC) + if(${SIZEOF_CPU} EQUAL 64) + overrule_arch(mmx "No MMX for Win64") + endif() + force_arch(sse "Built-in for MSVC > 2013") + force_arch(sse2 "Built-in for MSVC > 2013") endif() - endif() -if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "^riscv64$") - message("---- Adding RISC-V ASM files") - message("DEBUG: looking for ASM files in ${CMAKE_SOURCE_DIR}/kernels/volk/asm/riscv") - include_directories(${CMAKE_SOURCE_DIR}/kernels/volk/asm/riscv) - file(GLOB asm_files ${CMAKE_SOURCE_DIR}/kernels/volk/asm/riscv/*.s) - foreach(asm_file ${asm_files}) - list(APPEND volk_sources ${asm_file}) - message(STATUS "Adding source file: ${asm_file}") - endforeach(asm_file) +if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "^riscv64$") + message("---- Adding RISC-V ASM files") + message("DEBUG: looking for ASM files in ${CMAKE_SOURCE_DIR}/kernels/volk/asm/riscv") + include_directories(${CMAKE_SOURCE_DIR}/kernels/volk/asm/riscv) + file(GLOB asm_files ${CMAKE_SOURCE_DIR}/kernels/volk/asm/riscv/*.s) + foreach(asm_file ${asm_files}) + list(APPEND volk_sources ${asm_file}) + message(STATUS "Adding source file: ${asm_file}") + endforeach(asm_file) else() - OVERRULE_ARCH(riscv64 "machine is not riscv64") + overrule_arch(riscv64 "machine is not riscv64") endif() ######################################################################## @@ -286,11 +296,12 @@ message(STATUS "Available architectures: ${available_archs}") # determine available machines given the available architectures ######################################################################## execute_process( - COMMAND ${PYTHON_EXECUTABLE} ${PYTHON_DASH_B} - ${PROJECT_SOURCE_DIR}/gen/volk_compile_utils.py - --mode "machines" --archs "${available_archs}" - OUTPUT_VARIABLE available_machines OUTPUT_STRIP_TRAILING_WHITESPACE -) + COMMAND + ${PYTHON_EXECUTABLE} ${PYTHON_DASH_B} + ${PROJECT_SOURCE_DIR}/gen/volk_compile_utils.py --mode "machines" --archs + "${available_archs}" + OUTPUT_VARIABLE available_machines + OUTPUT_STRIP_TRAILING_WHITESPACE) ######################################################################## # Implement machine overruling for redundant machines: @@ -302,7 +313,8 @@ execute_process( foreach(arch mmx orc 64 32) foreach(machine_name ${available_machines}) string(REPLACE "_${arch}" "" machine_name_no_arch ${machine_name}) - if (${machine_name} STREQUAL ${machine_name_no_arch}) + if(${machine_name} STREQUAL ${machine_name_no_arch}) + else() list(REMOVE_ITEM available_machines ${machine_name_no_arch}) endif() @@ -328,22 +340,29 @@ macro(gen_template tmpl output) add_custom_command( OUTPUT ${output} DEPENDS ${xml_files} ${py_files} ${h_files} ${tmpl} - COMMAND ${PYTHON_EXECUTABLE} ${PYTHON_DASH_B} - ${PROJECT_SOURCE_DIR}/gen/volk_tmpl_utils.py - --input ${tmpl} --output ${output} ${ARGN} - ) + COMMAND + ${PYTHON_EXECUTABLE} ${PYTHON_DASH_B} + ${PROJECT_SOURCE_DIR}/gen/volk_tmpl_utils.py --input ${tmpl} --output + ${output} ${ARGN}) endmacro(gen_template) make_directory(${PROJECT_BINARY_DIR}/include/volk) -gen_template(${PROJECT_SOURCE_DIR}/tmpl/volk.tmpl.h ${PROJECT_BINARY_DIR}/include/volk/volk.h) -gen_template(${PROJECT_SOURCE_DIR}/tmpl/volk.tmpl.c ${PROJECT_BINARY_DIR}/lib/volk.c) -gen_template(${PROJECT_SOURCE_DIR}/tmpl/volk_typedefs.tmpl.h ${PROJECT_BINARY_DIR}/include/volk/volk_typedefs.h) -gen_template(${PROJECT_SOURCE_DIR}/tmpl/volk_cpu.tmpl.h ${PROJECT_BINARY_DIR}/include/volk/volk_cpu.h) -gen_template(${PROJECT_SOURCE_DIR}/tmpl/volk_cpu.tmpl.c ${PROJECT_BINARY_DIR}/lib/volk_cpu.c) -gen_template(${PROJECT_SOURCE_DIR}/tmpl/volk_config_fixed.tmpl.h ${PROJECT_BINARY_DIR}/include/volk/volk_config_fixed.h) -gen_template(${PROJECT_SOURCE_DIR}/tmpl/volk_machines.tmpl.h ${PROJECT_BINARY_DIR}/lib/volk_machines.h) -gen_template(${PROJECT_SOURCE_DIR}/tmpl/volk_machines.tmpl.c ${PROJECT_BINARY_DIR}/lib/volk_machines.c) +gen_template(${PROJECT_SOURCE_DIR}/tmpl/volk.tmpl.h + ${PROJECT_BINARY_DIR}/include/volk/volk.h) +gen_template(${PROJECT_SOURCE_DIR}/tmpl/volk.tmpl.c ${PROJECT_BINARY_DIR}/lib/volk.c) +gen_template(${PROJECT_SOURCE_DIR}/tmpl/volk_typedefs.tmpl.h + ${PROJECT_BINARY_DIR}/include/volk/volk_typedefs.h) +gen_template(${PROJECT_SOURCE_DIR}/tmpl/volk_cpu.tmpl.h + ${PROJECT_BINARY_DIR}/include/volk/volk_cpu.h) +gen_template(${PROJECT_SOURCE_DIR}/tmpl/volk_cpu.tmpl.c + ${PROJECT_BINARY_DIR}/lib/volk_cpu.c) +gen_template(${PROJECT_SOURCE_DIR}/tmpl/volk_config_fixed.tmpl.h + ${PROJECT_BINARY_DIR}/include/volk/volk_config_fixed.h) +gen_template(${PROJECT_SOURCE_DIR}/tmpl/volk_machines.tmpl.h + ${PROJECT_BINARY_DIR}/lib/volk_machines.h) +gen_template(${PROJECT_SOURCE_DIR}/tmpl/volk_machines.tmpl.c + ${PROJECT_BINARY_DIR}/lib/volk_machines.c) set(BASE_CFLAGS NONE) string(TOUPPER ${CMAKE_BUILD_TYPE} CBTU) @@ -351,40 +370,50 @@ message(STATUS "BUILD TYPE = ${CBTU}") message(STATUS "Base cflags = ${CMAKE_C_FLAGS_${CBTU}} ${CMAKE_C_FLAGS}") set(COMPILER_INFO "") if(MSVC) - if(MSVC90) #Visual Studio 9 + if(MSVC90) #Visual Studio 9 set(cmake_c_compiler_version "Microsoft Visual Studio 9.0") elseif(MSVC10) #Visual Studio 10 set(cmake_c_compiler_version "Microsoft Visual Studio 10.0") elseif(MSVC11) #Visual Studio 11 set(cmake_c_compiler_version "Microsoft Visual Studio 11.0") elseif(MSVC12) #Visual Studio 12 - SET(cmake_c_compiler_version "Microsoft Visual Studio 12.0") + set(cmake_c_compiler_version "Microsoft Visual Studio 12.0") elseif(MSVC14) #Visual Studio 14 - SET(cmake_c_compiler_version "Microsoft Visual Studio 14.0") + set(cmake_c_compiler_version "Microsoft Visual Studio 14.0") endif() else() execute_process(COMMAND ${CMAKE_C_COMPILER} --version - OUTPUT_VARIABLE cmake_c_compiler_version) + OUTPUT_VARIABLE cmake_c_compiler_version) endif(MSVC) -set(COMPILER_INFO "${CMAKE_C_COMPILER}:::${CMAKE_C_FLAGS_${GRCBTU}} ${CMAKE_C_FLAGS}\n${CMAKE_CXX_COMPILER}:::${CMAKE_CXX_FLAGS_${GRCBTU}} ${CMAKE_CXX_FLAGS}\n" ) +set(COMPILER_INFO + "${CMAKE_C_COMPILER}:::${CMAKE_C_FLAGS_${GRCBTU}} ${CMAKE_C_FLAGS}\n${CMAKE_CXX_COMPILER}:::${CMAKE_CXX_FLAGS_${GRCBTU}} ${CMAKE_CXX_FLAGS}\n" +) foreach(machine_name ${available_machines}) #generate machine source set(machine_source ${CMAKE_CURRENT_BINARY_DIR}/volk_machine_${machine_name}.c) - gen_template(${PROJECT_SOURCE_DIR}/tmpl/volk_machine_xxx.tmpl.c ${machine_source} ${machine_name}) + gen_template(${PROJECT_SOURCE_DIR}/tmpl/volk_machine_xxx.tmpl.c ${machine_source} + ${machine_name}) #determine machine flags execute_process( - COMMAND ${PYTHON_EXECUTABLE} ${PYTHON_DASH_B} - ${PROJECT_SOURCE_DIR}/gen/volk_compile_utils.py - --mode "machine_flags" --machine "${machine_name}" --compiler "${COMPILER_NAME}" - OUTPUT_VARIABLE ${machine_name}_flags OUTPUT_STRIP_TRAILING_WHITESPACE + COMMAND + ${PYTHON_EXECUTABLE} ${PYTHON_DASH_B} + ${PROJECT_SOURCE_DIR}/gen/volk_compile_utils.py --mode "machine_flags" + --machine "${machine_name}" --compiler "${COMPILER_NAME}" + OUTPUT_VARIABLE ${machine_name}_flags + OUTPUT_STRIP_TRAILING_WHITESPACE) + + message( + STATUS + "BUILD INFO ::: ${machine_name} ::: ${COMPILER_NAME} ::: ${CMAKE_C_FLAGS_${CBTU}} ${CMAKE_C_FLAGS} ${${machine_name}_flags}" + ) + set(COMPILER_INFO + "${COMPILER_INFO}${machine_name}:::${COMPILER_NAME}:::${CMAKE_C_FLAGS_${CBTU}} ${CMAKE_C_FLAGS} ${${machine_name}_flags}\n" ) - - MESSAGE(STATUS "BUILD INFO ::: ${machine_name} ::: ${COMPILER_NAME} ::: ${CMAKE_C_FLAGS_${CBTU}} ${CMAKE_C_FLAGS} ${${machine_name}_flags}") - set(COMPILER_INFO "${COMPILER_INFO}${machine_name}:::${COMPILER_NAME}:::${CMAKE_C_FLAGS_${CBTU}} ${CMAKE_C_FLAGS} ${${machine_name}_flags}\n" ) if(${machine_name}_flags AND NOT MSVC) - set_source_files_properties(${machine_source} PROPERTIES COMPILE_FLAGS "${${machine_name}_flags}") + set_source_files_properties(${machine_source} + PROPERTIES COMPILE_FLAGS "${${machine_name}_flags}") endif() #add to available machine defs @@ -395,11 +424,10 @@ endforeach(machine_name) # Convert to a C string to compile and display properly string(STRIP "${cmake_c_compiler_version}" cmake_c_compiler_version) string(STRIP ${COMPILER_INFO} COMPILER_INFO) -MESSAGE(STATUS "Compiler Version: ${cmake_c_compiler_version}") +message(STATUS "Compiler Version: ${cmake_c_compiler_version}") string(REPLACE "\n" " \\n" cmake_c_compiler_version ${cmake_c_compiler_version}) string(REPLACE "\n" " \\n" COMPILER_INFO ${COMPILER_INFO}) - ######################################################################## # Handle ASM support # on by default, but let users turn it off @@ -412,25 +440,24 @@ set(FULL_C_FLAGS "${CMAKE_C_FLAGS}" "${CMAKE_CXX_COMPILER_ARG1}") # if we find one that matches our current system architecture # set up the assembler flags and include the source files foreach(ARCH ${ASM_ARCHS_AVAILABLE}) - string(REGEX MATCH "${ARCH}" ASM_ARCH "${available_archs}") -if( ASM_ARCH STREQUAL "neonv7" ) - message(STATUS "---- Adding ASM files") # we always use ATT syntax - message(STATUS "-- Detected neon architecture; enabling ASM") - # architecture specific assembler flags are now set in the cmake toolchain file - # then add the files - include_directories(${PROJECT_SOURCE_DIR}/kernels/volk/asm/neon) - file(GLOB asm_files ${PROJECT_SOURCE_DIR}/kernels/volk/asm/neon/*.s) - foreach(asm_file ${asm_files}) - list(APPEND volk_sources ${asm_file}) - message(STATUS "Adding source file: ${asm_file}") - endforeach(asm_file) -endif() -enable_language(ASM) -message(STATUS "c flags: ${FULL_C_FLAGS}") -message(STATUS "asm flags: ${CMAKE_ASM_FLAGS}") + string(REGEX MATCH "${ARCH}" ASM_ARCH "${available_archs}") + if(ASM_ARCH STREQUAL "neonv7") + message(STATUS "---- Adding ASM files") # we always use ATT syntax + message(STATUS "-- Detected neon architecture; enabling ASM") + # architecture specific assembler flags are now set in the cmake toolchain file + # then add the files + include_directories(${PROJECT_SOURCE_DIR}/kernels/volk/asm/neon) + file(GLOB asm_files ${PROJECT_SOURCE_DIR}/kernels/volk/asm/neon/*.s) + foreach(asm_file ${asm_files}) + list(APPEND volk_sources ${asm_file}) + message(STATUS "Adding source file: ${asm_file}") + endforeach(asm_file) + endif() + enable_language(ASM) + message(STATUS "c flags: ${FULL_C_FLAGS}") + message(STATUS "asm flags: ${CMAKE_ASM_FLAGS}") endforeach(ARCH) - ######################################################################## # Handle orc support ######################################################################## @@ -449,9 +476,10 @@ if(ORC_FOUND) #create a rule to generate the source and add to the list of sources add_custom_command( - COMMAND ${ORCC_EXECUTABLE} --include math.h --implementation --include volk/volk_complex.h -o ${orcc_gen} ${orc_file} - DEPENDS ${orc_file} OUTPUT ${orcc_gen} - ) + COMMAND ${ORCC_EXECUTABLE} --include math.h --implementation --include + volk/volk_complex.h -o ${orcc_gen} ${orc_file} + DEPENDS ${orc_file} + OUTPUT ${orcc_gen}) list(APPEND volk_sources ${orcc_gen}) endforeach(orc_file) @@ -469,10 +497,8 @@ message(STATUS "Loading version ${VERSION} into constants...") string(REPLACE "\\" "\\\\" prefix "${prefix}") string(REPLACE "${CMAKE_SOURCE_DIR}" "$BUILD_DIR" COMPILER_INFO "${COMPILER_INFO}") -configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/constants.c.in - ${CMAKE_CURRENT_BINARY_DIR}/constants.c -@ONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/constants.c.in + ${CMAKE_CURRENT_BINARY_DIR}/constants.c @ONLY) list(APPEND volk_sources ${CMAKE_CURRENT_BINARY_DIR}/constants.c) @@ -484,18 +510,14 @@ if(NOT WIN32) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden -Wno-deprecated-declarations") endif() -list(APPEND volk_sources - ${CMAKE_CURRENT_SOURCE_DIR}/volk_prefs.c - ${CMAKE_CURRENT_SOURCE_DIR}/volk_rank_archs.c - ${CMAKE_CURRENT_SOURCE_DIR}/volk_malloc.c - ${volk_gen_sources} -) +list(APPEND volk_sources ${CMAKE_CURRENT_SOURCE_DIR}/volk_prefs.c + ${CMAKE_CURRENT_SOURCE_DIR}/volk_rank_archs.c + ${CMAKE_CURRENT_SOURCE_DIR}/volk_malloc.c ${volk_gen_sources}) #set the machine definitions where applicable set_source_files_properties( - ${CMAKE_CURRENT_BINARY_DIR}/volk.c - ${CMAKE_CURRENT_BINARY_DIR}/volk_machines.c -PROPERTIES COMPILE_DEFINITIONS "${machine_defs}") + ${CMAKE_CURRENT_BINARY_DIR}/volk.c ${CMAKE_CURRENT_BINARY_DIR}/volk_machines.c + PROPERTIES COMPILE_DEFINITIONS "${machine_defs}") if(MSVC) #add compatibility includes for stdint types @@ -512,23 +534,25 @@ endif() #work. There are options starting with CMake 3.13 for using the OBJECT #to propagate this information. add_library(volk_obj OBJECT ${volk_sources}) -target_include_directories(volk_obj +target_include_directories( + volk_obj PRIVATE $ PRIVATE $ PRIVATE $ PRIVATE ${CMAKE_CURRENT_BINARY_DIR} - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} -) + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) if(VOLK_CPU_FEATURES) - set_source_files_properties(volk_cpu.c PROPERTIES COMPILE_DEFINITIONS "VOLK_CPU_FEATURES=1") - target_include_directories(volk_obj - PRIVATE $ - ) + set_source_files_properties(volk_cpu.c PROPERTIES COMPILE_DEFINITIONS + "VOLK_CPU_FEATURES=1") + target_include_directories( + volk_obj + PRIVATE $ + ) endif() #Configure object target properties if(NOT MSVC) - set_target_properties(volk_obj PROPERTIES COMPILE_FLAGS "-fPIC") + set_target_properties(volk_obj PROPERTIES COMPILE_FLAGS "-fPIC") endif() #Add dynamic library @@ -542,36 +566,36 @@ endif() add_library(volk SHARED $) target_link_libraries(volk PUBLIC ${volk_libraries}) if(VOLK_CPU_FEATURES) - target_link_libraries(volk PRIVATE $) + target_link_libraries(volk PRIVATE $) endif() -target_include_directories(volk +target_include_directories( + volk PUBLIC $ PUBLIC $ PUBLIC $ PRIVATE ${CMAKE_CURRENT_BINARY_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PUBLIC $ -) - + PUBLIC $) #Configure target properties if(ORC_FOUND) - target_link_libraries(volk PRIVATE ${ORC_LIBRARIES}) + target_link_libraries(volk PRIVATE ${ORC_LIBRARIES}) endif() if(NOT MSVC) - target_link_libraries(volk PUBLIC m) + target_link_libraries(volk PUBLIC m) endif() set_target_properties(volk PROPERTIES VERSION ${VERSION}) set_target_properties(volk PROPERTIES SOVERSION ${SOVERSION}) set_target_properties(volk PROPERTIES DEFINE_SYMBOL "volk_EXPORTS") #Install locations -install(TARGETS volk - EXPORT VOLK-export - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT "volk_runtime" # .so file - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT "volk_devel" # .lib file - RUNTIME DESTINATION bin COMPONENT "volk_runtime" # .dll file - ) +install( + TARGETS volk + EXPORT VOLK-export + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT "volk_runtime" # .so file + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT "volk_devel" # .lib file + RUNTIME DESTINATION bin COMPONENT "volk_runtime" # .dll file +) #Configure static library # @@ -582,35 +606,36 @@ install(TARGETS volk #include directories is taken as provided; it -might- matter, but #probably doesn't. if(ENABLE_STATIC_LIBS) - add_library(volk_static STATIC $) - target_link_libraries(volk_static PUBLIC ${volk_libraries}) - if(VOLK_CPU_FEATURES) - target_link_libraries(volk_static PRIVATE $) - endif() - if(ORC_FOUND) - target_link_libraries(volk_static PUBLIC ${ORC_LIBRARIES_STATIC}) - endif() - if(NOT ANDROID) - target_link_libraries(volk_static PRIVATE pthread) - endif() - if(NOT MSVC) - target_link_libraries(volk_static PUBLIC m) - endif() - target_include_directories(volk_static - PUBLIC $ - PUBLIC $ - PUBLIC $ - PRIVATE ${CMAKE_CURRENT_BINARY_DIR} - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PUBLIC $ - ) - - set_target_properties(volk_static PROPERTIES OUTPUT_NAME volk) - - install(TARGETS volk_static - EXPORT VOLK-export - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT "volk_devel" - ) + add_library(volk_static STATIC $) + target_link_libraries(volk_static PUBLIC ${volk_libraries}) + if(VOLK_CPU_FEATURES) + target_link_libraries(volk_static + PRIVATE $) + endif() + if(ORC_FOUND) + target_link_libraries(volk_static PUBLIC ${ORC_LIBRARIES_STATIC}) + endif() + if(NOT ANDROID) + target_link_libraries(volk_static PRIVATE pthread) + endif() + if(NOT MSVC) + target_link_libraries(volk_static PUBLIC m) + endif() + target_include_directories( + volk_static + PUBLIC $ + PUBLIC $ + PUBLIC $ + PRIVATE ${CMAKE_CURRENT_BINARY_DIR} + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} + PUBLIC $) + + set_target_properties(volk_static PROPERTIES OUTPUT_NAME volk) + + install( + TARGETS volk_static + EXPORT VOLK-export + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT "volk_devel") endif(ENABLE_STATIC_LIBS) ######################################################################## @@ -621,22 +646,16 @@ if(ENABLE_TESTING) make_directory(${CMAKE_CURRENT_BINARY_DIR}/.unittest) include(VolkAddTest) if(ENABLE_STATIC_LIBS) - VOLK_GEN_TEST(volk_test_all - SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/testqa.cc - ${CMAKE_CURRENT_SOURCE_DIR}/qa_utils.cc - TARGET_DEPS volk_static - ) + volk_gen_test(volk_test_all SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/testqa.cc + ${CMAKE_CURRENT_SOURCE_DIR}/qa_utils.cc TARGET_DEPS volk_static) else() - VOLK_GEN_TEST(volk_test_all - SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/testqa.cc - ${CMAKE_CURRENT_SOURCE_DIR}/qa_utils.cc - TARGET_DEPS volk - ) + volk_gen_test(volk_test_all SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/testqa.cc + ${CMAKE_CURRENT_SOURCE_DIR}/qa_utils.cc TARGET_DEPS volk) endif() foreach(kernel ${h_files}) - get_filename_component(kernel ${kernel} NAME) - string(REPLACE ".h" "" kernel ${kernel}) - VOLK_ADD_TEST(${kernel} volk_test_all) + get_filename_component(kernel ${kernel} NAME) + string(REPLACE ".h" "" kernel ${kernel}) + volk_add_test(${kernel} volk_test_all) endforeach() endif(ENABLE_TESTING) diff --git a/python/volk_modtool/CMakeLists.txt b/python/volk_modtool/CMakeLists.txt index dcc79a5d..5f0f066c 100644 --- a/python/volk_modtool/CMakeLists.txt +++ b/python/volk_modtool/CMakeLists.txt @@ -11,18 +11,15 @@ ######################################################################## include(VolkPython) -VOLK_PYTHON_INSTALL( +volk_python_install( FILES __init__.py cfg.py volk_modtool_generate.py - DESTINATION ${VOLK_PYTHON_DIR}/volk_modtool - COMPONENT "volk" -) + DESTINATION + ${VOLK_PYTHON_DIR}/volk_modtool + COMPONENT + "volk") -VOLK_PYTHON_INSTALL( - PROGRAMS - volk_modtool - DESTINATION ${VOLK_RUNTIME_DIR} - COMPONENT "volk" -) +volk_python_install(PROGRAMS volk_modtool DESTINATION ${VOLK_RUNTIME_DIR} COMPONENT + "volk")