Skip to content

Commit

Permalink
Test the new module
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas Cornu committed Jun 26, 2024
1 parent 28bf8ef commit 1131eea
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ if(NRN_ENABLE_PYTHON)
# Make sure the USE_PYTHON macro is defined in the C++ code
list(APPEND NRN_COMPILE_DEFS USE_PYTHON)
# Ensure nanobind is there, but dont import, we don't want its CMake
nrn_add_external_project(nanobind False)
nrn_add_external_project(nanobind DISABLE_ADD RECURSIVE SHALLOW)
include(NanoBindMinimal)
endif()

Expand Down
24 changes: 20 additions & 4 deletions cmake/ExternalProjectHelper.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,21 @@ endfunction(nrn_submodule_file_not_found)

# initialize submodule with given path
function(nrn_initialize_submodule path)
cmake_parse_arguments(PARSE_ARGV 1 opt "RECURSIVE;SHALLOW" "" "")
set(UPDATE_OPTIONS "")
if(opt_RECURSIVE)
list(APPEND UPDATE_OPTIONS --recursive)
endif()
if(opt_SHALLOW)
list(APPEND UPDATE_OPTIONS --depth 1)
endif()
if(NOT ${GIT_FOUND})
message(
FATAL_ERROR "git not found and ${path} sub-module not cloned (use git clone --recursive)")
endif()
message(STATUS "Sub-module : missing ${path} : running git submodule update --init")
message(FATAL_ERROR "Sub-module : missing ${path} : running git submodule update ${UPDATE_OPTIONS} --init")
execute_process(
COMMAND ${GIT_EXECUTABLE} submodule update --recursive --init -- ${path}
COMMAND ${GIT_EXECUTABLE} submodule update ${UPDATE_OPTIONS} --init -- ${path}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
RESULT_VARIABLE ret)
if(NOT ret EQUAL 0)
Expand All @@ -39,20 +47,28 @@ endfunction()

# check for external project and initialize submodule if it is missing
function(nrn_add_external_project name)
cmake_parse_arguments(PARSE_ARGV 1 opt "RECURSIVE;SHALLOW;DISABLE_ADD" "" "")
find_path(
${name}_PATH
NAMES CMakeLists.txt
PATHS "${THIRD_PARTY_DIRECTORY}/${name}"
NO_DEFAULT_PATH)
if(NOT EXISTS ${${name}_PATH})
nrn_submodule_file_not_found("${THIRD_PARTY_DIRECTORY}/${name}")
nrn_initialize_submodule("${THIRD_PARTY_DIRECTORY}/${name}")
set(OPTIONS "")
if(opt_RECURSIVE)
list(APPEND OPTIONS "RECURSIVE")
endif()
if (opt_SHALLOW)
list (APPEND OPTIONS "SHALLOW")
endif()
nrn_initialize_submodule("${THIRD_PARTY_DIRECTORY}/${name}" ${OPTIONS})
else()
message(STATUS "Sub-project : using ${name} from from ${THIRD_PARTY_DIRECTORY}/${name}")
endif()
# if second argument is passed and if it's OFF then skip add_subdirectory
if(${ARGC} GREATER 1)
if(${ARGV2})
if(NOT opt_DISABLE_ADD)
add_subdirectory("${THIRD_PARTY_DIRECTORY}/${name}")
endif()
else()
Expand Down
2 changes: 1 addition & 1 deletion src/coreneuron/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ else()
set(NMODL_ENABLE_PYTHON_BINDINGS
OFF
CACHE BOOL "Enable NMODL python bindings")
nrn_add_external_project(nmodl OFF)
nrn_add_external_project(nmodl DISABLE_ADD)
add_subdirectory(${PROJECT_SOURCE_DIR}/external/nmodl ${CMAKE_BINARY_DIR}/external/nmodl)
set(CORENRN_NMODL_BINARY ${CMAKE_BINARY_DIR}/bin/nmodl${CMAKE_EXECUTABLE_SUFFIX})
set(CORENRN_NMODL_INCLUDE ${CMAKE_BINARY_DIR}/include)
Expand Down

0 comments on commit 1131eea

Please sign in to comment.