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

Commit 41ef177

Browse files
authored
Add cmake option to set external MOD2C (#123)
Remove CMAKE_CACHE_ARGS to avoid long warnings like: CMake Warning at /usr/local/Cellar/cmake/3.12.3/share/cmake/Modules/ExternalProject.cmake:1702 (message): Line 'CMAKE_C_COMPILER=gcc' does not match regex. Ignoring. Call Stack (most recent call first): /usr/local/Cellar/cmake/3.12.3/share/cmake/Modules/ExternalProject.cmake:2766 (_ep_command_line_to_initial_cache) /usr/local/Cellar/cmake/3.12.3/share/cmake/Modules/ExternalProject.cmake:2840 (_ep_extract_configure_command) The drawback of this approach is that cmake shows different compiler that make for external project.
1 parent 03aec7b commit 41ef177

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

CMake/config/DeclareMod2CSubModule.cmake

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,22 @@ include(FindPkgConfig)
2828

2929
find_path(MOD2C_PROJ NAMES CMakeLists.txt PATHS "${PROJECT_SOURCE_DIR}/external/mod2c")
3030
find_package_handle_standard_args(MOD2C REQUIRED_VARS MOD2C_PROJ)
31+
3132
if (NOT MOD2C_FOUND)
3233
message (FATAL_ERROR "missing mod2c submodule :run on top directory of your sources (git > 1.8.2 required):
3334
git submodule update --init --remote
3435
")
3536
endif()
37+
3638
set(ExternalProjectCMakeArgs
3739
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
3840
-DCMAKE_INSTALL_PREFIX=${PROJECT_BINARY_DIR}/external/mod2c
3941
-DCMAKE_C_COMPILER=${FRONTEND_C_COMPILER} -DCMAKE_CXX_COMPILER=${FRONTEND_CXX_COMPILER}
40-
)
42+
)
4143

4244
ExternalProject_Add(mod2c
4345
SOURCE_DIR ${PROJECT_SOURCE_DIR}/external/mod2c
4446
GIT_SUBMODULES
4547
CMAKE_ARGS ${ExternalProjectCMakeArgs}
46-
CMAKE_CACHE_ARGS ${ExternalProjectCMakeArgs}
47-
)
48+
)
4849

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ set(FRONTEND_CXX_COMPILER g++ CACHE FILEPATH "C++ compiler for building mod2c [f
7171
set(ADDITIONAL_MECHPATH "" CACHE PATH "Search path for optional additional mechanism MOD files")
7272
set(ADDITIONAL_MECHS "" CACHE FILEPATH "File containing list of additional mechanism MOD files")
7373

74+
# mod2c path (if external)
75+
set(MOD2C "" CACHE FILEPATH "Path of MOD2C binary")
76+
7477
# test compilations
7578
option(UNIT_TESTS "Enable unit tests compilation and execution" ON)
7679
option(FUNCTIONAL_TESTS "Enable functional tests compilation and execution" ON)

coreneuron/CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,16 @@ file(GLOB_RECURSE coreneuron_cuda_files "*.cu")
3737
# Compile and include MOD files
3838

3939
# set mod2c binary and files from built in
40-
set (MOD2C ${PROJECT_BINARY_DIR}/external/mod2c/bin/mod2c_core)
40+
if(NOT EXISTS ${MOD2C})
41+
set (MOD2C ${PROJECT_BINARY_DIR}/external/mod2c/bin/mod2c_core)
42+
endif()
43+
4144
get_filename_component(mod2c_install_prefix ${MOD2C} DIRECTORY)
4245
set (MOD2C_UNITS "${PROJECT_BINARY_DIR}/external/mod2c/share/nrnunits.lib")
4346
set(MOD2C env "MODLUNIT=${MOD2C_UNITS}" ${MOD2C})
47+
48+
message(STATUS "USING MOD2C ${MOD2C}")
49+
4450
# Macro sets up build rule for .c files from .mod files.
4551
# Parameters:
4652
# name An arbitrary name to keep track of output .c files

0 commit comments

Comments
 (0)