Skip to content

Commit

Permalink
Added the -cxxmodules flag to bdm-dictionary. With C++ Modules, we do…
Browse files Browse the repository at this point in the history
…n't need to pass the headers to the interpreter anymore.
  • Loading branch information
imorlxs committed Dec 11, 2024
1 parent 68332b8 commit 2c4114c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 3 additions & 1 deletion cmake/BioDynaMo.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,10 @@ function(build_shared_library TARGET)
else()
set(BDM_OUT_OF_SRC_ARG --bdm-source ${CMAKE_SOURCE_DIR})
endif()
if (runtime_cxxmodules)
set(BDM_CXX_MODULES_ARG "--cxxmodules")
add_custom_command(OUTPUT "${BDM_DICT_FILE}"
COMMAND ${Python_EXECUTABLE} ${BDM_DICT_BIN_PATH}/bdm-dictionary ${BDM_OUT_OF_SRC_ARG} --output ${BDM_DICT_FILE} --include-dirs ${INCLUDE_DIRS} --headers ${ARG_HEADERS}
COMMAND ${Python_EXECUTABLE} ${BDM_DICT_BIN_PATH}/bdm-dictionary ${BDM_OUT_OF_SRC_ARG} ${BDM_CXX_MODULES_ARG} --output ${BDM_DICT_FILE} --include-dirs ${INCLUDE_DIRS} --headers ${ARG_HEADERS}
DEPENDS ${ARG_HEADERS} ${BDM_DICT_BIN_PATH}/bdm-dictionary)
# generate shared library
add_library(${TARGET} SHARED ${ARG_SOURCES} ${DICT_FILE}.cc ${BDM_DICT_FILE})
Expand Down
7 changes: 5 additions & 2 deletions cmake/bdm-dictionary
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ if __name__ == '__main__':
parser.add_argument('--bdm-source', action='store', type=str, required=False, help='Source directory of BioDynaMo for bdm build.')
parser.add_argument('--include-dirs', nargs='+', type=str, required=True, help='At least one directory that contains the header files.')
parser.add_argument('--headers', nargs='+', type=str, required=True, help='At least one header file containing biodynamo definitions.')
parser.add_argument('--cxxmodules', action='store_true', help='Generate bdm dictionary for a C++ Modules enabled installation.')

args = parser.parse_args()

Expand Down Expand Up @@ -116,8 +117,10 @@ static struct BioDynaMoDictInit {
AppendPrefix(id, prefixes)
f.write(' idirs << {0} << ":";\n'.format(id_processed))

for h in args.headers:
f.write(' bdm::JitHeaders::Register("{0}");\n'.format(RemoveLongestPrefix(h, prefixes)))
# We don't need to pass the headers to the interpreter since we use modules
if not args.modules:
for h in args.headers:
f.write(' bdm::JitHeaders::Register("{0}");\n'.format(RemoveLongestPrefix(h, prefixes)))

f.write("""
AppendEnvVar(idirs, "ROOT_INCLUDE_PATH", "");
Expand Down

0 comments on commit 2c4114c

Please sign in to comment.