diff --git a/.gersemirc b/.gersemirc new file mode 100644 index 0000000..e42c9cf --- /dev/null +++ b/.gersemirc @@ -0,0 +1,2 @@ +line_length: 80 +list_expansion: favour-expansion diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8dbe767..5675092 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -23,3 +23,8 @@ repos: language: system entry: ci/check_license.py files: \.(cpp|hpp|ipp|cu|cuh)$ + + - repo: https://github.com/BlankSpruce/gersemi + rev: "0.17.0" + hooks: + - id: gersemi diff --git a/CMakeLists.txt b/CMakeLists.txt index a2195be..62d530e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,41 +8,19 @@ cmake_minimum_required(VERSION 3.18) -project( - "covfie" - VERSION 0.10.0 -) +project("covfie" VERSION 0.10.0) # Declare options which control the parts of the code being built. -option( - COVFIE_BUILD_BENCHMARKS - "Build benchmark executables." -) -option( - COVFIE_BUILD_TESTS - "Build test executables." -) -option( - COVFIE_BUILD_EXAMPLES - "Build example executables." -) +option(COVFIE_BUILD_BENCHMARKS "Build benchmark executables.") +option(COVFIE_BUILD_TESTS "Build test executables.") +option(COVFIE_BUILD_EXAMPLES "Build example executables.") # Declare option to enable header completeness tests. -option( - COVFIE_TEST_HEADERS - "Enable header completeness tests." -) +option(COVFIE_TEST_HEADERS "Enable header completeness tests.") # Declare options for the different platforms that we wish to support. -option( - COVFIE_PLATFORM_CPU - "Enable building of CPU code." - On -) -option( - COVFIE_PLATFORM_CUDA - "Enable building of CUDA code." -) +option(COVFIE_PLATFORM_CPU "Enable building of CPU code." On) +option(COVFIE_PLATFORM_CUDA "Enable building of CUDA code.") # Additional options that may be useful in some cases, such as CI. option( @@ -56,10 +34,7 @@ option( "Disable warnings about missing C++ features. Enabling this is strongly discouraged." ) -option( - COVFIE_FAIL_ON_WARNINGS - "Treat compiler warnings as errors." -) +option(COVFIE_FAIL_ON_WARNINGS "Treat compiler warnings as errors.") # Make the CMake modules in the cmake/ directory visible to the project. list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") diff --git a/benchmarks/CMakeLists.txt b/benchmarks/CMakeLists.txt index d01c888..b090321 100644 --- a/benchmarks/CMakeLists.txt +++ b/benchmarks/CMakeLists.txt @@ -10,11 +10,7 @@ find_package(benchmark CONFIG REQUIRED) # All of these benchmarks rely on the Boost MP11 library. -find_package( - Boost - 1.71.0 - REQUIRED -) +find_package(Boost 1.71.0 REQUIRED) # Set up the C++ compiler flags for the benchmarks. include(covfie-compiler-options-cpp) diff --git a/benchmarks/common/CMakeLists.txt b/benchmarks/common/CMakeLists.txt index 6342201..8ce4c61 100644 --- a/benchmarks/common/CMakeLists.txt +++ b/benchmarks/common/CMakeLists.txt @@ -6,25 +6,10 @@ # v. 2.0. If a copy of the MPL was not distributed with this file, You can # obtain one at http://mozilla.org/MPL/2.0/. -add_library( - benchmark - test_field.cpp -) +add_library(benchmark test_field.cpp) -target_include_directories( - benchmark - PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR} -) +target_include_directories(benchmark PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) -target_link_libraries( - benchmark - PUBLIC - core -) +target_link_libraries(benchmark PUBLIC core) -target_compile_definitions( - benchmark - PRIVATE - _CRT_SECURE_NO_WARNINGS -) +target_compile_definitions(benchmark PRIVATE _CRT_SECURE_NO_WARNINGS) diff --git a/benchmarks/cpu/CMakeLists.txt b/benchmarks/cpu/CMakeLists.txt index c8fcc08..482a4c3 100644 --- a/benchmarks/cpu/CMakeLists.txt +++ b/benchmarks/cpu/CMakeLists.txt @@ -7,20 +7,15 @@ # obtain one at http://mozilla.org/MPL/2.0/. # Create the benchmark executable from the individual files. -add_executable( - benchmark_cpu - - benchmark_cpu.cpp -) +add_executable(benchmark_cpu benchmark_cpu.cpp) # Ensure that the tests are linked against the required libraries. target_link_libraries( benchmark_cpu - PUBLIC - core - cpu - benchmark - benchmark::benchmark - Boost::headers + core + cpu + benchmark + benchmark::benchmark + Boost::headers ) diff --git a/benchmarks/cuda/CMakeLists.txt b/benchmarks/cuda/CMakeLists.txt index e09152f..b1265df 100644 --- a/benchmarks/cuda/CMakeLists.txt +++ b/benchmarks/cuda/CMakeLists.txt @@ -12,20 +12,15 @@ enable_language(CUDA) include(covfie-compiler-options-cuda) # Create the benchmark executable from the individual files. -add_executable( - benchmark_cuda - - benchmark_cuda.cu -) +add_executable(benchmark_cuda benchmark_cuda.cu) # Ensure that the tests are linked against the required libraries. target_link_libraries( benchmark_cuda - PUBLIC - core - cuda - benchmark - benchmark::benchmark - Boost::headers + core + cuda + benchmark + benchmark::benchmark + Boost::headers ) diff --git a/benchmarks/openmp/CMakeLists.txt b/benchmarks/openmp/CMakeLists.txt index 20af7d7..215be12 100644 --- a/benchmarks/openmp/CMakeLists.txt +++ b/benchmarks/openmp/CMakeLists.txt @@ -10,21 +10,16 @@ find_package(OpenMP COMPONENTS CXX REQUIRED) # Create the benchmark executable from the individual files. -add_executable( - benchmark_openmp - - benchmark_openmp.cpp -) +add_executable(benchmark_openmp benchmark_openmp.cpp) # Ensure that the tests are linked against the required libraries. target_link_libraries( benchmark_openmp - PUBLIC - core - cpu - benchmark - OpenMP::OpenMP_CXX - benchmark::benchmark - Boost::headers + core + cpu + benchmark + OpenMP::OpenMP_CXX + benchmark::benchmark + Boost::headers ) diff --git a/cmake/covfie-compiler-options-cpp.cmake b/cmake/covfie-compiler-options-cpp.cmake index 1d03a79..a7c1875 100644 --- a/cmake/covfie-compiler-options-cpp.cmake +++ b/cmake/covfie-compiler-options-cpp.cmake @@ -7,39 +7,44 @@ # obtain one at http://mozilla.org/MPL/2.0/. # Include the helper function(s). -include( covfie-functions ) +include(covfie-functions) # Turn on a number of warnings for the "known compilers". -if( ( "${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU" ) OR - ( "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" ) ) - - # Basic flags for all build modes. - covfie_add_flag( CMAKE_CXX_FLAGS "-Wall" ) - covfie_add_flag( CMAKE_CXX_FLAGS "-Wextra" ) - covfie_add_flag( CMAKE_CXX_FLAGS "-Wshadow" ) - covfie_add_flag( CMAKE_CXX_FLAGS "-Wunused-local-typedefs" ) - covfie_add_flag( CMAKE_CXX_FLAGS "-pedantic" ) - covfie_add_flag( CMAKE_CXX_FLAGS "-Wfloat-conversion" ) - covfie_add_flag( CMAKE_CXX_FLAGS "-Wconversion" ) - - # Fail on warnings, if asked for that behaviour. - if( COVFIE_FAIL_ON_WARNINGS ) - covfie_add_flag( CMAKE_CXX_FLAGS "-Werror" ) - endif() - -elseif( "${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC" ) - - # Basic flags for all build modes. - string( REGEX REPLACE "/W[0-9]" "" CMAKE_CXX_FLAGS - "${CMAKE_CXX_FLAGS}" ) - covfie_add_flag( CMAKE_CXX_FLAGS "/W4" ) - - # Fail on warnings, if asked for that behaviour. - if( COVFIE_FAIL_ON_WARNINGS ) - covfie_add_flag( CMAKE_CXX_FLAGS "/WX" ) - endif() - - # Turn on the correct setting for the __cplusplus macro with MSVC. - covfie_add_flag( CMAKE_CXX_FLAGS "/Zc:__cplusplus" ) - +if( + ( + "${CMAKE_CXX_COMPILER_ID}" + MATCHES + "GNU" + ) + OR ( + "${CMAKE_CXX_COMPILER_ID}" + MATCHES + "Clang" + ) +) + # Basic flags for all build modes. + covfie_add_flag( CMAKE_CXX_FLAGS "-Wall" ) + covfie_add_flag( CMAKE_CXX_FLAGS "-Wextra" ) + covfie_add_flag( CMAKE_CXX_FLAGS "-Wshadow" ) + covfie_add_flag( CMAKE_CXX_FLAGS "-Wunused-local-typedefs" ) + covfie_add_flag( CMAKE_CXX_FLAGS "-pedantic" ) + covfie_add_flag( CMAKE_CXX_FLAGS "-Wfloat-conversion" ) + covfie_add_flag( CMAKE_CXX_FLAGS "-Wconversion" ) + + # Fail on warnings, if asked for that behaviour. + if(COVFIE_FAIL_ON_WARNINGS) + covfie_add_flag( CMAKE_CXX_FLAGS "-Werror" ) + endif() +elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC") + # Basic flags for all build modes. + string(REGEX REPLACE "/W[0-9]" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + covfie_add_flag( CMAKE_CXX_FLAGS "/W4" ) + + # Fail on warnings, if asked for that behaviour. + if(COVFIE_FAIL_ON_WARNINGS) + covfie_add_flag( CMAKE_CXX_FLAGS "/WX" ) + endif() + + # Turn on the correct setting for the __cplusplus macro with MSVC. + covfie_add_flag( CMAKE_CXX_FLAGS "/Zc:__cplusplus" ) endif() diff --git a/cmake/covfie-compiler-options-cuda.cmake b/cmake/covfie-compiler-options-cuda.cmake index 2d5bf3b..d8d6c0b 100644 --- a/cmake/covfie-compiler-options-cuda.cmake +++ b/cmake/covfie-compiler-options-cuda.cmake @@ -7,41 +7,54 @@ # obtain one at http://mozilla.org/MPL/2.0/. # FindCUDAToolkit needs at least CMake 3.17. -cmake_minimum_required( VERSION 3.17 ) +cmake_minimum_required(VERSION 3.17) # Include the helper function(s). -include( covfie-functions ) +include(covfie-functions) # Figure out the properties of CUDA being used. -find_package( CUDAToolkit REQUIRED ) +find_package(CUDAToolkit REQUIRED) # Set the architecture to build code for. -set( CMAKE_CUDA_ARCHITECTURES "52" CACHE STRING - "CUDA architectures to build device code for" ) +set(CMAKE_CUDA_ARCHITECTURES + "52" + CACHE STRING + "CUDA architectures to build device code for" +) # Turn on the correct setting for the __cplusplus macro with MSVC. -if( "${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC" ) - covfie_add_flag( CMAKE_CUDA_FLAGS "-Xcompiler /Zc:__cplusplus" ) +if("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC") + covfie_add_flag( CMAKE_CUDA_FLAGS "-Xcompiler /Zc:__cplusplus" ) endif() -if( "${CMAKE_CUDA_COMPILER_ID}" MATCHES "NVIDIA" ) - # Make CUDA generate debug symbols for the device code as well in a debug - # build. - covfie_add_flag( CMAKE_CUDA_FLAGS_DEBUG "-G" ) - # Allow to use functions in device code that are constexpr, even if they are - # not marked with __device__. - covfie_add_flag( CMAKE_CUDA_FLAGS "--expt-relaxed-constexpr" ) +if("${CMAKE_CUDA_COMPILER_ID}" MATCHES "NVIDIA") + # Make CUDA generate debug symbols for the device code as well in a debug + # build. + covfie_add_flag( CMAKE_CUDA_FLAGS_DEBUG "-G" ) + # Allow to use functions in device code that are constexpr, even if they are + # not marked with __device__. + covfie_add_flag( CMAKE_CUDA_FLAGS "--expt-relaxed-constexpr" ) endif() covfie_add_flag( CMAKE_CUDA_FLAGS "-Wfloat-conversion" ) covfie_add_flag( CMAKE_CUDA_FLAGS "-Wconversion" ) # Fail on warnings, if asked for that behaviour. -if( COVFIE_FAIL_ON_WARNINGS ) - if( ( "${CUDAToolkit_VERSION}" VERSION_GREATER_EQUAL "10.2" ) AND - ( "${CMAKE_CUDA_COMPILER_ID}" MATCHES "NVIDIA" ) ) - covfie_add_flag( CMAKE_CUDA_FLAGS "-Werror all-warnings" ) - elseif( "${CMAKE_CUDA_COMPILER_ID}" MATCHES "Clang" ) - covfie_add_flag( CMAKE_CUDA_FLAGS "-Werror" ) - endif() +if(COVFIE_FAIL_ON_WARNINGS) + if( + ( + "${CUDAToolkit_VERSION}" + VERSION_GREATER_EQUAL + "10.2" + ) + AND ( + "${CMAKE_CUDA_COMPILER_ID}" + MATCHES + "NVIDIA" + ) + ) + covfie_add_flag( CMAKE_CUDA_FLAGS "-Werror all-warnings" ) + elseif("${CMAKE_CUDA_COMPILER_ID}" MATCHES "Clang") + covfie_add_flag( CMAKE_CUDA_FLAGS "-Werror" ) + endif() endif() diff --git a/cmake/covfie-functions.cmake b/cmake/covfie-functions.cmake index b3ddb2e..d5d5dd7 100644 --- a/cmake/covfie-functions.cmake +++ b/cmake/covfie-functions.cmake @@ -16,55 +16,68 @@ # Usage: covfie_test_public_headers( covfie_core # include/header1.hpp ... ) # -function( covfie_test_public_headers library ) - # All arguments are treated as header file names. - foreach( _headerName ${ARGN} ) +function(covfie_test_public_headers library) + # All arguments are treated as header file names. + foreach(_headerName ${ARGN}) + # Make the header filename into a "string". + string(REPLACE "/" "_" _headerNormName "${_headerName}") + string(REPLACE "." "_" _headerNormName "${_headerNormName}") - # Make the header filename into a "string". - string( REPLACE "/" "_" _headerNormName "${_headerName}" ) - string( REPLACE "." "_" _headerNormName "${_headerNormName}" ) + # Write a small source file that would test that the public + # header can be used as-is. + set(_testFileName + "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/test_${library}_${_headerNormName}.cpp" + ) + if(NOT EXISTS "${_testFileName}") + file( + WRITE + "${_testFileName}" + "#include \"${_headerName}\"\n" + "int main() { return 0; }" + ) + endif() - # Write a small source file that would test that the public - # header can be used as-is. - set( _testFileName - "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/test_${library}_${_headerNormName}.cpp" ) - if( NOT EXISTS "${_testFileName}" ) - file( WRITE "${_testFileName}" - "#include \"${_headerName}\"\n" - "int main() { return 0; }" ) - endif() - - # Set up an executable that would build it. But hide it, don't put it - # into ${CMAKE_BINARY_DIR}/bin. - add_executable( "test_${library}_${_headerNormName}" "${_testFileName}" ) - target_link_libraries( "test_${library}_${_headerNormName}" - PRIVATE ${library} ) - set_target_properties( "test_${library}_${_headerNormName}" PROPERTIES - RUNTIME_OUTPUT_DIRECTORY - "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}" ) - - endforeach() - -endfunction( covfie_test_public_headers ) + # Set up an executable that would build it. But hide it, don't put it + # into ${CMAKE_BINARY_DIR}/bin. + add_executable("test_${library}_${_headerNormName}" "${_testFileName}") + target_link_libraries( + "test_${library}_${_headerNormName}" + PRIVATE + ${library} + ) + set_target_properties( + "test_${library}_${_headerNormName}" + PROPERTIES + RUNTIME_OUTPUT_DIRECTORY + "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}" + ) + endforeach() +endfunction(covfie_test_public_headers) # Helper function for adding individual flags to "flag variables". # # Usage: covfie_add_flag( CMAKE_CXX_FLAGS "-Wall" ) # -function( covfie_add_flag name value ) - - # Escape special characters in the value: - set( matchedValue "${value}" ) - foreach( c "*" "." "^" "$" "+" "?" ) - string( REPLACE "${c}" "\\${c}" matchedValue "${matchedValue}" ) - endforeach() - - # Check if the variable already has this value in it: - if( "${${name}}" MATCHES "${matchedValue}" ) - return() - endif() +function(covfie_add_flag name value) + # Escape special characters in the value: + set(matchedValue "${value}") + foreach( + c + "*" + "." + "^" + "$" + "+" + "?" + ) + string(REPLACE "${c}" "\\${c}" matchedValue "${matchedValue}") + endforeach() - # If not, then let's add it now: - set( ${name} "${${name}} ${value}" PARENT_SCOPE ) + # Check if the variable already has this value in it: + if("${${name}}" MATCHES "${matchedValue}") + return() + endif() -endfunction( covfie_add_flag ) + # If not, then let's add it now: + set(${name} "${${name}} ${value}" PARENT_SCOPE) +endfunction(covfie_add_flag) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 7ad8214..5ccac8e 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -22,9 +22,9 @@ find_package( 1.71.0 REQUIRED COMPONENTS - log - log_setup - program_options + log + log_setup + program_options ) # As always, the core examples are built any time the examples are. diff --git a/examples/common/bitmap/CMakeLists.txt b/examples/common/bitmap/CMakeLists.txt index fb8b407..f7dc0b7 100644 --- a/examples/common/bitmap/CMakeLists.txt +++ b/examples/common/bitmap/CMakeLists.txt @@ -6,14 +6,6 @@ # v. 2.0. If a copy of the MPL was not distributed with this file, You can # obtain one at http://mozilla.org/MPL/2.0/. -add_library( - bitmap +add_library(bitmap bitmap.cpp) - bitmap.cpp -) - -target_include_directories( - bitmap - PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR} -) +target_include_directories(bitmap PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/examples/core/CMakeLists.txt b/examples/core/CMakeLists.txt index a695acd..03520b1 100644 --- a/examples/core/CMakeLists.txt +++ b/examples/core/CMakeLists.txt @@ -7,131 +7,78 @@ # obtain one at http://mozilla.org/MPL/2.0/. # Add the conversion of B-fields to our native format. -add_executable( - convert_bfield - - convert_bfield.cpp -) +add_executable(convert_bfield convert_bfield.cpp) target_link_libraries( convert_bfield - PRIVATE - core - Boost::log - Boost::log_setup - Boost::program_options + core + Boost::log + Boost::log_setup + Boost::program_options ) # Add the conversion of B-fields from CSV to our native format. -add_executable( - convert_bfield_csv - - convert_bfield_csv.cpp -) +add_executable(convert_bfield_csv convert_bfield_csv.cpp) target_link_libraries( convert_bfield_csv - PRIVATE - core - Boost::log - Boost::log_setup - Boost::program_options + core + Boost::log + Boost::log_setup + Boost::program_options ) # Add the first example that can be found in the README. -add_executable( - readme_example_1 - - readme_example_1.cpp -) +add_executable(readme_example_1 readme_example_1.cpp) -target_link_libraries( - readme_example_1 - - PRIVATE - core -) +target_link_libraries(readme_example_1 PRIVATE core) # Add the second example that can be found in the README. -add_executable( - readme_example_2 - - readme_example_2.cpp -) - -target_link_libraries( - readme_example_2 +add_executable(readme_example_2 readme_example_2.cpp) - PRIVATE - core -) +target_link_libraries(readme_example_2 PRIVATE core) # Add the an executable to create 2D slices from 3D fields. -add_executable( - slice3dto2d - - slice3dto2d.cpp -) +add_executable(slice3dto2d slice3dto2d.cpp) target_link_libraries( slice3dto2d - PRIVATE - core - Boost::log - Boost::log_setup - Boost::program_options + core + Boost::log + Boost::log_setup + Boost::program_options ) # Add the an executable to scale up B-fields. -add_executable( - scaleup_bfield - - scaleup_bfield.cpp -) +add_executable(scaleup_bfield scaleup_bfield.cpp) target_link_libraries( scaleup_bfield - PRIVATE - core - Boost::log - Boost::log_setup - Boost::program_options + core + Boost::log + Boost::log_setup + Boost::program_options ) add_library(asm asm.cpp) -target_link_libraries( - asm - - PRIVATE - core -) +target_link_libraries(asm PRIVATE core) # Some libraries which are designed to inspected by the user. add_library(shuffle_asm shuffle_asm.cpp) -target_link_libraries( - shuffle_asm - - PRIVATE - core -) +target_link_libraries(shuffle_asm PRIVATE core) # Executable for generating an testable field. -add_executable( - generate_test_field - - generate_test_field.cpp -) +add_executable(generate_test_field generate_test_field.cpp) target_link_libraries( generate_test_field - PRIVATE - core - Boost::log - Boost::log_setup - Boost::program_options + core + Boost::log + Boost::log_setup + Boost::program_options ) diff --git a/examples/cpu/CMakeLists.txt b/examples/cpu/CMakeLists.txt index 2cb5586..a51a1fc 100644 --- a/examples/cpu/CMakeLists.txt +++ b/examples/cpu/CMakeLists.txt @@ -7,38 +7,28 @@ # obtain one at http://mozilla.org/MPL/2.0/. # Add the 3D field slice rendering tool. -add_executable( - render_slice_cpu - - render_slice.cpp -) +add_executable(render_slice_cpu render_slice.cpp) target_link_libraries( render_slice_cpu - PRIVATE - core - cpu - bitmap - Boost::log - Boost::log_setup - Boost::program_options + core + cpu + bitmap + Boost::log + Boost::log_setup + Boost::program_options ) -add_executable( - render_image_cpu - - render_image.cpp -) +add_executable(render_image_cpu render_image.cpp) target_link_libraries( render_image_cpu - PRIVATE - core - cpu - bitmap - Boost::log - Boost::log_setup - Boost::program_options + core + cpu + bitmap + Boost::log + Boost::log_setup + Boost::program_options ) diff --git a/examples/cuda/CMakeLists.txt b/examples/cuda/CMakeLists.txt index 179bf4d..cb09928 100644 --- a/examples/cuda/CMakeLists.txt +++ b/examples/cuda/CMakeLists.txt @@ -14,39 +14,29 @@ enable_language(CUDA) include(covfie-compiler-options-cuda) # Add the 3D field slice rendering tool based on CUDA. -add_executable( - render_slice_cuda - - render_slice.cu -) +add_executable(render_slice_cuda render_slice.cu) target_link_libraries( render_slice_cuda - PRIVATE - core - cuda - bitmap - Boost::log - Boost::log_setup - Boost::program_options + core + cuda + bitmap + Boost::log + Boost::log_setup + Boost::program_options ) # Add the 3D field slice rendering tool based on CUDA textures. -add_executable( - render_slice_texture_cuda - - render_slice_texture.cu -) +add_executable(render_slice_texture_cuda render_slice_texture.cu) target_link_libraries( render_slice_texture_cuda - PRIVATE - core - cuda - bitmap - Boost::log - Boost::log_setup - Boost::program_options + core + cuda + bitmap + Boost::log + Boost::log_setup + Boost::program_options ) diff --git a/lib/core/CMakeLists.txt b/lib/core/CMakeLists.txt index 88de7d3..20046b0 100644 --- a/lib/core/CMakeLists.txt +++ b/lib/core/CMakeLists.txt @@ -11,30 +11,20 @@ add_library(core INTERFACE) target_include_directories( core INTERFACE - $ - $ + $ + $ ) target_compile_features(core INTERFACE cxx_std_20) if(COVFIE_QUIET) - target_compile_definitions( - core - INTERFACE - COVFIE_QUIET - ) + target_compile_definitions(core INTERFACE COVFIE_QUIET) endif() # Logic to ensure that the core module can be installed properly. -install( - TARGETS core - EXPORT ${PROJECT_NAME}Targets -) +install(TARGETS core EXPORT ${PROJECT_NAME}Targets) -install( - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/covfie - DESTINATION include -) +install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/covfie DESTINATION include) # Hack for people using the disgusting mal-practice of pullling in external # projects via "add_subdirectory"... @@ -45,10 +35,8 @@ if(COVFIE_TEST_HEADERS) include(covfie-functions) file( - GLOB_RECURSE - public_headers - RELATIVE - "${CMAKE_CURRENT_SOURCE_DIR}" + GLOB_RECURSE public_headers + RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/covfie/*.hpp" ) diff --git a/lib/cpu/CMakeLists.txt b/lib/cpu/CMakeLists.txt index 0771f5d..e7aed59 100644 --- a/lib/cpu/CMakeLists.txt +++ b/lib/cpu/CMakeLists.txt @@ -11,28 +11,18 @@ add_library(cpu INTERFACE) target_include_directories( cpu INTERFACE - $ - $ + $ + $ ) target_compile_features(cpu INTERFACE cxx_std_20) # Logic to ensure that the CPU module can be installed properly. -install( - TARGETS cpu - EXPORT ${PROJECT_NAME}Targets -) +install(TARGETS cpu EXPORT ${PROJECT_NAME}Targets) -install( - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/covfie - DESTINATION include -) +install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/covfie DESTINATION include) -target_link_libraries( - cpu - INTERFACE - covfie::core -) +target_link_libraries(cpu INTERFACE covfie::core) # Hack for compatibility add_library(covfie::cpu ALIAS cpu) @@ -42,10 +32,8 @@ if(COVFIE_TEST_HEADERS) include(covfie-functions) file( - GLOB_RECURSE - public_headers - RELATIVE - "${CMAKE_CURRENT_SOURCE_DIR}" + GLOB_RECURSE public_headers + RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/covfie/*.hpp" ) diff --git a/lib/cuda/CMakeLists.txt b/lib/cuda/CMakeLists.txt index c686f50..515f71f 100644 --- a/lib/cuda/CMakeLists.txt +++ b/lib/cuda/CMakeLists.txt @@ -13,8 +13,8 @@ add_library(cuda INTERFACE) target_include_directories( cuda INTERFACE - $ - $ + $ + $ ) target_compile_features(cuda INTERFACE cxx_std_20) @@ -22,20 +22,14 @@ target_compile_features(cuda INTERFACE cxx_std_20) target_link_libraries( cuda INTERFACE - CUDA::cudart - covfie::core + CUDA::cudart + covfie::core ) # Logic to ensure that the CUDA module can be installed properly. -install( - TARGETS cuda - EXPORT ${PROJECT_NAME}Targets -) +install(TARGETS cuda EXPORT ${PROJECT_NAME}Targets) -install( - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/covfie - DESTINATION include -) +install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/covfie DESTINATION include) # Hack for compatibility add_library(covfie::cuda ALIAS cuda) @@ -45,10 +39,8 @@ if(COVFIE_TEST_HEADERS) include(covfie-functions) file( - GLOB_RECURSE - public_headers - RELATIVE - "${CMAKE_CURRENT_SOURCE_DIR}" + GLOB_RECURSE public_headers + RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/covfie/*.hpp" ) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 3295854..2f5b5da 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -9,11 +9,12 @@ # All the tests here will require Google Test, so we will go ahead and set it # up. # Set up GoogleTest. -option(COVFIE_SETUP_GOOGLETEST "Set up the GoogleTest targets explicitly" - TRUE) -option(COVFIE_USE_SYSTEM_GOOGLETEST +option(COVFIE_SETUP_GOOGLETEST "Set up the GoogleTest targets explicitly" TRUE) +option( + COVFIE_USE_SYSTEM_GOOGLETEST "Pick up an existing installation of GoogleTest from the build environment" - TRUE) + TRUE +) if(COVFIE_SETUP_GOOGLETEST) if(COVFIE_USE_SYSTEM_GOOGLETEST) find_package(GTest CONFIG REQUIRED) diff --git a/tests/core/CMakeLists.txt b/tests/core/CMakeLists.txt index abe4792..bb4b07b 100644 --- a/tests/core/CMakeLists.txt +++ b/tests/core/CMakeLists.txt @@ -8,18 +8,11 @@ # We use the Boost filesystem for the creation of some temporary files, so # we'll load that as well. -find_package( - Boost - 1.71.0 - REQUIRED - COMPONENTS - filesystem -) +find_package(Boost 1.71.0 REQUIRED COMPONENTS filesystem) # Create the test executable from the individual test groups. add_executable( test_core - test_utility.cpp test_constant_field.cpp test_transformer_affine.cpp @@ -41,11 +34,10 @@ add_executable( # Ensure that the tests are linked against the required libraries. target_link_libraries( test_core - PUBLIC - core - GTest::gtest - GTest::gtest_main - Boost::filesystem - testing_utils + core + GTest::gtest + GTest::gtest_main + Boost::filesystem + testing_utils ) diff --git a/tests/cpu/CMakeLists.txt b/tests/cpu/CMakeLists.txt index f6c1477..1800c40 100644 --- a/tests/cpu/CMakeLists.txt +++ b/tests/cpu/CMakeLists.txt @@ -7,19 +7,14 @@ # obtain one at http://mozilla.org/MPL/2.0/. # Create the test executable from the individual test groups. -add_executable( - test_cpu - - test_cpu_array_backend.cpp -) +add_executable(test_cpu test_cpu_array_backend.cpp) # Ensure that the tests are linked against the required libraries. target_link_libraries( test_cpu - PUBLIC - core - cpu - GTest::gtest - GTest::gtest_main + core + cpu + GTest::gtest + GTest::gtest_main ) diff --git a/tests/cuda/CMakeLists.txt b/tests/cuda/CMakeLists.txt index f584e53..6183744 100644 --- a/tests/cuda/CMakeLists.txt +++ b/tests/cuda/CMakeLists.txt @@ -13,19 +13,14 @@ enable_language(CUDA) include(covfie-compiler-options-cuda) # Create the test executable from the individual test groups. -add_executable( - test_cuda - - test_cuda_array.cu -) +add_executable(test_cuda test_cuda_array.cu) # Ensure that the tests are linked against the required libraries. target_link_libraries( test_cuda - PUBLIC - core - cuda - GTest::gtest - GTest::gtest_main + core + cuda + GTest::gtest + GTest::gtest_main ) diff --git a/tests/googletest/CMakeLists.txt b/tests/googletest/CMakeLists.txt index d4b4383..1abee1d 100644 --- a/tests/googletest/CMakeLists.txt +++ b/tests/googletest/CMakeLists.txt @@ -7,37 +7,46 @@ # obtain one at http://mozilla.org/MPL/2.0/. # CMake include(s). -cmake_minimum_required( VERSION 3.11 ) -include( FetchContent ) +cmake_minimum_required(VERSION 3.11) +include(FetchContent) # Silence FetchContent warnings with CMake >=3.24. if(POLICY CMP0135) - cmake_policy(SET CMP0135 NEW) + cmake_policy(SET CMP0135 NEW) endif() # Tell the user what's happening. message(STATUS "Building GoogleTest as part of the Covfie project") # Declare where to get GoogleTest from. -FetchContent_Declare(GoogleTest - URL "https://github.com/google/googletest/archive/refs/tags/v1.14.0.tar.gz" - URL_MD5 "c8340a482851ef6a3fe618a082304cfc") +FetchContent_Declare( + GoogleTest + URL + "https://github.com/google/googletest/archive/refs/tags/v1.14.0.tar.gz" + URL_MD5 "c8340a482851ef6a3fe618a082304cfc" +) # Options used in the build of GoogleTest. set(BUILD_GMOCK FALSE CACHE BOOL "Turn off the build of GMock") set(INSTALL_GTEST FALSE CACHE BOOL "Turn off the installation of GoogleTest") -if( WIN32 ) - set(gtest_force_shared_crt TRUE CACHE BOOL - "Use shared (DLL) run-time library, even with static libraries") +if(WIN32) + set(gtest_force_shared_crt + TRUE + CACHE BOOL + "Use shared (DLL) run-time library, even with static libraries" + ) endif() # Silence some warnings with modern versions of CMake on macOS. set(CMAKE_MACOSX_RPATH TRUE) # Get it into the current directory. -FetchContent_Populate( GoogleTest ) -add_subdirectory("${googletest_SOURCE_DIR}" "${googletest_BINARY_DIR}" - EXCLUDE_FROM_ALL) +FetchContent_Populate(GoogleTest) +add_subdirectory( + "${googletest_SOURCE_DIR}" + "${googletest_BINARY_DIR}" + EXCLUDE_FROM_ALL +) # Set up aliases for the GTest targets with the same name that they have # when we find GTest pre-installed. diff --git a/tests/utils/CMakeLists.txt b/tests/utils/CMakeLists.txt index 297a63e..d0b0151 100644 --- a/tests/utils/CMakeLists.txt +++ b/tests/utils/CMakeLists.txt @@ -6,37 +6,17 @@ # v. 2.0. If a copy of the MPL was not distributed with this file, You can # obtain one at http://mozilla.org/MPL/2.0/. -find_package( - Boost - 1.71.0 - REQUIRED - COMPONENTS - filesystem -) - -add_library( - testing_utils +find_package(Boost 1.71.0 REQUIRED COMPONENTS filesystem) - tmp_file.cpp -) +add_library(testing_utils tmp_file.cpp) # Ensure that the utils. -target_link_libraries( - testing_utils - - PUBLIC - Boost::filesystem -) +target_link_libraries(testing_utils PUBLIC Boost::filesystem) target_include_directories( testing_utils PUBLIC - - $ + $ ) -target_compile_definitions( - testing_utils - PRIVATE - _CRT_SECURE_NO_WARNINGS -) +target_compile_definitions(testing_utils PRIVATE _CRT_SECURE_NO_WARNINGS)