-
Notifications
You must be signed in to change notification settings - Fork 206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[REVIEW] CMake target cleanup, formatting, linting #604
Merged
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
2a3b207
Further CMake cleanup, add formatting and linting
kkraus14 f5b2879
set up pre-commit hook for cmake-format and cmake-lint
kkraus14 aa4e344
fix cmake breakages, fix all known linting issues
kkraus14 1b38e54
pin cmake-format version
kkraus14 62f93eb
remove unused config
kkraus14 56f0b81
fix function casing
kkraus14 3dba085
more comment cleanup
kkraus14 51dd405
match clang-format settings of 100 width, 2 spaces tabs
kkraus14 02e10e5
changelog
kkraus14 8e51a74
align pre-commit and conda versions with cudf
kkraus14 ecec53b
tweak some additional formatting config, fix cmake build issues
kkraus14 676822e
further config tweak to prevent vertical layout in situations
kkraus14 7efb644
Move compile definitions down to benchmarks / tests
kkraus14 1e0cd0a
Remove 'GPU_ARCHS' and move CUDA language down to tests/benchmarks
kkraus14 8b0f765
Merge branch 'branch-0.17' into cmake_target_cleanup
kkraus14 2e09862
Merge branch 'branch-0.17' into cmake_target_cleanup
kkraus14 ee5d025
temporarily upgrade cmake via gpu ci script
kkraus14 40b8bbc
typo in conda command
kkraus14 1c4be3b
need to call 'enable_testing' in root cmake
kkraus14 4f4f537
hook up formatting and linting to CI
kkraus14 5918222
add cmake-format to style checker conda environment temporarily
kkraus14 d5fe0f6
Merge branch 'branch-0.17' into cmake_target_cleanup
kkraus14 b1a1df8
remove 'cmake-format' install from style ci script
kkraus14 da29d84
Merge branch 'branch-0.17' into cmake_target_cleanup
kkraus14 080544a
use exclude list instead of include list
kkraus14 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,37 @@ | ||
repos: | ||
- repo: https://github.com/timothycrosley/isort | ||
rev: 5.0.4 | ||
hooks: | ||
- id: isort | ||
- repo: https://github.com/ambv/black | ||
rev: stable | ||
hooks: | ||
- id: black | ||
- repo: https://gitlab.com/pycqa/flake8 | ||
rev: 3.8.1 | ||
hooks: | ||
- id: flake8 | ||
alias: flake8 | ||
name: flake8 | ||
args: ["--config=python/.flake8"] | ||
types: [python] | ||
- repo: https://gitlab.com/pycqa/flake8 | ||
rev: 3.8.1 | ||
hooks: | ||
- id: flake8 | ||
alias: flake8-cython | ||
name: flake8-cython | ||
args: ["--config=python/.flake8.cython"] | ||
types: [cython] | ||
- repo: https://github.com/timothycrosley/isort | ||
rev: 5.0.7 | ||
hooks: | ||
- id: isort | ||
- repo: https://github.com/ambv/black | ||
rev: 19.10b0 | ||
hooks: | ||
- id: black | ||
- repo: https://gitlab.com/pycqa/flake8 | ||
rev: 3.8.3 | ||
hooks: | ||
- id: flake8 | ||
alias: flake8 | ||
name: flake8 | ||
args: ["--config=python/.flake8"] | ||
types: [python] | ||
- id: flake8 | ||
alias: flake8-cython | ||
name: flake8-cython | ||
args: ["--config=python/.flake8.cython"] | ||
types: [cython] | ||
- repo: https://github.com/cheshirekow/cmake-format-precommit | ||
rev: v0.6.11 | ||
hooks: | ||
- id: cmake-format | ||
name: cmake-format | ||
args: ["--config-files", "cmake/config.json", "--in-place", "--"] | ||
types: [file] # override `types: [cmake]` | ||
files: \.(cmake(\.in)?)$|CMakeLists\.txt | ||
- id: cmake-lint | ||
args: ["--config-files", "cmake/config.json", "--"] | ||
types: [file] # override `types: [cmake]` | ||
files: \.(cmake(\.in)?)$|CMakeLists\.txt | ||
|
||
default_language_version: | ||
python: python3 | ||
python: python3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,166 +1,130 @@ | ||
#============================================================================= | ||
# ============================================================================= | ||
# Copyright (c) 2018, NVIDIA CORPORATION. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except | ||
# in compliance with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
#============================================================================= | ||
cmake_minimum_required(VERSION 3.17...3.18 FATAL_ERROR) | ||
# Unless required by applicable law or agreed to in writing, software distributed under the License | ||
# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
# or implied. See the License for the specific language governing permissions and limitations under | ||
# the License. | ||
# ============================================================================= | ||
cmake_minimum_required(VERSION 3.18...3.18 FATAL_ERROR) | ||
|
||
project(RMM VERSION 0.17.0 LANGUAGES C CXX CUDA) | ||
project( | ||
RMM | ||
VERSION 0.17.0 | ||
LANGUAGES CXX) | ||
|
||
include(cmake/CPM.cmake) | ||
include(cmake/Modules/CPM.cmake) | ||
include(cmake/Modules/RMM_thirdparty.cmake) | ||
|
||
################################################################################################### | ||
# - build type | ||
# build type | ||
|
||
# Set a default build type if none was specified | ||
set(DEFAULT_BUILD_TYPE "Release") | ||
|
||
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) | ||
message(STATUS "Setting build type to '${DEFAULT_BUILD_TYPE}' since none specified.") | ||
set(CMAKE_BUILD_TYPE "${DEFAULT_BUILD_TYPE}" CACHE | ||
STRING "Choose the type of build." FORCE) | ||
message(STATUS "RMM: Setting build type to '${DEFAULT_BUILD_TYPE}' since none specified.") | ||
set(CMAKE_BUILD_TYPE | ||
"${DEFAULT_BUILD_TYPE}" | ||
CACHE STRING "Choose the type of build." FORCE) | ||
# Set the possible values of build type for cmake-gui | ||
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS | ||
"Debug" "Release" "MinSizeRel" "RelWithDebInfo") | ||
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" | ||
"RelWithDebInfo") | ||
endif() | ||
|
||
################################################################################################### | ||
# - compiler options | ||
|
||
set(CMAKE_CXX_STANDARD 14) | ||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
|
||
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wno-error=deprecated-declarations") | ||
endif(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") | ||
|
||
################################################################################################### | ||
# - build options | ||
# build options | ||
|
||
option(BUILD_TESTS "Configure CMake to build tests" ON) | ||
option(BUILD_BENCHMARKS "Configure CMake to build (google) benchmarks" OFF) | ||
|
||
option(DISABLE_DEPRECATION_WARNING "Disable warnings generated from deprecated declarations." OFF) | ||
if(DISABLE_DEPRECATION_WARNING) | ||
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Xcompiler -Wno-deprecated-declarations") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations") | ||
endif(DISABLE_DEPRECATION_WARNING) | ||
|
||
# cudart can be statically linked or dynamically linked the python ecosystem wants dynamic linking | ||
option(CUDA_STATIC_RUNTIME "Statically link the CUDA runtime" OFF) | ||
|
||
################################################################################################### | ||
# find packages we depend on | ||
|
||
find_package(CUDAToolkit REQUIRED) | ||
|
||
################################################################################################### | ||
# cmake modules | ||
|
||
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH}) | ||
|
||
################################################################################################### | ||
# third-party dependencies | ||
|
||
include(RMM_thirdparty) | ||
|
||
################################################################################################### | ||
# library targets | ||
|
||
add_library(rmm INTERFACE) | ||
add_library(rmm::rmm ALIAS rmm) | ||
|
||
target_include_directories(rmm INTERFACE | ||
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>" | ||
"$<INSTALL_INTERFACE:include>" | ||
) | ||
target_include_directories(rmm INTERFACE "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>" | ||
"$<INSTALL_INTERFACE:include>") | ||
|
||
if(CUDA_STATIC_RUNTIME) | ||
message(STATUS "Enabling static linking of cudart") | ||
message(STATUS "RMM: Enabling static linking of cudart") | ||
target_link_libraries(rmm INTERFACE CUDA::cudart_static) | ||
else() | ||
target_link_libraries(rmm INTERFACE CUDA::cudart) | ||
endif(CUDA_STATIC_RUNTIME) | ||
|
||
target_link_libraries(rmm INTERFACE rmm::Thrust spdlog::spdlog_header_only ${CMAKE_DL_LIBS}) | ||
target_link_libraries(rmm INTERFACE rmm::Thrust) | ||
target_link_libraries(rmm INTERFACE spdlog::spdlog_header_only) | ||
target_compile_features(rmm INTERFACE cxx_std_14 cuda_std_14) | ||
|
||
################################################################################################### | ||
# Set logging level. Must go before including gtests and benchmarks. | ||
# Set logging level. Must go before including gtests and benchmarks. | ||
|
||
set(RMM_LOGGING_LEVEL "INFO" CACHE STRING "Choose the logging level.") | ||
set(RMM_LOGGING_LEVEL | ||
"INFO" | ||
CACHE STRING "Choose the logging level.") | ||
# Set the possible values of build type for cmake-gui | ||
set_property(CACHE RMM_LOGGING_LEVEL PROPERTY STRINGS | ||
"TRACE" "DEBUG" "INFO" "WARN" "ERROR" "CRITICAL" "OFF") | ||
message(STATUS "RMM_LOGGING_LEVEL = '${RMM_LOGGING_LEVEL}'.") | ||
set_property(CACHE RMM_LOGGING_LEVEL PROPERTY STRINGS "TRACE" "DEBUG" "INFO" "WARN" "ERROR" | ||
"CRITICAL" "OFF") | ||
message(STATUS "RMM: RMM_LOGGING_LEVEL = '${RMM_LOGGING_LEVEL}'") | ||
|
||
################################################################################################### | ||
# add gtest | ||
# optionally build tests | ||
|
||
if(BUILD_TESTS) | ||
include(CTest) | ||
add_subdirectory(tests) | ||
enable_testing() | ||
add_subdirectory(tests) | ||
endif(BUILD_TESTS) | ||
|
||
################################################################################################### | ||
# add google benchmark | ||
|
||
if(BUILD_BENCHMARKS) | ||
add_subdirectory(benchmarks) | ||
endif(BUILD_BENCHMARKS) | ||
|
||
################################################################################################### | ||
# install targets | ||
|
||
include(GNUInstallDirs) | ||
set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/rmm) | ||
|
||
install(TARGETS rmm | ||
EXPORT rmm-targets) | ||
install(TARGETS rmm EXPORT rmm-targets) | ||
|
||
install(DIRECTORY include/rmm | ||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) | ||
install(DIRECTORY include/rmm DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) | ||
|
||
include(CMakePackageConfigHelpers) | ||
configure_package_config_file( | ||
cmake/rmm-config.cmake.in | ||
${RMM_BINARY_DIR}/rmm-config.cmake | ||
INSTALL_DESTINATION ${INSTALL_CONFIGDIR} | ||
) | ||
|
||
write_basic_package_version_file( | ||
${RMM_BINARY_DIR}/rmm-config-version.cmake | ||
COMPATIBILITY SameMinorVersion | ||
) | ||
|
||
install(EXPORT rmm-targets | ||
configure_package_config_file(cmake/rmm-config.cmake.in ${RMM_BINARY_DIR}/rmm-config.cmake | ||
INSTALL_DESTINATION ${INSTALL_CONFIGDIR}) | ||
|
||
write_basic_package_version_file(${RMM_BINARY_DIR}/rmm-config-version.cmake | ||
COMPATIBILITY SameMinorVersion) | ||
|
||
install( | ||
EXPORT rmm-targets | ||
FILE rmm-targets.cmake | ||
NAMESPACE rmm:: | ||
DESTINATION ${INSTALL_CONFIGDIR} | ||
) | ||
|
||
install(FILES | ||
${RMM_BINARY_DIR}/rmm-config.cmake | ||
${RMM_BINARY_DIR}/rmm-config-version.cmake | ||
${RMM_SOURCE_DIR}/cmake/install/FindThrust.cmake | ||
DESTINATION ${INSTALL_CONFIGDIR} | ||
) | ||
|
||
################################################################################################### | ||
# make documentation | ||
DESTINATION ${INSTALL_CONFIGDIR}) | ||
|
||
install(FILES ${RMM_BINARY_DIR}/rmm-config.cmake ${RMM_BINARY_DIR}/rmm-config-version.cmake | ||
${RMM_SOURCE_DIR}/cmake/install/FindThrust.cmake DESTINATION ${INSTALL_CONFIGDIR}) | ||
|
||
add_custom_command(OUTPUT RMM_DOXYGEN | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/doxygen | ||
COMMAND doxygen Doxyfile | ||
VERBATIM) | ||
# make documentation | ||
|
||
add_custom_target(rmm_doc DEPENDS RMM_DOXYGEN) | ||
add_custom_command( | ||
OUTPUT RMM_DOXYGEN | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/doxygen | ||
COMMAND doxygen Doxyfile | ||
VERBATIM | ||
COMMENT "Custom command for RMM doxygen docs") | ||
|
||
add_custom_target( | ||
rmm_doc | ||
DEPENDS RMM_DOXYGEN | ||
COMMENT "Target for the custom command to build the RMM doxygen docs") |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this option even needed anymore? RMM doesn't produce a binary object anymore, so if someone wants to statically link against cudart, they can do that when compiling their binary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we don't have this then the CUDA dependency isn't properly enforced on the RMM target and it becomes the downstream project's responsibility to add it which is problematic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even though the library is header-only, it still needs to know what libraries to link against when it's being used -- either in the tests or in a downstream project. The choice of static vs dynamic runtime does get recorded together with the target, and picked up downstream.
Maybe another question is whether the static option is still used / needed anywhere in the first place?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You typically want to static link the CUDA libraries if you're not in a conda controlled environment. This allows shipping your application / binary without the user needing the CUDA toolkit installed.