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

Commit

Permalink
Browse files Browse the repository at this point in the history
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 <omar.awile@epfl.ch>
  • Loading branch information
pramodk and ohm314 committed Aug 11, 2020
1 parent 5fb8978 commit b1ea553
Show file tree
Hide file tree
Showing 32 changed files with 696 additions and 772 deletions.
94 changes: 0 additions & 94 deletions .clang-format

This file was deleted.

6 changes: 6 additions & 0 deletions .cmake-format.changes.yaml
@@ -0,0 +1,6 @@
additional_commands:
cuda_add_library:
pargs: '*'
flags: ["STATIC", "SHARED", "MODULE", "EXCLUDE_FROM_ALL"]
kwargs:
OPTIONS: '*'
3 changes: 3 additions & 0 deletions .gitmodules
Expand Up @@ -10,3 +10,6 @@
[submodule "external/Random123"]
path = external/Random123
url = https://github.com/BlueBrain/Random123.git
[submodule "CMake/hpc-coding-conventions"]
path = CMake/hpc-coding-conventions
url = https://github.com/BlueBrain/hpc-coding-conventions.git
19 changes: 12 additions & 7 deletions CMake/AddCLI11Submodule.cmake
@@ -1,13 +1,17 @@
# =============================================================================
# Copyright (C) 2020 Blue Brain Project
# Copyright (C) 2016-2020 Blue Brain Project
#
# See top-level LICENSE file for details.
# =============================================================================


include(FindPackageHandleStandardArgs)
find_package(FindPkgConfig QUIET)
find_path(CLI11_PROJ NAMES CMakeLists.txt PATHS "${CORENEURON_PROJECT_SOURCE_DIR}/external/CLI11")

find_path(
CLI11_PROJ
NAMES CMakeLists.txt
PATHS "${CORENEURON_PROJECT_SOURCE_DIR}/external/CLI11")

find_package_handle_standard_args(CLI11 REQUIRED_VARS CLI11_PROJ)

if(NOT CLI11_FOUND)
Expand All @@ -16,8 +20,9 @@ if(NOT CLI11_FOUND)
message(FATAL_ERROR "git not found, clone repository with --recursive")
endif()
message(STATUS "Sub-module CLI11 missing: running git submodule update --init --recursive")
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive --
${CORENEURON_PROJECT_SOURCE_DIR}/external/CLI11
WORKING_DIRECTORY ${CORENEURON_PROJECT_SOURCE_DIR})
execute_process(
COMMAND
${GIT_EXECUTABLE} submodule update --init --recursive --
${CORENEURON_PROJECT_SOURCE_DIR}/external/CLI11
WORKING_DIRECTORY ${CORENEURON_PROJECT_SOURCE_DIR})
endif()

35 changes: 19 additions & 16 deletions CMake/AddMod2cSubmodule.cmake
@@ -1,13 +1,17 @@
# =============================================================================
# Copyright (C) 2016-2019 Blue Brain Project
# Copyright (C) 2016-2020 Blue Brain Project
#
# See top-level LICENSE file for details.
# =============================================================================

include(ExternalProject)

find_package(FindPkgConfig QUIET)
find_path(MOD2C_PROJ NAMES CMakeLists.txt PATHS "${CORENEURON_PROJECT_SOURCE_DIR}/external/mod2c")

find_path(
MOD2C_PROJ
NAMES CMakeLists.txt
PATHS "${CORENEURON_PROJECT_SOURCE_DIR}/external/mod2c")

find_package_handle_standard_args(MOD2C REQUIRED_VARS MOD2C_PROJ)

if(NOT MOD2C_FOUND)
Expand All @@ -16,24 +20,23 @@ if(NOT MOD2C_FOUND)
message(FATAL_ERROR "git not found, clone repository with --recursive")
endif()
message(STATUS "Sub-module mod2c missing : running git submodule update --init --recursive")
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive --
${CORENEURON_PROJECT_SOURCE_DIR}/external/mod2c
WORKING_DIRECTORY ${CORENEURON_PROJECT_SOURCE_DIR})
execute_process(
COMMAND
${GIT_EXECUTABLE} submodule update --init --recursive --
${CORENEURON_PROJECT_SOURCE_DIR}/external/mod2c
WORKING_DIRECTORY ${CORENEURON_PROJECT_SOURCE_DIR})
else()
message(STATUS "Using mod2c submodule from ${MOD2C_PROJ}")
endif()

set(ExternalProjectCMakeArgs
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}
-DCMAKE_C_COMPILER=${CORENRN_FRONTEND_C_COMPILER}
-DCMAKE_CXX_COMPILER=${CORENRN_FRONTEND_CXX_COMPILER})

externalproject_add(mod2c
BUILD_ALWAYS
1
SOURCE_DIR
${CORENEURON_PROJECT_SOURCE_DIR}/external/mod2c
GIT_SUBMODULES
CMAKE_ARGS
${ExternalProjectCMakeArgs})
ExternalProject_Add(
mod2c
BUILD_ALWAYS 1
SOURCE_DIR ${CORENEURON_PROJECT_SOURCE_DIR}/external/mod2c
GIT_SUBMODULES
CMAKE_ARGS ${ExternalProjectCMakeArgs})
19 changes: 12 additions & 7 deletions CMake/AddNmodlSubmodule.cmake
@@ -1,12 +1,16 @@
# =============================================================================
# Copyright (C) 2016-2019 Blue Brain Project
# Copyright (C) 2016-2020 Blue Brain Project
#
# See top-level LICENSE file for details.
# =============================================================================


find_package(FindPkgConfig QUIET)
find_path(NMODL_PROJ NAMES CMakeLists.txt PATHS "${CORENEURON_PROJECT_SOURCE_DIR}/external/nmodl")

find_path(
NMODL_PROJ
NAMES CMakeLists.txt
PATHS "${CORENEURON_PROJECT_SOURCE_DIR}/external/nmodl")

find_package_handle_standard_args(NMODL REQUIRED_VARS NMODL_PROJ)

if(NOT NMODL_FOUND)
Expand All @@ -15,12 +19,13 @@ if(NOT NMODL_FOUND)
message(FATAL_ERROR "git not found, clone repository with --recursive")
endif()
message(STATUS "Sub-module nmodl missing : running git submodule update --init --recursive")
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive --
${CORENEURON_PROJECT_SOURCE_DIR}/external/nmodl
WORKING_DIRECTORY ${CORENEURON_PROJECT_SOURCE_DIR})
execute_process(
COMMAND
${GIT_EXECUTABLE} submodule update --init --recursive --
${CORENEURON_PROJECT_SOURCE_DIR}/external/nmodl
WORKING_DIRECTORY ${CORENEURON_PROJECT_SOURCE_DIR})
else()
message(STATUS "Using nmodl submodule from ${NMODL_PROJ}")
endif()

add_subdirectory(${CORENEURON_PROJECT_SOURCE_DIR}/external/nmodl)

19 changes: 12 additions & 7 deletions CMake/AddRandom123Submodule.cmake
@@ -1,13 +1,17 @@
# =============================================================================
# Copyright (C) 2020 Blue Brain Project
# Copyright (C) 2016-2020 Blue Brain Project
#
# See top-level LICENSE file for details.
# =============================================================================


include(FindPackageHandleStandardArgs)
find_package(FindPkgConfig QUIET)
find_path(Random123_PROJ NAMES LICENSE PATHS "${CORENEURON_PROJECT_SOURCE_DIR}/external/Random123")

find_path(
Random123_PROJ
NAMES LICENSE
PATHS "${CORENEURON_PROJECT_SOURCE_DIR}/external/Random123")

find_package_handle_standard_args(Random123 REQUIRED_VARS Random123_PROJ)

if(NOT Random123_FOUND)
Expand All @@ -16,8 +20,9 @@ if(NOT Random123_FOUND)
message(FATAL_ERROR "git not found, clone repository with --recursive")
endif()
message(STATUS "Sub-module Random123 missing: running git submodule update --init --recursive")
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive --
${CORENEURON_PROJECT_SOURCE_DIR}/external/Random123
WORKING_DIRECTORY ${CORENEURON_PROJECT_SOURCE_DIR})
execute_process(
COMMAND
${GIT_EXECUTABLE} submodule update --init --recursive --
${CORENEURON_PROJECT_SOURCE_DIR}/external/Random123
WORKING_DIRECTORY ${CORENEURON_PROJECT_SOURCE_DIR})
endif()

13 changes: 6 additions & 7 deletions CMake/CMakeDetermineISPCCompiler.cmake
@@ -1,16 +1,15 @@
# =============================================================================
# Copyright (C) 2016-2019 Blue Brain Project
# Copyright (C) 2016-2020 Blue Brain Project
#
# See top-level LICENSE file for details.
# =============================================================================

# Find the compiler
# Find the ISPC compiler
find_program(
CMAKE_ISPC_COMPILER
NAMES $ENV{ISPC} ispc
PATHS ENV PATH
DOC "ISPC compiler"
)
CMAKE_ISPC_COMPILER
NAMES $ENV{ISPC} ispc
PATHS ENV PATH
DOC "ISPC compiler")
mark_as_advanced(CMAKE_ISPC_COMPILER)

set(CMAKE_ISPC_SOURCE_FILE_EXTENSIONS ispc)
Expand Down
2 changes: 1 addition & 1 deletion CMake/CMakeISPCInformation.cmake
Expand Up @@ -8,6 +8,6 @@
set(CMAKE_INCLUDE_FLAG_ISPC "-I")

if(NOT CMAKE_ISPC_COMPILE_OBJECT)
set(CMAKE_ISPC_COMPILE_OBJECT "<CMAKE_ISPC_COMPILER> <FLAGS> <INCLUDES> <SOURCE> -o <OBJECT>")
set(CMAKE_ISPC_COMPILE_OBJECT "<CMAKE_ISPC_COMPILER> <FLAGS> <INCLUDES> <SOURCE> -o <OBJECT>")
endif()
set(CMAKE_ISPC_INFORMATION_LOADED 1)
65 changes: 37 additions & 28 deletions CMake/CMakeTestISPCCompiler.cmake
@@ -1,30 +1,36 @@
if(CMAKE_ISPC_COMPILER_FORCED)
# The compiler configuration was forced by the user.
# Assume the user has configured all compiler information.
# ~~~
# The compiler configuration was forced by the user. Assume the user has
# configured all compiler information.
# ~~~
set(CMAKE_ISPC_COMPILER_WORKS TRUE)
return()
endif()

set(CMAKE_ISPC_COMPILER_WORKS 1 CACHE INTERNAL "")
set(CMAKE_ISPC_COMPILER_WORKS
1
CACHE INTERNAL "")

# Remove any cached result from an older CMake version.
# We now store this in CMakeISPCCompiler.cmake.
# Remove any cached result from an older CMake version. We now store this in
# CMakeISPCCompiler.cmake.
unset(CMAKE_ISPC_COMPILER_WORKS CACHE)

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

execute_process(COMMAND ${CMAKE_ISPC_COMPILER} "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/kernel.ispc"
OUTPUT_VARIABLE __CMAKE_ISPC_COMPILER_OUTPUT
ERROR_VARIABLE __CMAKE_ISPC_COMPILER_ERROR
RESULT_VARIABLE ISPC_RESULT)
execute_process(
COMMAND ${CMAKE_ISPC_COMPILER}
"${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/kernel.ispc"
OUTPUT_VARIABLE __CMAKE_ISPC_COMPILER_OUTPUT
ERROR_VARIABLE __CMAKE_ISPC_COMPILER_ERROR
RESULT_VARIABLE ISPC_RESULT)

if(${ISPC_RESULT})
set(CMAKE_ISPC_COMPILER_WORKS 0)
Expand All @@ -37,25 +43,28 @@ if(NOT CMAKE_ISPC_COMPILER_WORKS)
set(ISPC_TEST_WAS_RUN 1)
endif()

# Print compiler status
if(NOT CMAKE_ISPC_COMPILER_WORKS)
PrintTestCompilerStatus("ISPC" " -- broken")
printtestcompilerstatus("ISPC" " -- broken")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"Determining if the ISPC compiler works failed with "
"the following output:\n${__CMAKE_ISPC_COMPILER_OUTPUT}\n\n")
string(REPLACE "\n" "\n " _output "${__CMAKE_ISPC_COMPILER_OUTPUT} ${__CMAKE_ISPC_COMPILER_ERROR}")
message(FATAL_ERROR "The ISPC compiler\n \"${CMAKE_ISPC_COMPILER}\"\n"
"is not able to compile a simple test program.\nIt fails "
"with the following output:\n ${_output}\n\n"
"CMake will not be able to correctly generate this project.")
"Determining if the ISPC compiler works failed with "
"the following output:\n${__CMAKE_ISPC_COMPILER_OUTPUT}\n\n")
string(REPLACE "\n" "\n " _output
"${__CMAKE_ISPC_COMPILER_OUTPUT} ${__CMAKE_ISPC_COMPILER_ERROR}")
message(
FATAL_ERROR
"The ISPC compiler\n \"${CMAKE_ISPC_COMPILER}\"\n"
"is not able to compile a simple test program.\nIt fails "
"with the following output:\n ${_output}\n\n"
"CMake will not be able to correctly generate this project.")
else()
if(ISPC_TEST_WAS_RUN)
PrintTestCompilerStatus("ISPC" " -- works")
printtestcompilerstatus("ISPC" " -- works")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"Determining if the ISPC compiler works passed with "
"the following output:\n${__CMAKE_ISPC_COMPILER_OUTPUT}\n\n")
"Determining if the ISPC compiler works passed with "
"the following output:\n${__CMAKE_ISPC_COMPILER_OUTPUT}\n\n")
endif()
endif()


unset(__CMAKE_ISPC_COMPILER_OUTPUT)
unset(__CMAKE_ISPC_COMPILER_ERROR)

0 comments on commit b1ea553

Please sign in to comment.