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

Commit 7d80ff8

Browse files
authored
Apply cmake-format consistently (#466)
* Apply cmake-format - update github action to run cmake-format as well - run cmake-format on all project files - Update CMake/hpc-coding-conventions to support cmake-format 0.16.3
1 parent d1da3e1 commit 7d80ff8

19 files changed

+140
-107
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: clang-cmake-format-check
2+
on:
3+
push:
4+
5+
jobs:
6+
build:
7+
name: clang-cmake-format-check
8+
runs-on: ubuntu-20.04
9+
steps:
10+
- name: Fetch repository
11+
uses: actions/checkout@v2
12+
- name: Install clang-format 11
13+
run: sudo apt-get install clang-format-11 python3-pip
14+
- name: Install cmake-format 0.6.13
15+
run: python3 -m pip install cmake-format==0.6.13
16+
- name: Configure
17+
shell: bash
18+
working-directory: ${{runner.workspace}}/CoreNeuron
19+
run: |
20+
export PATH=/home/runner/.local/bin:$PATH
21+
mkdir BUILD && cd BUILD
22+
cmake -DCORENRN_CLANG_FORMAT=ON -DCORENRN_CMAKE_FORMAT=ON -DCORENRN_ENABLE_MPI=OFF -DCORENRN_ENABLE_OPENMP=OFF -DClangFormat_EXECUTABLE=$(which clang-format-11) -DCMakeFormat_EXECUTABLE=$(which cmake-format) ..
23+
- name: Run clang-format
24+
shell: bash
25+
working-directory: ${{runner.workspace}}/CoreNeuron/BUILD
26+
run: make check-clang-format
27+
- name: Run cmake-format
28+
shell: bash
29+
working-directory: ${{runner.workspace}}/CoreNeuron/BUILD
30+
run: make check-cmake-format

.github/workflows/clang_format_check.yaml

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

CMake/AddCLI11Submodule.cmake

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ if(NOT CLI11_FOUND)
2121
endif()
2222
message(STATUS "Sub-module CLI11 missing: running git submodule update --init")
2323
execute_process(
24-
COMMAND
25-
${GIT_EXECUTABLE} submodule update --init --
26-
${CORENEURON_PROJECT_SOURCE_DIR}/external/CLI11
24+
COMMAND ${GIT_EXECUTABLE} submodule update --init --
25+
${CORENEURON_PROJECT_SOURCE_DIR}/external/CLI11
2726
WORKING_DIRECTORY ${CORENEURON_PROJECT_SOURCE_DIR})
2827
endif()

CMake/AddHpcCodingConvSubmodule.cmake

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ include(FindPackageHandleStandardArgs)
88
find_package(FindPkgConfig QUIET)
99

1010
find_path(
11-
HpcCodingConv_PROJ
11+
HpcCodingConv_PROJ
1212
NAMES setup.cfg
1313
PATHS "${CORENEURON_PROJECT_SOURCE_DIR}/CMake/hpc-coding-conventions/")
1414

@@ -19,10 +19,10 @@ if(NOT HpcCodingConv_FOUND)
1919
if(NOT ${GIT_FOUND})
2020
message(FATAL_ERROR "git not found, clone repository with --recursive")
2121
endif()
22-
message(STATUS "Sub-module CMake/hpc-coding-conventions missing: running git submodule update --init")
22+
message(
23+
STATUS "Sub-module CMake/hpc-coding-conventions missing: running git submodule update --init")
2324
execute_process(
24-
COMMAND
25-
${GIT_EXECUTABLE} submodule update --init --
26-
${CORENEURON_PROJECT_SOURCE_DIR}/CMake/hpc-coding-conventions
25+
COMMAND ${GIT_EXECUTABLE} submodule update --init --
26+
${CORENEURON_PROJECT_SOURCE_DIR}/CMake/hpc-coding-conventions
2727
WORKING_DIRECTORY ${CORENEURON_PROJECT_SOURCE_DIR})
2828
endif()

CMake/AddMod2cSubmodule.cmake

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@ if(NOT MOD2C_FOUND)
2020
endif()
2121
message(STATUS "Sub-module mod2c missing : running git submodule update --init --recursive")
2222
execute_process(
23-
COMMAND
24-
${GIT_EXECUTABLE} submodule update --init --recursive --
25-
${CORENEURON_PROJECT_SOURCE_DIR}/external/mod2c
23+
COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive --
24+
${CORENEURON_PROJECT_SOURCE_DIR}/external/mod2c
2625
WORKING_DIRECTORY ${CORENEURON_PROJECT_SOURCE_DIR})
2726
else()
2827
message(STATUS "Using mod2c submodule from ${MOD2C_PROJ}")

CMake/AddNmodlSubmodule.cmake

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@ if(NOT NMODL_FOUND)
2020
endif()
2121
message(STATUS "Sub-module nmodl missing : running git submodule update --init")
2222
execute_process(
23-
COMMAND
24-
${GIT_EXECUTABLE} submodule update --init --
25-
${CORENEURON_PROJECT_SOURCE_DIR}/external/nmodl
23+
COMMAND ${GIT_EXECUTABLE} submodule update --init --
24+
${CORENEURON_PROJECT_SOURCE_DIR}/external/nmodl
2625
WORKING_DIRECTORY ${CORENEURON_PROJECT_SOURCE_DIR})
2726
else()
2827
message(STATUS "Using nmodl submodule from ${NMODL_PROJ}")

CMake/AddRandom123Submodule.cmake

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ if(NOT Random123_FOUND)
2222
endif()
2323
message(STATUS "Sub-module Random123 missing: running git submodule update --init --recursive")
2424
execute_process(
25-
COMMAND
26-
${GIT_EXECUTABLE} submodule update --init --recursive --
27-
${CORENEURON_PROJECT_SOURCE_DIR}/external/Random123
25+
COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive --
26+
${CORENEURON_PROJECT_SOURCE_DIR}/external/Random123
2827
WORKING_DIRECTORY ${CORENEURON_PROJECT_SOURCE_DIR})
2928
endif()

CMake/CMakeTestISPCCompiler.cmake

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ unset(CMAKE_ISPC_COMPILER_WORKS CACHE)
2828
# set and cmake stops processing commands and will not generate any makefiles or projects.
2929
# ~~~
3030
if(NOT CMAKE_ISPC_COMPILER_WORKS)
31-
printtestcompilerstatus("ISPC" "")
31+
PrintTestCompilerStatus("ISPC" "")
3232
file(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/kernel.ispc
3333
"export uniform int kernel(uniform int){return 0;}\n")
3434

@@ -52,7 +52,7 @@ endif()
5252

5353
# Print compiler status
5454
if(NOT CMAKE_ISPC_COMPILER_WORKS)
55-
printtestcompilerstatus("ISPC" " -- broken")
55+
PrintTestCompilerStatus("ISPC" " -- broken")
5656
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
5757
"Determining if the ISPC compiler works failed with "
5858
"the following output:\n${__CMAKE_ISPC_COMPILER_OUTPUT}\n\n")
@@ -66,7 +66,7 @@ if(NOT CMAKE_ISPC_COMPILER_WORKS)
6666
"CMake will not be able to correctly generate this project.")
6767
else()
6868
if(ISPC_TEST_WAS_RUN)
69-
printtestcompilerstatus("ISPC" " -- works")
69+
PrintTestCompilerStatus("ISPC" " -- works")
7070
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
7171
"Determining if the ISPC compiler works passed with "
7272
"the following output:\n${__CMAKE_ISPC_COMPILER_OUTPUT}\n\n")

CMake/GitRevision.cmake

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44
# See top-level LICENSE file for details.
55
# =============================================================================
66

7-
# For now use simple approach to get version information as git is
8-
# often avaialble on the machine where we are building from source
7+
# ~~~
8+
# For now use simple approach to get version information as git is often
9+
# avaialble on the machine where we are building from source
10+
# ~~~
911

1012
find_package(Git)
1113

CMake/MakefileBuildOptions.cmake

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@ set(CMAKE_ISPC_FLAGS "${CMAKE_ISPC_FLAGS} --pic")
1414
# =============================================================================
1515
# NMODL CLI options : common and backend specific
1616
# =============================================================================
17+
# ~~~
1718
# if user pass arguments then use those as common arguments
1819
# note that inlining is done by default
20+
# ~~~
1921
set(NMODL_COMMON_ARGS "passes --inline")
2022

21-
if (NOT "${CORENRN_NMODL_FLAGS}" STREQUAL "")
23+
if(NOT "${CORENRN_NMODL_FLAGS}" STREQUAL "")
2224
set(NMODL_COMMON_ARGS "${NMODL_COMMON_ARGS} ${CORENRN_NMODL_FLAGS}")
2325
endif()
2426

@@ -31,10 +33,10 @@ set(NMODL_ACC_BACKEND_ARGS "host --c acc --oacc")
3133
# =============================================================================
3234
get_directory_property(COMPILE_DEFS COMPILE_DEFINITIONS)
3335
if(COMPILE_DEFS)
34-
set(CORENRN_COMMON_COMPILE_DEFS "")
35-
foreach(flag ${COMPILE_DEFS})
36-
set(CORENRN_COMMON_COMPILE_DEFS "${CORENRN_COMMON_COMPILE_DEFS} -D${flag}")
37-
endforeach()
36+
set(CORENRN_COMMON_COMPILE_DEFS "")
37+
foreach(flag ${COMPILE_DEFS})
38+
set(CORENRN_COMMON_COMPILE_DEFS "${CORENRN_COMMON_COMPILE_DEFS} -D${flag}")
39+
endforeach()
3840
endif()
3941

4042
# =============================================================================
@@ -48,20 +50,20 @@ list(REMOVE_ITEM CORENRN_LINK_LIBS "Threads::Threads")
4850

4951
# replicate CMake magic to transform system libs to -l<libname>
5052
foreach(link_lib ${CORENRN_LINK_LIBS})
51-
if(${link_lib} MATCHES "\-l.*")
52-
string(APPEND CORENRN_COMMON_LDFLAGS " ${link_lib}")
53-
continue()
54-
endif()
55-
get_filename_component(path ${link_lib} DIRECTORY)
56-
if(NOT path)
57-
string(APPEND CORENRN_COMMON_LDFLAGS " -l${link_lib}")
58-
elseif("${path}" MATCHES "^(/lib|/lib64|/usr/lib|/usr/lib64)$")
59-
get_filename_component(libname ${link_lib} NAME_WE)
60-
string(REGEX REPLACE "^lib" "" libname ${libname})
61-
string(APPEND CORENRN_COMMON_LDFLAGS " -l${libname}")
62-
else()
63-
string(APPEND CORENRN_COMMON_LDFLAGS " ${link_lib}")
64-
endif()
53+
if(${link_lib} MATCHES "\-l.*")
54+
string(APPEND CORENRN_COMMON_LDFLAGS " ${link_lib}")
55+
continue()
56+
endif()
57+
get_filename_component(path ${link_lib} DIRECTORY)
58+
if(NOT path)
59+
string(APPEND CORENRN_COMMON_LDFLAGS " -l${link_lib}")
60+
elseif("${path}" MATCHES "^(/lib|/lib64|/usr/lib|/usr/lib64)$")
61+
get_filename_component(libname ${link_lib} NAME_WE)
62+
string(REGEX REPLACE "^lib" "" libname ${libname})
63+
string(APPEND CORENRN_COMMON_LDFLAGS " -l${libname}")
64+
else()
65+
string(APPEND CORENRN_COMMON_LDFLAGS " ${link_lib}")
66+
endif()
6567
endforeach()
6668

6769
# =============================================================================

0 commit comments

Comments
 (0)