From 11ab1103c591c23c1c9472a45ff8600f85427189 Mon Sep 17 00:00:00 2001 From: Johannes Demel Date: Sun, 15 Jan 2023 12:51:07 +0100 Subject: [PATCH] cmake: Apply cmake-format This commit adds `.cmake-format.py`. It is mostly inspired by the GNU Radio version of it. Steps to reproduce these results: - `pip3 install cmakelang` - `cmake-format --dump-config python > .cmake-format.py` - Modify .cmake-format.py to be close to the GNU Radio version. - `cmake-format -c .cmake-format.py -i $(git ls-files | grep CMakeLists.txt) $(git ls-files | grep .cmake)` Fixes #600 Fixes #423 Signed-off-by: Johannes Demel --- .cmake-format.py | 69 ++ CMakeLists.txt | 312 +++++---- apps/CMakeLists.txt | 88 ++- cmake/Modules/CMakeParseArgumentsCopy.cmake | 35 +- cmake/Modules/FindFILESYSTEM.cmake | 182 ++--- cmake/Modules/FindORC.cmake | 81 +-- cmake/Modules/VolkAddTest.cmake | 51 +- cmake/Modules/VolkBuildTypes.cmake | 186 +++-- cmake/Modules/VolkConfig.cmake.in | 21 +- cmake/Modules/VolkConfigVersion.cmake.in | 4 +- cmake/Modules/VolkPython.cmake | 267 +++---- cmake/Modules/VolkVersion.cmake | 67 +- cmake/Toolchains/aarch64-linux-gnu.cmake | 18 +- cmake/Toolchains/arm-linux-gnueabihf.cmake | 30 +- .../arm_cortex_a15_hardfp_native.cmake | 18 +- .../arm_cortex_a53_hardfp_native.cmake | 17 +- .../arm_cortex_a72_hardfp_native.cmake | 17 +- .../arm_cortex_a8_hardfp_native.cmake | 17 +- .../arm_cortex_a8_softfp_native.cmake | 17 +- .../arm_cortex_a9_hardfp_native.cmake | 17 +- cmake/Toolchains/intel-sde.cmake | 3 +- cmake/Toolchains/oe-sdk_cross.cmake | 38 +- cmake/cmake_uninstall.cmake.in | 57 +- docs/CMakeLists.txt | 15 +- lib/CMakeLists.txt | 652 +++++++++--------- python/volk_modtool/CMakeLists.txt | 25 +- 26 files changed, 1318 insertions(+), 986 deletions(-) create mode 100644 .cmake-format.py diff --git a/.cmake-format.py b/.cmake-format.py new file mode 100644 index 000000000..ac8113bba --- /dev/null +++ b/.cmake-format.py @@ -0,0 +1,69 @@ +# Copyright 2023 Johannes Demel +# SPDX-License-Identifier: LGPL-3.0-or-later + +# ---------------------------------- +# Options affecting listfile parsing +# ---------------------------------- +with section("parse"): + additional_commands = { + "gr_python_install": { + "flags": [], + "kwargs": {"PROGRAMS": "*", "FILES": "*", "DESTINATION": "*"}, + }, + } + + +with section("format"): + # Disable formatting entirely, making cmake-format a no-op + disable = False + + # How wide to allow formatted cmake files + line_width = 80 + + # How many spaces to tab for indent + tab_size = 2 + + # 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 = False + + # 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("markup"): + first_comment_is_literal = True + enable_markup = False + + +with section("lint"): + max_arguments = 6 + max_localvars = 20 + max_statements = 75 diff --git a/CMakeLists.txt b/CMakeLists.txt index d9141b154..a1f29f6ff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,7 +11,11 @@ # 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 +26,6 @@ set(CMAKE_CXX_STANDARD 17) enable_testing() - ######################################################################## # Common compile flags ######################################################################## @@ -31,13 +34,13 @@ enable_testing() include(CheckCXXCompilerFlag) check_cxx_compiler_flag(-fcx-limited-range HAVE_CX_LIMITED_RANGE) if(HAVE_CX_LIMITED_RANGE) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcx-limited-range") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcx-limited-range") endif(HAVE_CX_LIMITED_RANGE) include(CheckCCompilerFlag) check_c_compiler_flag(-fcx-limited-range HAVE_C_LIMITED_RANGE) if(HAVE_C_LIMITED_RANGE) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fcx-limited-range") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fcx-limited-range") endif(HAVE_C_LIMITED_RANGE) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") @@ -45,30 +48,38 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") add_definitions(-D_GLIBCXX_USE_CXX11_ABI=1) if(CMAKE_C_COMPILER_ID MATCHES "Clang|GNU") - # Abort compilation if kernel implementations have inconsistent function - # prototypes, i.e. if - # - # kernel_foo_sse(uint32_t *dst, lv32fc_t *src) - # kernel_foo_avx(uint16_t *dst, lv32fc_t *src) - # - # 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") + # Abort compilation if kernel implementations have inconsistent function + # prototypes, i.e. if + # + # kernel_foo_sse(uint32_t *dst, lv32fc_t *src) + # kernel_foo_avx(uint16_t *dst, lv32fc_t *src) + # + # 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") 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" +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" include(VolkBuildTypes) #select the release build type by default to get optimization flags if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE "Release") - message(STATUS "Build type not specified: defaulting to release.") + 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}.") ######################################################################## @@ -94,26 +105,31 @@ set_version_str(MAJOR) set_version_str(MINOR) set_version_str(MAINT) -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_compile_options(/W1) #reduce warnings - add_compile_options(/wo4309) - add_compile_options(/wd4752) - add_compile_options(/wo4273) - add_compile_options(/wo4838) + 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) + add_compile_options(/wo4273) + add_compile_options(/wo4838) endif(MSVC) ######################################################################## @@ -121,28 +137,43 @@ 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)") +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) else() option(VOLK_CPU_FEATURES "Volk uses cpu_features" OFF) endif() -if (VOLK_CPU_FEATURES) +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") + 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_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) @@ -155,25 +186,29 @@ 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") + message(FATAL_ERROR "Python 3.4 or greater required to build VOLK") endif() # Mako if(NOT MAKO_FOUND) - message(FATAL_ERROR "Mako templates required to build VOLK") + message(FATAL_ERROR "Mako templates required to build VOLK") 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` @@ -181,10 +216,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() ######################################################################## @@ -205,8 +240,8 @@ add_subdirectory(docs) ######################################################################## # Detect /lib versus /lib64 ######################################################################## -if (${CMAKE_INSTALL_LIBDIR} MATCHES lib64) - set(LIB_SUFFIX 64) +if(${CMAKE_INSTALL_LIBDIR} MATCHES lib64) + set(LIB_SUFFIX 64) endif() ######################################################################## @@ -218,128 +253,122 @@ set(exec_prefix "\${prefix}") set(libdir "\${exec_prefix}/lib${LIB_SUFFIX}") 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 lib${LIB_SUFFIX}/pkgconfig - COMPONENT "volk_devel" -) + FILES ${CMAKE_CURRENT_BINARY_DIR}/volk.pc + DESTINATION lib${LIB_SUFFIX}/pkgconfig + COMPONENT "volk_devel") ######################################################################## # Install all headers in the include directories ######################################################################## -set(VOLK_RUNTIME_DIR bin) -set(VOLK_LIBRARY_DIR lib${LIB_SUFFIX}) -set(VOLK_INCLUDE_DIR include) +set(VOLK_RUNTIME_DIR bin) +set(VOLK_LIBRARY_DIR lib${LIB_SUFFIX}) +set(VOLK_INCLUDE_DIR include) install( - DIRECTORY ${CMAKE_SOURCE_DIR}/kernels/volk - DESTINATION include COMPONENT "volk_devel" - FILES_MATCHING PATTERN "*.h" -) + DIRECTORY ${CMAKE_SOURCE_DIR}/kernels/volk + 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 - DESTINATION include/volk - COMPONENT "volk_devel" -) +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") ######################################################################## # On Apple only, set install name and use rpath correctly, if not already set ######################################################################## 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) - 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) - 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) - endif(NOT CMAKE_BUILD_WITH_INSTALL_RPATH) + 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) + 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) + 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) + 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 ######################################################################## if(NOT CMAKE_MODULES_DIR) - set(CMAKE_MODULES_DIR lib${LIB_SUFFIX}/cmake) + set(CMAKE_MODULES_DIR lib${LIB_SUFFIX}/cmake) endif(NOT CMAKE_MODULES_DIR) install( - 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" ) + 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") -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.") else() @@ -350,21 +379,24 @@ 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}") + 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}") + 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") + set(VOLK_CONFIGPATH "$ENV{HOME}/.volk") elseif(DEFINED ENV{APPDATA}) - set(VOLK_CONFIGPATH "$ENV{APPDATA}/.volk") + set(VOLK_CONFIGPATH "$ENV{APPDATA}/.volk") endif() endif() else() diff --git a/apps/CMakeLists.txt b/apps/CMakeLists.txt index db6ab50f1..31cad28ff 100644 --- a/apps/CMakeLists.txt +++ b/apps/CMakeLists.txt @@ -12,80 +12,78 @@ # POSIX_MEMALIGN: If we have to fall back to `posix_memalign`. if(HAVE_POSIX_MEMALIGN) - message(STATUS "Use `posix_memalign` for aligned malloc!") - add_definitions(-DHAVE_POSIX_MEMALIGN) + message(STATUS "Use `posix_memalign` for aligned malloc!") + add_definitions(-DHAVE_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 - PRIVATE $ - PRIVATE $ - PRIVATE $ - PRIVATE $ - PRIVATE ${CMAKE_CURRENT_BINARY_DIR} - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} -) +target_include_directories( + volk_profile + PRIVATE $ + PRIVATE $ + PRIVATE $ + PRIVATE $ + PRIVATE ${CMAKE_CURRENT_BINARY_DIR} + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) add_definitions(-DHAS_STD_FILESYSTEM=1) if(${find_experimental}) - add_definitions(-DHAS_STD_FILESYSTEM_EXPERIMENTAL=1) + add_definitions(-DHAS_STD_FILESYSTEM_EXPERIMENTAL=1) endif() target_link_libraries(volk_profile PRIVATE std::filesystem) if(ENABLE_STATIC_LIBS) - target_link_libraries(volk_profile PRIVATE volk_static) - set_target_properties(volk_profile PROPERTIES LINK_FLAGS "-static") + target_link_libraries(volk_profile PRIVATE volk_static) + set_target_properties(volk_profile PROPERTIES LINK_FLAGS "-static") else() - target_link_libraries(volk_profile PRIVATE volk) + target_link_libraries(volk_profile PRIVATE volk) endif() install( - TARGETS volk_profile - DESTINATION bin - COMPONENT "volk" -) + TARGETS volk_profile + DESTINATION bin + 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) - set_target_properties(volk-config-info PROPERTIES LINK_FLAGS "-static") + target_link_libraries(volk-config-info volk_static) + set_target_properties(volk-config-info PROPERTIES LINK_FLAGS "-static") else() - target_link_libraries(volk-config-info volk) + target_link_libraries(volk-config-info volk) endif() install( - TARGETS volk-config-info - DESTINATION bin - COMPONENT "volk" -) + TARGETS volk-config-info + DESTINATION bin + 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} - COMMAND volk_profile "${VOLK_CONFIG_ARG}" - DEPENDS volk_profile - COMMENT "Launching profiler, this may take a few minutes..." - ) - add_custom_target(volk-profile-run ALL DEPENDS ${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...") + add_custom_target(volk-profile-run ALL DEPENDS ${VOLK_CONFIG}) endif() diff --git a/cmake/Modules/CMakeParseArgumentsCopy.cmake b/cmake/Modules/CMakeParseArgumentsCopy.cmake index a8b8b3148..3dd7b68ba 100644 --- a/cmake/Modules/CMakeParseArgumentsCopy.cmake +++ b/cmake/Modules/CMakeParseArgumentsCopy.cmake @@ -80,14 +80,13 @@ # (To distribute this file outside of CMake, substitute the full # License text for the above reference.) - if(__CMAKE_PARSE_ARGUMENTS_INCLUDED) return() endif() set(__CMAKE_PARSE_ARGUMENTS_INCLUDED TRUE) - -function(CMAKE_PARSE_ARGUMENTS prefix _optionNames _singleArgNames _multiArgNames) +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}) @@ -104,11 +103,17 @@ function(CMAKE_PARSE_ARGUMENTS prefix _optionNames _singleArgNames _multiArgName # 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 + 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( + ${optionIndex} EQUAL -1 + AND ${singleArgIndex} EQUAL -1 + AND ${multiArgIndex} EQUAL -1) if(insideValues) if("${insideValues}" STREQUAL "SINGLE") set(${prefix}_${currentArgName} ${currentArg}) @@ -138,8 +143,18 @@ function(CMAKE_PARSE_ARGUMENTS prefix _optionNames _singleArgNames _multiArgName # propagate the result variables to the caller: foreach(arg_name ${_singleArgNames} ${_multiArgNames} ${_optionNames}) - set(${prefix}_${arg_name} ${${prefix}_${arg_name}} PARENT_SCOPE) + set( + ${prefix}_${arg_name} + ${${prefix}_${arg_name}} + PARENT_SCOPE) endforeach(arg_name) - set(${prefix}_UNPARSED_ARGUMENTS ${${prefix}_UNPARSED_ARGUMENTS} PARENT_SCOPE) + 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 6b92a82a9..f074f9612 100644 --- a/cmake/Modules/FindFILESYSTEM.cmake +++ b/cmake/Modules/FindFILESYSTEM.cmake @@ -104,10 +104,9 @@ Using `find_package(FILESYSTEM)` with no component arguments: #]=======================================================================] - if(TARGET std::filesystem) - # This module has already been processed. Don't do it again. - return() + # This module has already been processed. Don't do it again. + return() endif() include(CMakePushCheckState) @@ -121,141 +120,164 @@ 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_VERSION VERSION_LESS "8.99") - set(UNDEFINED_BEHAVIOR_WITHOUT_LINKING TRUE) - endif() - set(CMAKE_REQUIRED_FLAGS "-std=c++17") +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")) - set(CMAKE_REQUIRED_FLAGS "-std=c++17") +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")) - set(CMAKE_REQUIRED_FLAGS "-std=c++17") +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")) - set(CMAKE_REQUIRED_FLAGS "/std:c++17") + set(CMAKE_REQUIRED_FLAGS "/std:c++17") endif() # Normalize and check the component list we were given set(want_components ${FILESYSTEM_FIND_COMPONENTS}) if(FILESYSTEM_FIND_COMPONENTS STREQUAL "") - set(want_components Final) + set(want_components Final) endif() # Warn on any unrecognized components set(extra_components ${want_components}) list(REMOVE_ITEM extra_components Final Experimental) foreach(component IN LISTS extra_components) - message(WARNING "Extraneous find_package component for FILESYSTEM: ${component}") + message( + WARNING "Extraneous find_package component for FILESYSTEM: ${component}") endforeach() # Detect which of Experimental and Final we should look for set(find_experimental TRUE) set(find_final TRUE) if(NOT "Final" IN_LIST want_components) - set(find_final FALSE) + set(find_final FALSE) endif() if(NOT "Experimental" IN_LIST want_components) - set(find_experimental FALSE) + set(find_experimental FALSE) endif() if(find_final) - check_include_file_cxx("filesystem" _CXX_FILESYSTEM_HAVE_HEADER) - mark_as_advanced(_CXX_FILESYSTEM_HAVE_HEADER) - if(_CXX_FILESYSTEM_HAVE_HEADER) - # We found the non-experimental header. Don't bother looking for the - # experimental one. - set(find_experimental FALSE) - endif() + check_include_file_cxx("filesystem" _CXX_FILESYSTEM_HAVE_HEADER) + mark_as_advanced(_CXX_FILESYSTEM_HAVE_HEADER) + if(_CXX_FILESYSTEM_HAVE_HEADER) + # We found the non-experimental header. Don't bother looking for the + # experimental one. + set(find_experimental FALSE) + endif() else() - set(_CXX_FILESYSTEM_HAVE_HEADER FALSE) + set(_CXX_FILESYSTEM_HAVE_HEADER FALSE) endif() if(find_experimental) - check_include_file_cxx("experimental/filesystem" _CXX_FILESYSTEM_HAVE_EXPERIMENTAL_HEADER) - mark_as_advanced(_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) + set(_CXX_FILESYSTEM_HAVE_EXPERIMENTAL_HEADER FALSE) endif() if(_CXX_FILESYSTEM_HAVE_HEADER) - set(_have_fs TRUE) - set(_fs_header filesystem) - set(_fs_namespace std::filesystem) + set(_have_fs TRUE) + set(_fs_header filesystem) + set(_fs_namespace std::filesystem) elseif(_CXX_FILESYSTEM_HAVE_EXPERIMENTAL_HEADER) - set(_have_fs TRUE) - set(_fs_header experimental/filesystem) - set(_fs_namespace std::experimental::filesystem) + set(_have_fs TRUE) + set(_fs_header experimental/filesystem) + set(_fs_namespace std::experimental::filesystem) else() - set(_have_fs FALSE) + 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 [[ + # We have some filesystem library available. Do link checks + string( + CONFIGURE + [[ #include <@CXX_FILESYSTEM_HEADER@> int main() { auto cwd = @CXX_FILESYSTEM_NAMESPACE@::current_path(); return static_cast(cwd.string().size()); } - ]] code @ONLY) - - # Try to compile a simple filesystem program without any linker flags - if(NOT UNDEFINED_BEHAVIOR_WITHOUT_LINKING) - check_cxx_source_compiles("${code}" CXX_FILESYSTEM_NO_LINK_NEEDED) - set(can_link ${CXX_FILESYSTEM_NO_LINK_NEEDED}) + ]] + code + @ONLY) + + # Try to compile a simple filesystem program without any linker flags + if(NOT UNDEFINED_BEHAVIOR_WITHOUT_LINKING) + check_cxx_source_compiles("${code}" CXX_FILESYSTEM_NO_LINK_NEEDED) + set(can_link ${CXX_FILESYSTEM_NO_LINK_NEEDED}) + endif() + + if(NOT CXX_FILESYSTEM_NO_LINK_NEEDED) + set(prev_libraries ${CMAKE_REQUIRED_LIBRARIES}) + set(CMAKE_REQUIRED_FLAGS "-std=c++17") + # Add the libstdc++ flag + set(CMAKE_REQUIRED_LIBRARIES ${prev_libraries} -lstdc++fs) + check_cxx_source_compiles("${code}" CXX_FILESYSTEM_STDCPPFS_NEEDED) + set(can_link ${CXX_FILESYSTEM_STDCPPFS_NEEDED}) + if(NOT CXX_FILESYSTEM_STDCPPFS_NEEDED) + # Try the libc++ flag + set(CMAKE_REQUIRED_LIBRARIES ${prev_libraries} -lc++fs) + check_cxx_source_compiles("${code}" CXX_FILESYSTEM_CPPFS_NEEDED) + set(can_link ${CXX_FILESYSTEM_CPPFS_NEEDED}) endif() - - if(NOT CXX_FILESYSTEM_NO_LINK_NEEDED) - set(prev_libraries ${CMAKE_REQUIRED_LIBRARIES}) - set(CMAKE_REQUIRED_FLAGS "-std=c++17") - # Add the libstdc++ flag - set(CMAKE_REQUIRED_LIBRARIES ${prev_libraries} -lstdc++fs) - check_cxx_source_compiles("${code}" CXX_FILESYSTEM_STDCPPFS_NEEDED) - set(can_link ${CXX_FILESYSTEM_STDCPPFS_NEEDED}) - if(NOT CXX_FILESYSTEM_STDCPPFS_NEEDED) - # Try the libc++ flag - set(CMAKE_REQUIRED_LIBRARIES ${prev_libraries} -lc++fs) - check_cxx_source_compiles("${code}" CXX_FILESYSTEM_CPPFS_NEEDED) - set(can_link ${CXX_FILESYSTEM_CPPFS_NEEDED}) - endif() + endif() + + if(can_link) + if(CMAKE_VERSION VERSION_LESS 3.12) + add_library(std::filesystem INTERFACE IMPORTED GLOBAL) + else() + add_library(std::filesystem INTERFACE IMPORTED) + target_compile_features(std::filesystem INTERFACE cxx_std_17) endif() - - if(can_link) - if(CMAKE_VERSION VERSION_LESS 3.12) - add_library(std::filesystem INTERFACE IMPORTED GLOBAL) - else() - add_library(std::filesystem INTERFACE IMPORTED) - target_compile_features(std::filesystem INTERFACE cxx_std_17) - endif() - set(_found TRUE) - - if(CXX_FILESYSTEM_NO_LINK_NEEDED) - # Nothing to add... - elseif(CXX_FILESYSTEM_STDCPPFS_NEEDED) - target_link_libraries(std::filesystem INTERFACE -lstdc++fs) - elseif(CXX_FILESYSTEM_CPPFS_NEEDED) - target_link_libraries(std::filesystem INTERFACE -lc++fs) - endif() + set(_found TRUE) + + if(CXX_FILESYSTEM_NO_LINK_NEEDED) + # Nothing to add... + elseif(CXX_FILESYSTEM_STDCPPFS_NEEDED) + target_link_libraries(std::filesystem INTERFACE -lstdc++fs) + elseif(CXX_FILESYSTEM_CPPFS_NEEDED) + target_link_libraries(std::filesystem INTERFACE -lc++fs) endif() + endif() endif() if(NOT ${_found}) - set(CMAKE_CXX_STANDARD ${OLD_CMAKE_CXX_STANDARD}) + set(CMAKE_CXX_STANDARD ${OLD_CMAKE_CXX_STANDARD}) 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") + message(FATAL_ERROR "Cannot compile a simple program using std::filesystem") endif() diff --git a/cmake/Modules/FindORC.cmake b/cmake/Modules/FindORC.cmake index 5b43c98b4..a249f3cdd 100644 --- a/cmake/Modules/FindORC.cmake +++ b/cmake/Modules/FindORC.cmake @@ -5,45 +5,46 @@ # SPDX-License-Identifier: LGPL-3.0-or-later # -FIND_PACKAGE(PkgConfig) -PKG_CHECK_MODULES(PC_ORC "orc-0.4 > 0.4.11") - - - - -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}/lib${LIB_SUFFIX} ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}) - -FIND_LIBRARY(ORC_LIB orc-0.4 - HINTS ${PC_ORC_LIBRARY_DIRS} - PATHS ${ORC_ROOT}/lib${LIB_SUFFIX} ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}) - -FIND_LIBRARY(ORC_LIBRARY_STATIC liborc-0.4.a - HINTS ${PC_ORC_LIBRARY_DIRS} - PATHS ${ORC_ROOT}/lib${LIB_SUFFIX} ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}) - -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") + +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}/lib${LIB_SUFFIX} ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}) + +find_library( + ORC_LIB orc-0.4 + HINTS ${PC_ORC_LIBRARY_DIRS} + PATHS ${ORC_ROOT}/lib${LIB_SUFFIX} ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}) + +find_library( + ORC_LIBRARY_STATIC liborc-0.4.a + HINTS ${PC_ORC_LIBRARY_DIRS} + PATHS ${ORC_ROOT}/lib${LIB_SUFFIX} ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}) + +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 f0a0f47a5..79fdf7ce1 100644 --- a/cmake/Modules/VolkAddTest.cmake +++ b/cmake/Modules/VolkAddTest.cmake @@ -6,7 +6,7 @@ # if(DEFINED __INCLUDED_VOLK_ADD_TEST) - return() + return() endif() set(__INCLUDED_VOLK_ADD_TEST TRUE) @@ -19,10 +19,11 @@ 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}) - add_executable(${executable_name} ${VOLK_TEST_SOURCES}) - target_link_libraries(${executable_name} ${VOLK_TEST_TARGET_DEPS}) + include(CMakeParseArgumentsCopy) + 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() ######################################################################## @@ -43,7 +44,8 @@ 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}) + cmake_parse_arguments(VOLK_TEST "" "" + "TARGET_DEPS;EXTRA_LIB_DIRS;ENVIRONS;ARGS" ${ARGN}) #set the initial environs to use set(environs ${VOLK_TEST_ENVIRONS}) @@ -86,7 +88,10 @@ function(VOLK_ADD_TEST test_name executable_name) #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( + 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") @@ -95,15 +100,19 @@ function(VOLK_ADD_TEST test_name executable_name) 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 - ) + 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" - ) + 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) @@ -130,7 +139,8 @@ function(VOLK_ADD_TEST test_name executable_name) 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") + file(APPEND ${sh_file} + "LL=\"$1\" && for tf in \"\$@\"; do LL=\"\${LL}:\${tf}\"; done\n") endif() #each line sets an environment variable @@ -144,7 +154,9 @@ function(VOLK_ADD_TEST test_name executable_name) 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") + 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}) @@ -152,9 +164,8 @@ function(VOLK_ADD_TEST test_name executable_name) #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} - ) + add_test(NAME qa_${test_name} COMMAND ${SHELL} ${sh_file} + ${TARGET_DIR_LIST}) endif(UNIX) @@ -200,9 +211,7 @@ function(VOLK_ADD_TEST test_name executable_name) 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} - ) + 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 a65beae42..79bfbef32 100644 --- a/cmake/Modules/VolkBuildTypes.cmake +++ b/cmake/Modules/VolkBuildTypes.cmake @@ -6,7 +6,7 @@ # if(DEFINED __INCLUDED_VOLK_BUILD_TYPES_CMAKE) - return() + return() endif() set(__INCLUDED_VOLK_BUILD_TYPES_CMAKE TRUE) @@ -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) + string(TOUPPER ${settype} _settype) foreach(btype ${AVAIL_BUILDTYPES}) - STRING(TOUPPER ${btype} _btype) + 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}") + message( + FATAL_ERROR + "Build type '${settype}' not valid, must be one of: ${AVAIL_BUILDTYPES}") endfunction(VOLK_CHECK_BUILD_TYPE) ######################################################################## @@ -64,25 +74,33 @@ 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( + 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 - CMAKE_SHARED_LINKER_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 +113,33 @@ 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( + 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 - CMAKE_SHARED_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 +153,31 @@ 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( + 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 - CMAKE_SHARED_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 +191,29 @@ 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( + 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 - CMAKE_SHARED_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 +226,18 @@ 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 -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 -fno-omit-frame-pointer" CACHE STRING - "Flags used by the C compiler during Address Sanitized builds." FORCE) - MARK_AS_ADVANCED( + set( CMAKE_CXX_FLAGS_ASAN + "-Wall -Wextra -g -O2 -fsanitize=address -fno-omit-frame-pointer" + CACHE STRING + "Flags used by the C++ compiler during Address Sanitized builds." + FORCE) + set( CMAKE_C_FLAGS_ASAN - CMAKE_EXE_LINKER_FLAGS_DEBUGPARANOID - CMAKE_SHARED_LINKER_DEBUGPARANOID) + "-Wall -Wextra -g -O2 -fsanitize=address -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 f18e07fa1..4e24388b3 100644 --- a/cmake/Modules/VolkConfig.cmake.in +++ b/cmake/Modules/VolkConfig.cmake.in @@ -22,20 +22,31 @@ 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) + 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) + 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) + 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 b97d25d95..96d8e7b36 100644 --- a/cmake/Modules/VolkConfigVersion.cmake.in +++ b/cmake/Modules/VolkConfigVersion.cmake.in @@ -14,8 +14,8 @@ 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 + set(PACKAGE_VERSION_EXACT 1) # exact match for API version + set(PACKAGE_VERSION_COMPATIBLE 1) # compat for minor/patch version endif() endif() endif() diff --git a/cmake/Modules/VolkPython.cmake b/cmake/Modules/VolkPython.cmake index b58519d51..66520b2f6 100644 --- a/cmake/Modules/VolkPython.cmake +++ b/cmake/Modules/VolkPython.cmake @@ -6,7 +6,7 @@ # if(DEFINED __INCLUDED_VOLK_PYTHON_CMAKE) - return() + return() endif() set(__INCLUDED_VOLK_PYTHON_CMAKE TRUE) @@ -35,28 +35,30 @@ set(__INCLUDED_VOLK_PYTHON_CMAKE TRUE) if(PYTHON_EXECUTABLE) - set(PYTHONINTERP_FOUND TRUE) + 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 - set(Python_ADDITIONAL_VERSIONS 3.4 3.5 3.6 3.7 3.8) - find_package(PythonInterp 3) + #use the built-in find script + set(Python_ADDITIONAL_VERSIONS 3.4 3.5 3.6 3.7 3.8) + find_package(PythonInterp 3) - #and if that fails use the find program routine - if(NOT PYTHONINTERP_FOUND) - find_program(PYTHON_EXECUTABLE NAMES python3 python) - if(PYTHON_EXECUTABLE) - set(PYTHONINTERP_FOUND TRUE) - endif(PYTHON_EXECUTABLE) - endif(NOT PYTHONINTERP_FOUND) + #and if that fails use the find program routine + if(NOT PYTHONINTERP_FOUND) + find_program(PYTHON_EXECUTABLE NAMES python3 python) + if(PYTHON_EXECUTABLE) + set(PYTHONINTERP_FOUND TRUE) + endif(PYTHON_EXECUTABLE) + endif(NOT PYTHONINTERP_FOUND) 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: @@ -66,10 +68,11 @@ set(PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE} CACHE FILEPATH "python interpreter") # - have the result variable to set ######################################################################## macro(VOLK_PYTHON_CHECK_MODULE desc mod cmd have) - message(STATUS "") - message(STATUS "Python checking for ${desc}") - execute_process( - COMMAND ${PYTHON_EXECUTABLE} -c " + message(STATUS "") + message(STATUS "Python checking for ${desc}") + execute_process( + COMMAND + ${PYTHON_EXECUTABLE} -c " ######################################### try: import ${mod} except: @@ -78,15 +81,14 @@ except: try: assert ${cmd} except: exit(-1) #########################################" - RESULT_VARIABLE ${have} - ) - if(${have} EQUAL 0) - message(STATUS "Python checking for ${desc} - found") - set(${have} TRUE) - else(${have} EQUAL 0) - message(STATUS "Python checking for ${desc} - not found") - set(${have} FALSE) - endif(${have} EQUAL 0) + RESULT_VARIABLE ${have}) + if(${have} EQUAL 0) + message(STATUS "Python checking for ${desc} - found") + set(${have} TRUE) + else(${have} EQUAL 0) + message(STATUS "Python checking for ${desc} - not found") + set(${have} FALSE) + endif(${have} EQUAL 0) endmacro(VOLK_PYTHON_CHECK_MODULE) ######################################################################## @@ -96,8 +98,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 @@ -129,8 +132,7 @@ 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_VARIABLE VOLK_PYTHON_DIR) endif() file(TO_CMAKE_PATH ${VOLK_PYTHON_DIR} VOLK_PYTHON_DIR) @@ -139,123 +141,134 @@ file(TO_CMAKE_PATH ${VOLK_PYTHON_DIR} VOLK_PYTHON_DIR) # Usage: VOLK_UNIQUE_TARGET( ) ######################################################################## 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 + file(RELATIVE_PATH reldir ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}) + 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) - add_custom_target(${_target} ALL DEPENDS ${ARGN}) + OUTPUT_VARIABLE _target + OUTPUT_STRIP_TRAILING_WHITESPACE) + add_custom_target(${_target} ALL DEPENDS ${ARGN}) endfunction(VOLK_UNIQUE_TARGET) ######################################################################## # Install python sources (also builds and installs byte-compiled python) ######################################################################## function(VOLK_PYTHON_INSTALL) - include(CMakeParseArgumentsCopy) - CMAKE_PARSE_ARGUMENTS(VOLK_PYTHON_INSTALL "" "DESTINATION;COMPONENT" "FILES;PROGRAMS" ${ARGN}) + include(CMakeParseArgumentsCopy) + cmake_parse_arguments(VOLK_PYTHON_INSTALL "" "DESTINATION;COMPONENT" + "FILES;PROGRAMS" ${ARGN}) + #################################################################### + if(VOLK_PYTHON_INSTALL_FILES) #################################################################### - if(VOLK_PYTHON_INSTALL_FILES) - #################################################################### - install(${ARGN}) #installs regular python files - - #create a list of all generated files - unset(pysrcfiles) - unset(pycfiles) - unset(pyofiles) - foreach(pyfile ${VOLK_PYTHON_INSTALL_FILES}) - get_filename_component(pyfile ${pyfile} ABSOLUTE) - list(APPEND pysrcfiles ${pyfile}) - - #determine if this file is in the source or binary directory - file(RELATIVE_PATH source_rel_path ${CMAKE_CURRENT_SOURCE_DIR} ${pyfile}) - string(LENGTH "${source_rel_path}" source_rel_path_len) - file(RELATIVE_PATH binary_rel_path ${CMAKE_CURRENT_BINARY_DIR} ${pyfile}) - string(LENGTH "${binary_rel_path}" binary_rel_path_len) - - #and set the generated path appropriately - if(${source_rel_path_len} GREATER ${binary_rel_path_len}) - set(pygenfile ${CMAKE_CURRENT_BINARY_DIR}/${binary_rel_path}) - else() - set(pygenfile ${CMAKE_CURRENT_BINARY_DIR}/${source_rel_path}) - endif() - list(APPEND pycfiles ${pygenfile}c) - list(APPEND pyofiles ${pygenfile}o) - - #ensure generation path exists - get_filename_component(pygen_path ${pygenfile} PATH) - file(MAKE_DIRECTORY ${pygen_path}) - - endforeach(pyfile) - - #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} - ) - - #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} - ) - - #create install rule and add generated files to target list - set(python_install_gen_targets ${pycfiles} ${pyofiles}) - install(FILES ${python_install_gen_targets} - DESTINATION ${VOLK_PYTHON_INSTALL_DESTINATION} - COMPONENT ${VOLK_PYTHON_INSTALL_COMPONENT} - ) - + install(${ARGN}) #installs regular python files + + #create a list of all generated files + unset(pysrcfiles) + unset(pycfiles) + unset(pyofiles) + foreach(pyfile ${VOLK_PYTHON_INSTALL_FILES}) + get_filename_component(pyfile ${pyfile} ABSOLUTE) + list(APPEND pysrcfiles ${pyfile}) + + #determine if this file is in the source or binary directory + file(RELATIVE_PATH source_rel_path ${CMAKE_CURRENT_SOURCE_DIR} ${pyfile}) + string(LENGTH "${source_rel_path}" source_rel_path_len) + file(RELATIVE_PATH binary_rel_path ${CMAKE_CURRENT_BINARY_DIR} ${pyfile}) + string(LENGTH "${binary_rel_path}" binary_rel_path_len) + + #and set the generated path appropriately + if(${source_rel_path_len} GREATER ${binary_rel_path_len}) + set(pygenfile ${CMAKE_CURRENT_BINARY_DIR}/${binary_rel_path}) + else() + set(pygenfile ${CMAKE_CURRENT_BINARY_DIR}/${source_rel_path}) + endif() + list(APPEND pycfiles ${pygenfile}c) + list(APPEND pyofiles ${pygenfile}o) + + #ensure generation path exists + get_filename_component(pygen_path ${pygenfile} PATH) + file(MAKE_DIRECTORY ${pygen_path}) + + endforeach(pyfile) + + #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}) + + #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}) + + #create install rule and add generated files to target list + set(python_install_gen_targets ${pycfiles} ${pyofiles}) + install( + FILES ${python_install_gen_targets} + DESTINATION ${VOLK_PYTHON_INSTALL_DESTINATION} + COMPONENT ${VOLK_PYTHON_INSTALL_COMPONENT}) #################################################################### - elseif(VOLK_PYTHON_INSTALL_PROGRAMS) + elseif(VOLK_PYTHON_INSTALL_PROGRAMS) #################################################################### - file(TO_NATIVE_PATH ${PYTHON_EXECUTABLE} pyexe_native) - - 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") - 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())" - COMMENT "Shebangin ${pyfile_name}" - VERBATIM - ) - - #on windows, python files need an extension to execute - get_filename_component(pyfile_ext ${pyfile} EXT) - if(WIN32 AND NOT pyfile_ext) - set(pyfile_name "${pyfile_name}.py") - endif() - - install(PROGRAMS ${pyexefile} RENAME ${pyfile_name} - DESTINATION ${VOLK_PYTHON_INSTALL_DESTINATION} - COMPONENT ${VOLK_PYTHON_INSTALL_COMPONENT} - ) - endforeach(pyfile) + file(TO_NATIVE_PATH ${PYTHON_EXECUTABLE} pyexe_native) + if(CMAKE_CROSSCOMPILING) + set(pyexe_native "/usr/bin/env python") endif() - VOLK_UNIQUE_TARGET("pygen" ${python_install_gen_targets}) + 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") + 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())" + COMMENT "Shebangin ${pyfile_name}" + VERBATIM) + + #on windows, python files need an extension to execute + get_filename_component(pyfile_ext ${pyfile} EXT) + if(WIN32 AND NOT pyfile_ext) + set(pyfile_name "${pyfile_name}.py") + endif() + + install( + PROGRAMS ${pyexefile} + RENAME ${pyfile_name} + DESTINATION ${VOLK_PYTHON_INSTALL_DESTINATION} + COMPONENT ${VOLK_PYTHON_INSTALL_COMPONENT}) + endforeach(pyfile) + + endif() + + 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 8be9d2535..97c666abc 100644 --- a/cmake/Modules/VolkVersion.cmake +++ b/cmake/Modules/VolkVersion.cmake @@ -6,7 +6,7 @@ # if(DEFINED __INCLUDED_VOLK_VERSION_CMAKE) - return() + return() endif() set(__INCLUDED_VOLK_VERSION_CMAKE TRUE) @@ -21,12 +21,12 @@ set(MAINT_VERSION ${VERSION_INFO_MAINT_VERSION}) find_package(Git) 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} - ) + 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}) else() if(NOT VOLK_GIT_COUNT) set(VOLK_GIT_COUNT "0") @@ -36,38 +36,39 @@ else() 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() ######################################################################## # Use the logic below to set the version constants ######################################################################## if("${MINOR_VERSION}" STREQUAL "git") - # VERSION: 1.0git-xxx-gxxxxxxxx - # 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(RC_MINOR_VERSION "0") - set(RC_MAINT_VERSION "0") + # VERSION: 1.0git-xxx-gxxxxxxxx + # 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(RC_MINOR_VERSION "0") + set(RC_MAINT_VERSION "0") elseif("${MAINT_VERSION}" STREQUAL "git") - # VERSION: 1.xgit-xxx-gxxxxxxxx - # 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}") - math(EXPR RC_MINOR_VERSION "${MINOR_VERSION} - 1") - set(RC_MAINT_VERSION "0") + # VERSION: 1.xgit-xxx-gxxxxxxxx + # 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}") + math(EXPR RC_MINOR_VERSION "${MINOR_VERSION} - 1") + set(RC_MAINT_VERSION "0") else() - # This is a numbered release. - # VERSION: 1.1{.x} - # DOCVER: 1.1{.x} - # SOVERSION: 1.1.0 - set(VERSION "${MAJOR_VERSION}.${MINOR_VERSION}.${MAINT_VERSION}") - set(DOCVER "${VERSION}") - set(SOVERSION "${MAJOR_VERSION}.${MINOR_VERSION}") - set(RC_MINOR_VERSION ${MINOR_VERSION}) - set(RC_MAINT_VERSION ${MAINT_VERSION}) + # This is a numbered release. + # VERSION: 1.1{.x} + # DOCVER: 1.1{.x} + # SOVERSION: 1.1.0 + set(VERSION "${MAJOR_VERSION}.${MINOR_VERSION}.${MAINT_VERSION}") + set(DOCVER "${VERSION}") + set(SOVERSION "${MAJOR_VERSION}.${MINOR_VERSION}") + set(RC_MINOR_VERSION ${MINOR_VERSION}) + set(RC_MAINT_VERSION ${MAINT_VERSION}) endif() diff --git a/cmake/Toolchains/aarch64-linux-gnu.cmake b/cmake/Toolchains/aarch64-linux-gnu.cmake index d6e53959a..daa00de4c 100644 --- a/cmake/Toolchains/aarch64-linux-gnu.cmake +++ b/cmake/Toolchains/aarch64-linux-gnu.cmake @@ -9,7 +9,10 @@ set(CMAKE_SYSTEM_NAME Linux) set(CMAKE_SYSTEM_PROCESSOR aarch64) -if(MINGW OR CYGWIN OR WIN32) +if( + MINGW + OR CYGWIN + OR WIN32) set(UTIL_SEARCH_CMD where) elseif(UNIX OR APPLE) set(UTIL_SEARCH_CMD which) @@ -20,8 +23,7 @@ set(TOOLCHAIN_PREFIX aarch64-linux-gnu-) execute_process( COMMAND ${UTIL_SEARCH_CMD} ${TOOLCHAIN_PREFIX}gcc OUTPUT_VARIABLE BINUTILS_PATH - OUTPUT_STRIP_TRAILING_WHITESPACE - ) + OUTPUT_STRIP_TRAILING_WHITESPACE) get_filename_component(ARM_TOOLCHAIN_DIR ${BINUTILS_PATH} DIRECTORY) @@ -33,8 +35,14 @@ 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 e7ed3cf7e..5055f2791 100644 --- a/cmake/Toolchains/arm-linux-gnueabihf.cmake +++ b/cmake/Toolchains/arm-linux-gnueabihf.cmake @@ -9,7 +9,10 @@ set(CMAKE_SYSTEM_NAME Linux) set(CMAKE_SYSTEM_PROCESSOR arm) -if(MINGW OR CYGWIN OR WIN32) +if( + MINGW + OR CYGWIN + OR WIN32) set(UTIL_SEARCH_CMD where) elseif(UNIX OR APPLE) set(UTIL_SEARCH_CMD which) @@ -20,8 +23,7 @@ set(TOOLCHAIN_PREFIX arm-linux-gnueabihf-) execute_process( COMMAND ${UTIL_SEARCH_CMD} ${TOOLCHAIN_PREFIX}gcc OUTPUT_VARIABLE BINUTILS_PATH - OUTPUT_STRIP_TRAILING_WHITESPACE - ) + OUTPUT_STRIP_TRAILING_WHITESPACE) get_filename_component(ARM_TOOLCHAIN_DIR ${BINUTILS_PATH} DIRECTORY) @@ -33,11 +35,23 @@ 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 05f4c7713..35ebde1c5 100644 --- a/cmake/Toolchains/arm_cortex_a15_hardfp_native.cmake +++ b/cmake/Toolchains/arm_cortex_a15_hardfp_native.cmake @@ -6,13 +6,21 @@ # 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 636025a33..4b548327a 100644 --- a/cmake/Toolchains/arm_cortex_a53_hardfp_native.cmake +++ b/cmake/Toolchains/arm_cortex_a53_hardfp_native.cmake @@ -11,7 +11,16 @@ # 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 2551e1b5d..8c81159c8 100644 --- a/cmake/Toolchains/arm_cortex_a72_hardfp_native.cmake +++ b/cmake/Toolchains/arm_cortex_a72_hardfp_native.cmake @@ -11,7 +11,16 @@ # 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 588bb0c3b..44f5e247c 100644 --- a/cmake/Toolchains/arm_cortex_a8_hardfp_native.cmake +++ b/cmake/Toolchains/arm_cortex_a8_hardfp_native.cmake @@ -11,7 +11,16 @@ # 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 5cb2018d3..f61898175 100644 --- a/cmake/Toolchains/arm_cortex_a8_softfp_native.cmake +++ b/cmake/Toolchains/arm_cortex_a8_softfp_native.cmake @@ -11,7 +11,16 @@ # 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 7cca24f14..bdbb3c89b 100644 --- a/cmake/Toolchains/arm_cortex_a9_hardfp_native.cmake +++ b/cmake/Toolchains/arm_cortex_a9_hardfp_native.cmake @@ -11,7 +11,16 @@ # 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 04f90657b..19ae731b0 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 b41463a91..d4e193397 100644 --- a/cmake/Toolchains/oe-sdk_cross.cmake +++ b/cmake/Toolchains/oe-sdk_cross.cmake @@ -6,18 +6,30 @@ # 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 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 ) +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) diff --git a/cmake/cmake_uninstall.cmake.in b/cmake/cmake_uninstall.cmake.in index 7ffbc902a..ed64a4cfc 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}\"" +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}\"" + 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) + 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 7c4c5e08b..174e42205 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 + add_custom_target( + volk_doc ${DOXYGEN_EXECUTABLE} ${CMAKE_BINARY_DIR}/Doxyfile WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - COMMENT "Generating documentation with Doxygen" VERBATIM -) + COMMENT "Generating documentation with Doxygen" + VERBATIM) endif(DOXYGEN_FOUND) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index a27be22b4..50449ffac 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -10,25 +10,25 @@ # 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) + 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) + 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) + 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}) + add_definitions(-DHAVE_DLFCN_H) + list(APPEND volk_libraries ${CMAKE_DL_LIBS}) endif() ######################################################################## @@ -36,31 +36,34 @@ endif() ######################################################################## set(COMPILER_NAME ${CMAKE_C_COMPILER_ID}) if(MSVC) #its not set otherwise - set(COMPILER_NAME MSVC) + set(COMPILER_NAME MSVC) endif() # Assume "AppleClang == Clang". string(TOLOWER ${COMPILER_NAME} COMPILER_NAME_LOWER) string(REGEX MATCH "clang" COMPILER_NAME_LOWER ${COMPILER_NAME_LOWER}) if(${COMPILER_NAME_LOWER} MATCHES "clang") - set(COMPILER_NAME "Clang") + set(COMPILER_NAME "Clang") 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() ######################################################################## # Special clang flag so flag checks can fail ######################################################################## if(COMPILER_NAME MATCHES "GNU") - include(CheckCXXCompilerFlag) - 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() + include(CheckCXXCompilerFlag) + 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() endif() ######################################################################## @@ -68,65 +71,67 @@ endif() # make it known to the compiler. ######################################################################## if(HAVE_POSIX_MEMALIGN) - message(STATUS "Use `posix_memalign` for aligned malloc!") - add_definitions(-DHAVE_POSIX_MEMALIGN) + message(STATUS "Use `posix_memalign` for aligned malloc!") + add_definitions(-DHAVE_POSIX_MEMALIGN) endif(HAVE_POSIX_MEMALIGN) ######################################################################## # detect x86 flavor of CPU ######################################################################## -if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "^(i.86|x86|x86_64|amd64|AMD64)$") - message(STATUS "x86* CPU detected") - set(CPU_IS_x86 TRUE) +if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "^(i.86|x86|x86_64|amd64|AMD64)$") + message(STATUS "x86* CPU detected") + set(CPU_IS_x86 TRUE) 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" )) - # 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 - ) - if(VOLK_FLAG_CHECK_FLAGS) - set(CMAKE_REQUIRED_FLAGS ${VOLK_FLAG_CHECK_FLAGS}) - endif() - CHECK_CXX_COMPILER_FLAG(${flag} ${have_flag}) - unset(CMAKE_REQUIRED_FLAGS) - if (NOT ${have_flag}) - set(have_${arch_name} FALSE) - endif() - endif() - endforeach() - if (have_${arch_name}) - list(APPEND available_archs ${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")) + # 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) + if(VOLK_FLAG_CHECK_FLAGS) + set(CMAKE_REQUIRED_FLAGS ${VOLK_FLAG_CHECK_FLAGS}) + endif() + check_cxx_compiler_flag(${flag} ${have_flag}) + unset(CMAKE_REQUIRED_FLAGS) + if(NOT ${have_flag}) + set(have_${arch_name} FALSE) + endif() endif() + endforeach() + if(have_${arch_name}) + list(APPEND available_archs ${arch_name}) + endif() endmacro(check_arch) foreach(line ${arch_flag_lines}) - string(REGEX REPLACE "," ";" arch_flags ${line}) - check_arch(${arch_flags}) + string(REGEX REPLACE "," ";" arch_flags ${line}) + check_arch(${arch_flags}) endforeach(line) macro(OVERRULE_ARCH arch reason) - message(STATUS "${reason}, Overruled arch ${arch}") - list(REMOVE_ITEM available_archs ${arch}) + message(STATUS "${reason}, Overruled arch ${arch}") + list(REMOVE_ITEM available_archs ${arch}) endmacro(OVERRULE_ARCH) macro(FORCE_ARCH arch reason) @@ -141,43 +146,47 @@ endmacro(FORCE_ARCH) ######################################################################## set(HAVE_AVX_CVTPI32_PS 0) if(CPU_IS_x86) - ######################################################################### - # eliminate AVX if cvtpi32_ps intrinsic fails like some versions of clang - ######################################################################### - - # 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(NOT ${avx_compile_result} EQUAL 0) - OVERRULE_ARCH(avx "Compiler missing cvtpi32_ps instrinsic") - else() - set(HAVE_AVX_CVTPI32_PS 1) - endif() - file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/test_cvtpi32_ps - ${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) - 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 - - 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") + ######################################################################### + # eliminate AVX if cvtpi32_ps intrinsic fails like some versions of clang + ######################################################################### + + # 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(NOT ${avx_compile_result} EQUAL 0) + overrule_arch(avx "Compiler missing cvtpi32_ps instrinsic") + else() + set(HAVE_AVX_CVTPI32_PS 1) + endif() + file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/test_cvtpi32_ps + ${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) + 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 + + 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) if(${HAVE_AVX_CVTPI32_PS}) - add_definitions(-DHAVE_AVX_CVTPI32_PS) + add_definitions(-DHAVE_AVX_CVTPI32_PS) endif() ######################################################################## @@ -185,18 +194,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 +216,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 __VOLK_VOLATILE(\"vrev32.8 q0, q0\");}" - have_neonv7_result ) - check_c_source_compiles("#include \n int main(){__VOLK_ASM __VOLK_VOLATILE(\"sub v1.4s,v1.4s,v1.4s\");}" - have_neonv8_result ) - - if (NOT have_neonv7_result) - OVERRULE_ARCH(neonv7 "Compiler doesn't support neonv7") - endif() + set(CMAKE_REQUIRED_INCLUDES ${PROJECT_SOURCE_DIR}/include) + check_c_source_compiles( + "#include \n int main(){__VOLK_ASM __VOLK_VOLATILE(\"vrev32.8 q0, q0\");}" + have_neonv7_result) + check_c_source_compiles( + "#include \n int main(){__VOLK_ASM __VOLK_VOLATILE(\"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") - endif() + 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 +247,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() ######################################################################## @@ -243,30 +255,31 @@ endif() # this makes things work when both -m32 and -m64 pass ######################################################################## 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") - endif() - if (${SIZEOF_CPU} EQUAL 32) - OVERRULE_ARCH(64 "CPU width is 32 bits") - endif() + 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") + endif() + 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") + #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") + endif() endif() -if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "^riscv64$") +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") + 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}) @@ -274,7 +287,7 @@ if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "^riscv64$") 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 +299,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: @@ -300,13 +314,14 @@ execute_process( # to avoid unnecessary compilation of subset machines. ######################################################################## 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}) - else() - list(REMOVE_ITEM available_machines ${machine_name_no_arch}) - endif() - endforeach(machine_name) + foreach(machine_name ${available_machines}) + string(REPLACE "_${arch}" "" machine_name_no_arch ${machine_name}) + if(${machine_name} STREQUAL ${machine_name_no_arch}) + + else() + list(REMOVE_ITEM available_machines ${machine_name_no_arch}) + endif() + endforeach(machine_name) endforeach(arch) ######################################################################## @@ -324,26 +339,34 @@ file(GLOB py_files ${PROJECT_SOURCE_DIR}/gen/*.py) file(GLOB h_files ${PROJECT_SOURCE_DIR}/kernels/volk/*.h) macro(gen_template tmpl output) - list(APPEND volk_gen_sources ${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} - ) + list(APPEND volk_gen_sources ${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}) 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,55 +374,66 @@ 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 - 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") - elseif(MSVC14) #Visual Studio 14 - SET(cmake_c_compiler_version "Microsoft Visual Studio 14.0") - endif() + 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") + elseif(MSVC14) #Visual Studio 14 + 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) + execute_process(COMMAND ${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}) - - #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 - ) - - 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}") - endif() + #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}) + + #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) + + 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}") + endif() - #add to available machine defs - string(TOUPPER LV_MACHINE_${machine_name} machine_def) - list(APPEND machine_defs ${machine_def}) + #add to available machine defs + string(TOUPPER LV_MACHINE_${machine_name} machine_def) + list(APPEND machine_defs ${machine_def}) 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 @@ -413,50 +447,50 @@ set(FULL_C_FLAGS "${CMAKE_C_FLAGS}" "${CMAKE_CXX_COMPILER_ARG1}") # 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}") + 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 ######################################################################## if(ORC_FOUND) - #setup orc library usage - include_directories(${ORC_INCLUDE_DIRS}) - link_directories(${ORC_LIBRARY_DIRS}) - - #setup orc functions - file(GLOB orc_files ${PROJECT_SOURCE_DIR}/kernels/volk/asm/orc/*.orc) - foreach(orc_file ${orc_files}) - - #extract the name for the generated c source from the orc file - get_filename_component(orc_file_name_we ${orc_file} NAME_WE) - set(orcc_gen ${CMAKE_CURRENT_BINARY_DIR}/${orc_file_name_we}.c) - - #create a rule to generate the source and add to the list of sources - add_custom_command( - COMMAND ${ORCC_EXECUTABLE} --include math.h --implementation -o ${orcc_gen} ${orc_file} - DEPENDS ${orc_file} OUTPUT ${orcc_gen} - ) - list(APPEND volk_sources ${orcc_gen}) - - endforeach(orc_file) + #setup orc library usage + include_directories(${ORC_INCLUDE_DIRS}) + link_directories(${ORC_LIBRARY_DIRS}) + + #setup orc functions + file(GLOB orc_files ${PROJECT_SOURCE_DIR}/kernels/volk/asm/orc/*.orc) + foreach(orc_file ${orc_files}) + + #extract the name for the generated c source from the orc file + get_filename_component(orc_file_name_we ${orc_file} NAME_WE) + set(orcc_gen ${CMAKE_CURRENT_BINARY_DIR}/${orc_file_name_we}.c) + + #create a rule to generate the source and add to the list of sources + add_custom_command( + COMMAND ${ORCC_EXECUTABLE} --include math.h --implementation -o + ${orcc_gen} ${orc_file} + DEPENDS ${orc_file} + OUTPUT ${orcc_gen}) + list(APPEND volk_sources ${orcc_gen}) + + endforeach(orc_file) else() - message(STATUS "Did not find liborc and orcc, disabling orc support...") + message(STATUS "Did not find liborc and orcc, disabling orc support...") endif() ######################################################################## @@ -467,12 +501,11 @@ message(STATUS "Loading version ${VERSION} into constants...") #double escape for windows backslash path separators string(REPLACE "\\" "\\\\" prefix "${prefix}") -string(REPLACE "${CMAKE_SOURCE_DIR}" "$BUILD_DIR" COMPILER_INFO "${COMPILER_INFO}") +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) @@ -480,29 +513,26 @@ list(APPEND volk_sources ${CMAKE_CURRENT_BINARY_DIR}/constants.c) # Setup the volk sources list and library ######################################################################## if(NOT WIN32) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden -Wno-deprecated-declarations") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden") + 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 - include_directories(${PROJECT_SOURCE_DIR}/cmake/msvc) - add_definitions(-DHAVE_CONFIG_H) - #compile the sources as C++ due to the lack of complex.h under MSVC - set_source_files_properties(${volk_sources} PROPERTIES LANGUAGE CXX) + #add compatibility includes for stdint types + include_directories(${PROJECT_SOURCE_DIR}/cmake/msvc) + add_definitions(-DHAVE_CONFIG_H) + #compile the sources as C++ due to the lack of complex.h under MSVC + set_source_files_properties(${volk_sources} PROPERTIES LANGUAGE CXX) endif() #Create an object to reference Volk source and object files. @@ -512,17 +542,20 @@ 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 - PRIVATE $ - PRIVATE $ - PRIVATE $ - PRIVATE ${CMAKE_CURRENT_BINARY_DIR} - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} -) +target_include_directories( + volk_obj + PRIVATE $ + PRIVATE $ + PRIVATE $ + PRIVATE ${CMAKE_CURRENT_BINARY_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() @@ -542,17 +575,17 @@ 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 - PUBLIC $ - PUBLIC $ - PUBLIC $ - PRIVATE ${CMAKE_CURRENT_BINARY_DIR} - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PUBLIC $ -) - +target_include_directories( + volk + PUBLIC $ + PUBLIC $ + PUBLIC $ + PRIVATE ${CMAKE_CURRENT_BINARY_DIR} + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} + PUBLIC $) #Configure target properties if(ORC_FOUND) @@ -566,12 +599,13 @@ set_target_properties(volk PROPERTIES SOVERSION ${SOVERSION}) set_target_properties(volk PROPERTIES DEFINE_SYMBOL "volk_EXPORTS") #Install locations -install(TARGETS volk +install( + TARGETS volk EXPORT VOLK-export LIBRARY DESTINATION lib${LIB_SUFFIX} COMPONENT "volk_runtime" # .so file - ARCHIVE DESTINATION lib${LIB_SUFFIX} COMPONENT "volk_devel" # .lib file - RUNTIME DESTINATION bin COMPONENT "volk_runtime" # .dll file - ) + ARCHIVE DESTINATION lib${LIB_SUFFIX} COMPONENT "volk_devel" # .lib file + RUNTIME DESTINATION bin COMPONENT "volk_runtime" # .dll file +) #Configure static library # @@ -585,7 +619,8 @@ 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 $) + target_link_libraries(volk_static + PRIVATE $) endif() if(ORC_FOUND) target_link_libraries(volk_static PUBLIC ${ORC_LIBRARIES_STATIC}) @@ -596,21 +631,21 @@ if(ENABLE_STATIC_LIBS) if(NOT MSVC) target_link_libraries(volk_static PUBLIC m) endif() - target_include_directories(volk_static + target_include_directories( + volk_static PUBLIC $ PUBLIC $ PUBLIC $ PRIVATE ${CMAKE_CURRENT_BINARY_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PUBLIC $ - ) + PUBLIC $) set_target_properties(volk_static PROPERTIES OUTPUT_NAME volk) - install(TARGETS volk_static + install( + TARGETS volk_static EXPORT VOLK-export - ARCHIVE DESTINATION lib${LIB_SUFFIX} COMPONENT "volk_devel" - ) + ARCHIVE DESTINATION lib${LIB_SUFFIX} COMPONENT "volk_devel") endif(ENABLE_STATIC_LIBS) ######################################################################## @@ -618,25 +653,20 @@ endif(ENABLE_STATIC_LIBS) ######################################################################## 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 - ) - else() - 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) - endforeach() + 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) + else() + 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) + endforeach() endif(ENABLE_TESTING) diff --git a/python/volk_modtool/CMakeLists.txt b/python/volk_modtool/CMakeLists.txt index dcc79a5d2..bcc30ca32 100644 --- a/python/volk_modtool/CMakeLists.txt +++ b/python/volk_modtool/CMakeLists.txt @@ -11,18 +11,15 @@ ######################################################################## include(VolkPython) -VOLK_PYTHON_INSTALL( - FILES - __init__.py - cfg.py - volk_modtool_generate.py - DESTINATION ${VOLK_PYTHON_DIR}/volk_modtool - COMPONENT "volk" -) +volk_python_install( + FILES + __init__.py + cfg.py + volk_modtool_generate.py + 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")