Skip to content
This repository was archived by the owner on Mar 20, 2023. It is now read-only.

Commit b1ea553

Browse files
pramodkOmar Awile
andauthored
Integrate hpc coding conventions and reformat CMake files (#361)
* Introduce hpc-coding-conventions and update CMakeLists.txt accordingly. * Add .cmake-format.changes.yaml for project specific changes * Update cmake files according to cmake-format 0.6.0 * Various nitpicks to prepare PR for review * nmodl submodule updated latest master * Remove .clang-format file to avoid conflict with coding convention module Co-authored-by: Omar Awile <[email protected]>
1 parent 5fb8978 commit b1ea553

32 files changed

+696
-772
lines changed

.clang-format

Lines changed: 0 additions & 94 deletions
This file was deleted.

.cmake-format.changes.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
additional_commands:
2+
cuda_add_library:
3+
pargs: '*'
4+
flags: ["STATIC", "SHARED", "MODULE", "EXCLUDE_FROM_ALL"]
5+
kwargs:
6+
OPTIONS: '*'

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,6 @@
1010
[submodule "external/Random123"]
1111
path = external/Random123
1212
url = https://github.com/BlueBrain/Random123.git
13+
[submodule "CMake/hpc-coding-conventions"]
14+
path = CMake/hpc-coding-conventions
15+
url = https://github.com/BlueBrain/hpc-coding-conventions.git

CMake/AddCLI11Submodule.cmake

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
# =============================================================================
2-
# Copyright (C) 2020 Blue Brain Project
2+
# Copyright (C) 2016-2020 Blue Brain Project
33
#
44
# See top-level LICENSE file for details.
55
# =============================================================================
66

7-
87
include(FindPackageHandleStandardArgs)
98
find_package(FindPkgConfig QUIET)
10-
find_path(CLI11_PROJ NAMES CMakeLists.txt PATHS "${CORENEURON_PROJECT_SOURCE_DIR}/external/CLI11")
9+
10+
find_path(
11+
CLI11_PROJ
12+
NAMES CMakeLists.txt
13+
PATHS "${CORENEURON_PROJECT_SOURCE_DIR}/external/CLI11")
14+
1115
find_package_handle_standard_args(CLI11 REQUIRED_VARS CLI11_PROJ)
1216

1317
if(NOT CLI11_FOUND)
@@ -16,8 +20,9 @@ if(NOT CLI11_FOUND)
1620
message(FATAL_ERROR "git not found, clone repository with --recursive")
1721
endif()
1822
message(STATUS "Sub-module CLI11 missing: running git submodule update --init --recursive")
19-
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive --
20-
${CORENEURON_PROJECT_SOURCE_DIR}/external/CLI11
21-
WORKING_DIRECTORY ${CORENEURON_PROJECT_SOURCE_DIR})
23+
execute_process(
24+
COMMAND
25+
${GIT_EXECUTABLE} submodule update --init --recursive --
26+
${CORENEURON_PROJECT_SOURCE_DIR}/external/CLI11
27+
WORKING_DIRECTORY ${CORENEURON_PROJECT_SOURCE_DIR})
2228
endif()
23-

CMake/AddMod2cSubmodule.cmake

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
# =============================================================================
2-
# Copyright (C) 2016-2019 Blue Brain Project
2+
# Copyright (C) 2016-2020 Blue Brain Project
33
#
44
# See top-level LICENSE file for details.
55
# =============================================================================
66

77
include(ExternalProject)
8-
98
find_package(FindPkgConfig QUIET)
10-
find_path(MOD2C_PROJ NAMES CMakeLists.txt PATHS "${CORENEURON_PROJECT_SOURCE_DIR}/external/mod2c")
9+
10+
find_path(
11+
MOD2C_PROJ
12+
NAMES CMakeLists.txt
13+
PATHS "${CORENEURON_PROJECT_SOURCE_DIR}/external/mod2c")
14+
1115
find_package_handle_standard_args(MOD2C REQUIRED_VARS MOD2C_PROJ)
1216

1317
if(NOT MOD2C_FOUND)
@@ -16,24 +20,23 @@ if(NOT MOD2C_FOUND)
1620
message(FATAL_ERROR "git not found, clone repository with --recursive")
1721
endif()
1822
message(STATUS "Sub-module mod2c missing : running git submodule update --init --recursive")
19-
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive --
20-
${CORENEURON_PROJECT_SOURCE_DIR}/external/mod2c
21-
WORKING_DIRECTORY ${CORENEURON_PROJECT_SOURCE_DIR})
23+
execute_process(
24+
COMMAND
25+
${GIT_EXECUTABLE} submodule update --init --recursive --
26+
${CORENEURON_PROJECT_SOURCE_DIR}/external/mod2c
27+
WORKING_DIRECTORY ${CORENEURON_PROJECT_SOURCE_DIR})
2228
else()
2329
message(STATUS "Using mod2c submodule from ${MOD2C_PROJ}")
2430
endif()
2531

2632
set(ExternalProjectCMakeArgs
27-
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
28-
-DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}
33+
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}
2934
-DCMAKE_C_COMPILER=${CORENRN_FRONTEND_C_COMPILER}
3035
-DCMAKE_CXX_COMPILER=${CORENRN_FRONTEND_CXX_COMPILER})
3136

32-
externalproject_add(mod2c
33-
BUILD_ALWAYS
34-
1
35-
SOURCE_DIR
36-
${CORENEURON_PROJECT_SOURCE_DIR}/external/mod2c
37-
GIT_SUBMODULES
38-
CMAKE_ARGS
39-
${ExternalProjectCMakeArgs})
37+
ExternalProject_Add(
38+
mod2c
39+
BUILD_ALWAYS 1
40+
SOURCE_DIR ${CORENEURON_PROJECT_SOURCE_DIR}/external/mod2c
41+
GIT_SUBMODULES
42+
CMAKE_ARGS ${ExternalProjectCMakeArgs})

CMake/AddNmodlSubmodule.cmake

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
# =============================================================================
2-
# Copyright (C) 2016-2019 Blue Brain Project
2+
# Copyright (C) 2016-2020 Blue Brain Project
33
#
44
# See top-level LICENSE file for details.
55
# =============================================================================
66

7-
87
find_package(FindPkgConfig QUIET)
9-
find_path(NMODL_PROJ NAMES CMakeLists.txt PATHS "${CORENEURON_PROJECT_SOURCE_DIR}/external/nmodl")
8+
9+
find_path(
10+
NMODL_PROJ
11+
NAMES CMakeLists.txt
12+
PATHS "${CORENEURON_PROJECT_SOURCE_DIR}/external/nmodl")
13+
1014
find_package_handle_standard_args(NMODL REQUIRED_VARS NMODL_PROJ)
1115

1216
if(NOT NMODL_FOUND)
@@ -15,12 +19,13 @@ if(NOT NMODL_FOUND)
1519
message(FATAL_ERROR "git not found, clone repository with --recursive")
1620
endif()
1721
message(STATUS "Sub-module nmodl missing : running git submodule update --init --recursive")
18-
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive --
19-
${CORENEURON_PROJECT_SOURCE_DIR}/external/nmodl
20-
WORKING_DIRECTORY ${CORENEURON_PROJECT_SOURCE_DIR})
22+
execute_process(
23+
COMMAND
24+
${GIT_EXECUTABLE} submodule update --init --recursive --
25+
${CORENEURON_PROJECT_SOURCE_DIR}/external/nmodl
26+
WORKING_DIRECTORY ${CORENEURON_PROJECT_SOURCE_DIR})
2127
else()
2228
message(STATUS "Using nmodl submodule from ${NMODL_PROJ}")
2329
endif()
2430

2531
add_subdirectory(${CORENEURON_PROJECT_SOURCE_DIR}/external/nmodl)
26-

CMake/AddRandom123Submodule.cmake

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
# =============================================================================
2-
# Copyright (C) 2020 Blue Brain Project
2+
# Copyright (C) 2016-2020 Blue Brain Project
33
#
44
# See top-level LICENSE file for details.
55
# =============================================================================
66

7-
87
include(FindPackageHandleStandardArgs)
98
find_package(FindPkgConfig QUIET)
10-
find_path(Random123_PROJ NAMES LICENSE PATHS "${CORENEURON_PROJECT_SOURCE_DIR}/external/Random123")
9+
10+
find_path(
11+
Random123_PROJ
12+
NAMES LICENSE
13+
PATHS "${CORENEURON_PROJECT_SOURCE_DIR}/external/Random123")
14+
1115
find_package_handle_standard_args(Random123 REQUIRED_VARS Random123_PROJ)
1216

1317
if(NOT Random123_FOUND)
@@ -16,8 +20,9 @@ if(NOT Random123_FOUND)
1620
message(FATAL_ERROR "git not found, clone repository with --recursive")
1721
endif()
1822
message(STATUS "Sub-module Random123 missing: running git submodule update --init --recursive")
19-
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive --
20-
${CORENEURON_PROJECT_SOURCE_DIR}/external/Random123
21-
WORKING_DIRECTORY ${CORENEURON_PROJECT_SOURCE_DIR})
23+
execute_process(
24+
COMMAND
25+
${GIT_EXECUTABLE} submodule update --init --recursive --
26+
${CORENEURON_PROJECT_SOURCE_DIR}/external/Random123
27+
WORKING_DIRECTORY ${CORENEURON_PROJECT_SOURCE_DIR})
2228
endif()
23-

CMake/CMakeDetermineISPCCompiler.cmake

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
# =============================================================================
2-
# Copyright (C) 2016-2019 Blue Brain Project
2+
# Copyright (C) 2016-2020 Blue Brain Project
33
#
44
# See top-level LICENSE file for details.
55
# =============================================================================
66

7-
# Find the compiler
7+
# Find the ISPC compiler
88
find_program(
9-
CMAKE_ISPC_COMPILER
10-
NAMES $ENV{ISPC} ispc
11-
PATHS ENV PATH
12-
DOC "ISPC compiler"
13-
)
9+
CMAKE_ISPC_COMPILER
10+
NAMES $ENV{ISPC} ispc
11+
PATHS ENV PATH
12+
DOC "ISPC compiler")
1413
mark_as_advanced(CMAKE_ISPC_COMPILER)
1514

1615
set(CMAKE_ISPC_SOURCE_FILE_EXTENSIONS ispc)

CMake/CMakeISPCInformation.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
set(CMAKE_INCLUDE_FLAG_ISPC "-I")
99

1010
if(NOT CMAKE_ISPC_COMPILE_OBJECT)
11-
set(CMAKE_ISPC_COMPILE_OBJECT "<CMAKE_ISPC_COMPILER> <FLAGS> <INCLUDES> <SOURCE> -o <OBJECT>")
11+
set(CMAKE_ISPC_COMPILE_OBJECT "<CMAKE_ISPC_COMPILER> <FLAGS> <INCLUDES> <SOURCE> -o <OBJECT>")
1212
endif()
1313
set(CMAKE_ISPC_INFORMATION_LOADED 1)

CMake/CMakeTestISPCCompiler.cmake

Lines changed: 37 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,36 @@
11
if(CMAKE_ISPC_COMPILER_FORCED)
2-
# The compiler configuration was forced by the user.
3-
# Assume the user has configured all compiler information.
2+
# ~~~
3+
# The compiler configuration was forced by the user. Assume the user has
4+
# configured all compiler information.
5+
# ~~~
46
set(CMAKE_ISPC_COMPILER_WORKS TRUE)
57
return()
68
endif()
79

8-
set(CMAKE_ISPC_COMPILER_WORKS 1 CACHE INTERNAL "")
10+
set(CMAKE_ISPC_COMPILER_WORKS
11+
1
12+
CACHE INTERNAL "")
913

10-
# Remove any cached result from an older CMake version.
11-
# We now store this in CMakeISPCCompiler.cmake.
14+
# Remove any cached result from an older CMake version. We now store this in
15+
# CMakeISPCCompiler.cmake.
1216
unset(CMAKE_ISPC_COMPILER_WORKS CACHE)
1317

14-
# This file is used by EnableLanguage in cmGlobalGenerator to
15-
# determine that the selected ispc compiler can actually compile
16-
# and the most basic program. If not, a fatal error
17-
# is set and cmake stops processing commands and will not generate
18-
# any makefiles or projects.
18+
# ~~~
19+
# This file is used by EnableLanguage in cmGlobalGenerator to determine that the selected
20+
# ispc compiler can actually compile and the most basic program. If not, a fatal error is
21+
# set and cmake stops processing commands and will not generate any makefiles or projects.
22+
# ~~~
1923
if(NOT CMAKE_ISPC_COMPILER_WORKS)
20-
PrintTestCompilerStatus("ISPC" "")
24+
printtestcompilerstatus("ISPC" "")
2125
file(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/kernel.ispc
22-
"export uniform int kernel(uniform int){return 0;}\n")
26+
"export uniform int kernel(uniform int){return 0;}\n")
2327

24-
execute_process(COMMAND ${CMAKE_ISPC_COMPILER} "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/kernel.ispc"
25-
OUTPUT_VARIABLE __CMAKE_ISPC_COMPILER_OUTPUT
26-
ERROR_VARIABLE __CMAKE_ISPC_COMPILER_ERROR
27-
RESULT_VARIABLE ISPC_RESULT)
28+
execute_process(
29+
COMMAND ${CMAKE_ISPC_COMPILER}
30+
"${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/kernel.ispc"
31+
OUTPUT_VARIABLE __CMAKE_ISPC_COMPILER_OUTPUT
32+
ERROR_VARIABLE __CMAKE_ISPC_COMPILER_ERROR
33+
RESULT_VARIABLE ISPC_RESULT)
2834

2935
if(${ISPC_RESULT})
3036
set(CMAKE_ISPC_COMPILER_WORKS 0)
@@ -37,25 +43,28 @@ if(NOT CMAKE_ISPC_COMPILER_WORKS)
3743
set(ISPC_TEST_WAS_RUN 1)
3844
endif()
3945

46+
# Print compiler status
4047
if(NOT CMAKE_ISPC_COMPILER_WORKS)
41-
PrintTestCompilerStatus("ISPC" " -- broken")
48+
printtestcompilerstatus("ISPC" " -- broken")
4249
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
43-
"Determining if the ISPC compiler works failed with "
44-
"the following output:\n${__CMAKE_ISPC_COMPILER_OUTPUT}\n\n")
45-
string(REPLACE "\n" "\n " _output "${__CMAKE_ISPC_COMPILER_OUTPUT} ${__CMAKE_ISPC_COMPILER_ERROR}")
46-
message(FATAL_ERROR "The ISPC compiler\n \"${CMAKE_ISPC_COMPILER}\"\n"
47-
"is not able to compile a simple test program.\nIt fails "
48-
"with the following output:\n ${_output}\n\n"
49-
"CMake will not be able to correctly generate this project.")
50+
"Determining if the ISPC compiler works failed with "
51+
"the following output:\n${__CMAKE_ISPC_COMPILER_OUTPUT}\n\n")
52+
string(REPLACE "\n" "\n " _output
53+
"${__CMAKE_ISPC_COMPILER_OUTPUT} ${__CMAKE_ISPC_COMPILER_ERROR}")
54+
message(
55+
FATAL_ERROR
56+
"The ISPC compiler\n \"${CMAKE_ISPC_COMPILER}\"\n"
57+
"is not able to compile a simple test program.\nIt fails "
58+
"with the following output:\n ${_output}\n\n"
59+
"CMake will not be able to correctly generate this project.")
5060
else()
5161
if(ISPC_TEST_WAS_RUN)
52-
PrintTestCompilerStatus("ISPC" " -- works")
62+
printtestcompilerstatus("ISPC" " -- works")
5363
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
54-
"Determining if the ISPC compiler works passed with "
55-
"the following output:\n${__CMAKE_ISPC_COMPILER_OUTPUT}\n\n")
64+
"Determining if the ISPC compiler works passed with "
65+
"the following output:\n${__CMAKE_ISPC_COMPILER_OUTPUT}\n\n")
5666
endif()
5767
endif()
5868

59-
6069
unset(__CMAKE_ISPC_COMPILER_OUTPUT)
6170
unset(__CMAKE_ISPC_COMPILER_ERROR)

0 commit comments

Comments
 (0)