Skip to content

Commit

Permalink
cmake: Apply .cmake-format.py
Browse files Browse the repository at this point in the history
Run:
```
cmake-format -c .cmake-format.py -i $(git ls-files | grep CMakeLists.txt) $(git ls-files cmake/ | grep .cmake)
```
This applies the cmake formatting as defined in all files.

In order to install `cmake-format`, you might want to run
`pip install cmakelang`
Or use another package manager of your choice.

Signed-off-by: Johannes Demel <demel@uni-bremen.de>
  • Loading branch information
jdemel committed Feb 10, 2024
1 parent 7739ee4 commit e165c92
Show file tree
Hide file tree
Showing 25 changed files with 1,049 additions and 906 deletions.
271 changes: 140 additions & 131 deletions CMakeLists.txt

Large diffs are not rendered by default.

44 changes: 20 additions & 24 deletions apps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,24 @@ if(HAVE_POSIX_MEMALIGN)
endif(HAVE_POSIX_MEMALIGN)

# MAKE volk_profile
add_executable(volk_profile
${CMAKE_CURRENT_SOURCE_DIR}/volk_profile.cc
${PROJECT_SOURCE_DIR}/lib/qa_utils.cc
${CMAKE_CURRENT_SOURCE_DIR}/volk_option_helpers.cc
)
add_executable(
volk_profile
${CMAKE_CURRENT_SOURCE_DIR}/volk_profile.cc ${PROJECT_SOURCE_DIR}/lib/qa_utils.cc
${CMAKE_CURRENT_SOURCE_DIR}/volk_option_helpers.cc)

if(MSVC)
target_include_directories(volk_profile
PRIVATE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/cmake/msvc>
)
target_include_directories(
volk_profile PRIVATE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/cmake/msvc>)
endif(MSVC)

target_include_directories(volk_profile
target_include_directories(
volk_profile
PRIVATE $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include>
PRIVATE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
PRIVATE $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/lib>
PRIVATE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/lib>
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
)
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})

add_definitions(-DHAS_STD_FILESYSTEM=1)
if(${find_experimental})
Expand All @@ -54,12 +52,11 @@ endif()
install(
TARGETS volk_profile
DESTINATION bin
COMPONENT "volk"
)
COMPONENT "volk")

# MAKE volk-config-info
add_executable(volk-config-info volk-config-info.cc ${CMAKE_CURRENT_SOURCE_DIR}/volk_option_helpers.cc
)
add_executable(volk-config-info volk-config-info.cc
${CMAKE_CURRENT_SOURCE_DIR}/volk_option_helpers.cc)

if(ENABLE_STATIC_LIBS)
target_link_libraries(volk-config-info volk_static)
Expand All @@ -71,21 +68,20 @@ endif()
install(
TARGETS volk-config-info
DESTINATION bin
COMPONENT "volk"
)
COMPONENT "volk")

# Launch volk_profile if requested to do so
if(ENABLE_PROFILING)
if(DEFINED VOLK_CONFIGPATH)
set( VOLK_CONFIG_ARG "-p${VOLK_CONFIGPATH}" )
set( VOLK_CONFIG "${VOLK_CONFIGPATH}/volk_config" )
endif()
if(DEFINED VOLK_CONFIGPATH)
set(VOLK_CONFIG_ARG "-p${VOLK_CONFIGPATH}")
set(VOLK_CONFIG "${VOLK_CONFIGPATH}/volk_config")
endif()

add_custom_command(OUTPUT ${VOLK_CONFIG}
add_custom_command(
OUTPUT ${VOLK_CONFIG}
COMMAND volk_profile "${VOLK_CONFIG_ARG}"
DEPENDS volk_profile
COMMENT "Launching profiler, this may take a few minutes..."
)
COMMENT "Launching profiler, this may take a few minutes...")
add_custom_target(volk-profile-run ALL DEPENDS ${VOLK_CONFIG})

endif()
109 changes: 60 additions & 49 deletions cmake/Modules/CMakeParseArgumentsCopy.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -80,66 +80,77 @@
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)


if(__CMAKE_PARSE_ARGUMENTS_INCLUDED)
return()
return()
endif()
set(__CMAKE_PARSE_ARGUMENTS_INCLUDED TRUE)


function(CMAKE_PARSE_ARGUMENTS prefix _optionNames _singleArgNames _multiArgNames)
# first set all result variables to empty/FALSE
foreach(arg_name ${_singleArgNames} ${_multiArgNames})
set(${prefix}_${arg_name})
endforeach(arg_name)
# first set all result variables to empty/FALSE
foreach(arg_name ${_singleArgNames} ${_multiArgNames})
set(${prefix}_${arg_name})
endforeach(arg_name)

foreach(option ${_optionNames})
set(${prefix}_${option} FALSE)
endforeach(option)
foreach(option ${_optionNames})
set(${prefix}_${option} FALSE)
endforeach(option)

set(${prefix}_UNPARSED_ARGUMENTS)
set(${prefix}_UNPARSED_ARGUMENTS)

set(insideValues FALSE)
set(currentArgName)
set(insideValues FALSE)
set(currentArgName)

# now iterate over all arguments and fill the result variables
foreach(currentArg ${ARGN})
list(FIND _optionNames "${currentArg}" optionIndex) # ... then this marks the end of the arguments belonging to this keyword
list(FIND _singleArgNames "${currentArg}" singleArgIndex) # ... then this marks the end of the arguments belonging to this keyword
list(FIND _multiArgNames "${currentArg}" multiArgIndex) # ... then this marks the end of the arguments belonging to this keyword
# now iterate over all arguments and fill the result variables
foreach(currentArg ${ARGN})
list(FIND _optionNames "${currentArg}" optionIndex
)# ... then this marks the end of the arguments belonging to this keyword
list(FIND _singleArgNames "${currentArg}" singleArgIndex
)# ... then this marks the end of the arguments belonging to this keyword
list(FIND _multiArgNames "${currentArg}" multiArgIndex
)# ... then this marks the end of the arguments belonging to this keyword

if(${optionIndex} EQUAL -1 AND ${singleArgIndex} EQUAL -1 AND ${multiArgIndex} EQUAL -1)
if(insideValues)
if("${insideValues}" STREQUAL "SINGLE")
set(${prefix}_${currentArgName} ${currentArg})
set(insideValues FALSE)
elseif("${insideValues}" STREQUAL "MULTI")
list(APPEND ${prefix}_${currentArgName} ${currentArg})
if(${optionIndex} EQUAL -1
AND ${singleArgIndex} EQUAL -1
AND ${multiArgIndex} EQUAL -1)
if(insideValues)
if("${insideValues}" STREQUAL "SINGLE")
set(${prefix}_${currentArgName} ${currentArg})
set(insideValues FALSE)
elseif("${insideValues}" STREQUAL "MULTI")
list(APPEND ${prefix}_${currentArgName} ${currentArg})
endif()
else(insideValues)
list(APPEND ${prefix}_UNPARSED_ARGUMENTS ${currentArg})
endif(insideValues)
else()
if(NOT ${optionIndex} EQUAL -1)
set(${prefix}_${currentArg} TRUE)
set(insideValues FALSE)
elseif(NOT ${singleArgIndex} EQUAL -1)
set(currentArgName ${currentArg})
set(${prefix}_${currentArgName})
set(insideValues "SINGLE")
elseif(NOT ${multiArgIndex} EQUAL -1)
set(currentArgName ${currentArg})
set(${prefix}_${currentArgName})
set(insideValues "MULTI")
endif()
endif()
else(insideValues)
list(APPEND ${prefix}_UNPARSED_ARGUMENTS ${currentArg})
endif(insideValues)
else()
if(NOT ${optionIndex} EQUAL -1)
set(${prefix}_${currentArg} TRUE)
set(insideValues FALSE)
elseif(NOT ${singleArgIndex} EQUAL -1)
set(currentArgName ${currentArg})
set(${prefix}_${currentArgName})
set(insideValues "SINGLE")
elseif(NOT ${multiArgIndex} EQUAL -1)
set(currentArgName ${currentArg})
set(${prefix}_${currentArgName})
set(insideValues "MULTI")
endif()
endif()

endforeach(currentArg)
endforeach(currentArg)

# propagate the result variables to the caller:
foreach(arg_name ${_singleArgNames} ${_multiArgNames} ${_optionNames})
set(${prefix}_${arg_name} ${${prefix}_${arg_name}} PARENT_SCOPE)
endforeach(arg_name)
set(${prefix}_UNPARSED_ARGUMENTS ${${prefix}_UNPARSED_ARGUMENTS} PARENT_SCOPE)
# propagate the result variables to the caller:
foreach(arg_name ${_singleArgNames} ${_multiArgNames} ${_optionNames})
set(${prefix}_${arg_name}
${${prefix}_${arg_name}}
PARENT_SCOPE)
endforeach(arg_name)
set(${prefix}_UNPARSED_ARGUMENTS
${${prefix}_UNPARSED_ARGUMENTS}
PARENT_SCOPE)

endfunction(CMAKE_PARSE_ARGUMENTS _options _singleArgs _multiArgs)
endfunction(
CMAKE_PARSE_ARGUMENTS
_options
_singleArgs
_multiArgs)
37 changes: 26 additions & 11 deletions cmake/Modules/FindFILESYSTEM.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ Using `find_package(FILESYSTEM)` with no component arguments:

#]=======================================================================]


if(TARGET std::filesystem)
# This module has already been processed. Don't do it again.
return()
Expand All @@ -121,16 +120,19 @@ set(CMAKE_REQUIRED_QUIET ${FILESYSTEM_FIND_QUIETLY})
# All of our tests require C++17 or later
set(OLD_CMAKE_CXX_STANDARD ${CMAKE_CXX_STANDARD})
set(CMAKE_CXX_STANDARD 17)
if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "8.0.0"))
if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER
"8.0.0"))
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "8.99")
set(UNDEFINED_BEHAVIOR_WITHOUT_LINKING TRUE)
endif()
set(CMAKE_REQUIRED_FLAGS "-std=c++17")
endif()
if((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") AND NOT (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "8.99"))
if((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") AND NOT (CMAKE_CXX_COMPILER_VERSION
VERSION_LESS "8.99"))
set(CMAKE_REQUIRED_FLAGS "-std=c++17")
endif()
if((CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") AND NOT (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "11"))
if((CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") AND NOT (CMAKE_CXX_COMPILER_VERSION
VERSION_LESS "11"))
set(CMAKE_REQUIRED_FLAGS "-std=c++17")
endif()
if(MSVC AND NOT (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "18"))
Expand Down Expand Up @@ -173,7 +175,8 @@ else()
endif()

if(find_experimental)
check_include_file_cxx("experimental/filesystem" _CXX_FILESYSTEM_HAVE_EXPERIMENTAL_HEADER)
check_include_file_cxx("experimental/filesystem"
_CXX_FILESYSTEM_HAVE_EXPERIMENTAL_HEADER)
mark_as_advanced(_CXX_FILESYSTEM_HAVE_EXPERIMENTAL_HEADER)
else()
set(_CXX_FILESYSTEM_HAVE_EXPERIMENTAL_HEADER FALSE)
Expand All @@ -191,22 +194,32 @@ else()
set(_have_fs FALSE)
endif()

set(CXX_FILESYSTEM_HAVE_FS ${_have_fs} CACHE BOOL "TRUE if we have the C++ filesystem headers")
set(CXX_FILESYSTEM_HEADER ${_fs_header} CACHE STRING "The header that should be included to obtain the filesystem APIs")
set(CXX_FILESYSTEM_NAMESPACE ${_fs_namespace} CACHE STRING "The C++ namespace that contains the filesystem APIs")
set(CXX_FILESYSTEM_HAVE_FS
${_have_fs}
CACHE BOOL "TRUE if we have the C++ filesystem headers")
set(CXX_FILESYSTEM_HEADER
${_fs_header}
CACHE STRING "The header that should be included to obtain the filesystem APIs")
set(CXX_FILESYSTEM_NAMESPACE
${_fs_namespace}
CACHE STRING "The C++ namespace that contains the filesystem APIs")

set(_found FALSE)

if(CXX_FILESYSTEM_HAVE_FS)
# We have some filesystem library available. Do link checks
string(CONFIGURE [[
string(
CONFIGURE
[[
#include <@CXX_FILESYSTEM_HEADER@>

int main() {
auto cwd = @CXX_FILESYSTEM_NAMESPACE@::current_path();
return static_cast<int>(cwd.string().size());
}
]] code @ONLY)
]]
code
@ONLY)

# Try to compile a simple filesystem program without any linker flags
if(NOT UNDEFINED_BEHAVIOR_WITHOUT_LINKING)
Expand Down Expand Up @@ -254,7 +267,9 @@ endif()

cmake_pop_check_state()

set(FILESYSTEM_FOUND ${_found} CACHE BOOL "TRUE if we can compile and link a program using std::filesystem" FORCE)
set(FILESYSTEM_FOUND
${_found}
CACHE BOOL "TRUE if we can compile and link a program using std::filesystem" FORCE)

if(FILESYSTEM_FIND_REQUIRED AND NOT FILESYSTEM_FOUND)
message(FATAL_ERROR "Cannot compile a simple program using std::filesystem")
Expand Down
86 changes: 46 additions & 40 deletions cmake/Modules/FindORC.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,45 +5,51 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
#

FIND_PACKAGE(PkgConfig)
PKG_CHECK_MODULES(PC_ORC "orc-0.4 > 0.4.11")

INCLUDE(GNUInstallDirs)


FIND_PROGRAM(ORCC_EXECUTABLE orcc
HINTS ${PC_ORC_TOOLSDIR}
PATHS ${ORC_ROOT}/bin ${CMAKE_INSTALL_PREFIX}/bin)

FIND_PATH(ORC_INCLUDE_DIR NAMES orc/orc.h
HINTS ${PC_ORC_INCLUDEDIR}
PATHS ${ORC_ROOT}/include ${CMAKE_INSTALL_PREFIX}/include
PATH_SUFFIXES orc-0.4)


FIND_PATH(ORC_LIBRARY_DIR NAMES ${CMAKE_SHARED_LIBRARY_PREFIX}orc-0.4${CMAKE_SHARED_LIBRARY_SUFFIX}
HINTS ${PC_ORC_LIBDIR}
PATHS ${ORC_ROOT}/${CMAKE_INSTALL_LIBDIR} ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR})

FIND_LIBRARY(ORC_LIB orc-0.4
HINTS ${PC_ORC_LIBRARY_DIRS}
PATHS ${ORC_ROOT}/${CMAKE_INSTALL_LIBDIR} ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR})

FIND_LIBRARY(ORC_LIBRARY_STATIC liborc-0.4.a
HINTS ${PC_ORC_LIBRARY_DIRS}
PATHS ${ORC_ROOT}/${CMAKE_INSTALL_LIBDIR} ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR})

LIST(APPEND ORC_LIBRARY
${ORC_LIB}
)


SET(ORC_INCLUDE_DIRS ${ORC_INCLUDE_DIR})
SET(ORC_LIBRARIES ${ORC_LIBRARY})
SET(ORC_LIBRARY_DIRS ${ORC_LIBRARY_DIR})
SET(ORC_LIBRARIES_STATIC ${ORC_LIBRARY_STATIC})

INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(ORC "orc files" ORC_LIBRARY ORC_INCLUDE_DIR ORCC_EXECUTABLE)
find_package(PkgConfig)
pkg_check_modules(PC_ORC "orc-0.4 > 0.4.11")

include(GNUInstallDirs)

find_program(
ORCC_EXECUTABLE orcc
HINTS ${PC_ORC_TOOLSDIR}
PATHS ${ORC_ROOT}/bin ${CMAKE_INSTALL_PREFIX}/bin)

find_path(
ORC_INCLUDE_DIR
NAMES orc/orc.h
HINTS ${PC_ORC_INCLUDEDIR}
PATHS ${ORC_ROOT}/include ${CMAKE_INSTALL_PREFIX}/include
PATH_SUFFIXES orc-0.4)

find_path(
ORC_LIBRARY_DIR
NAMES ${CMAKE_SHARED_LIBRARY_PREFIX}orc-0.4${CMAKE_SHARED_LIBRARY_SUFFIX}
HINTS ${PC_ORC_LIBDIR}
PATHS ${ORC_ROOT}/${CMAKE_INSTALL_LIBDIR}
${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR})

find_library(
ORC_LIB orc-0.4
HINTS ${PC_ORC_LIBRARY_DIRS}
PATHS ${ORC_ROOT}/${CMAKE_INSTALL_LIBDIR}
${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR})

find_library(
ORC_LIBRARY_STATIC liborc-0.4.a
HINTS ${PC_ORC_LIBRARY_DIRS}
PATHS ${ORC_ROOT}/${CMAKE_INSTALL_LIBDIR}
${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR})

list(APPEND ORC_LIBRARY ${ORC_LIB})

set(ORC_INCLUDE_DIRS ${ORC_INCLUDE_DIR})
set(ORC_LIBRARIES ${ORC_LIBRARY})
set(ORC_LIBRARY_DIRS ${ORC_LIBRARY_DIR})
set(ORC_LIBRARIES_STATIC ${ORC_LIBRARY_STATIC})

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(ORC "orc files" ORC_LIBRARY ORC_INCLUDE_DIR
ORCC_EXECUTABLE)

mark_as_advanced(ORC_INCLUDE_DIR ORC_LIBRARY ORCC_EXECUTABLE)
Loading

0 comments on commit e165c92

Please sign in to comment.