From 2c4114cc41d26a9ff3dbbc53970a0abfa07582ee Mon Sep 17 00:00:00 2001 From: Isaac Morales Date: Wed, 11 Dec 2024 01:38:48 +0100 Subject: [PATCH] Added the -cxxmodules flag to bdm-dictionary. With C++ Modules, we don't need to pass the headers to the interpreter anymore. --- cmake/BioDynaMo.cmake | 4 +++- cmake/bdm-dictionary | 7 +++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/cmake/BioDynaMo.cmake b/cmake/BioDynaMo.cmake index 6f91b0469..37e0acd64 100644 --- a/cmake/BioDynaMo.cmake +++ b/cmake/BioDynaMo.cmake @@ -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}) diff --git a/cmake/bdm-dictionary b/cmake/bdm-dictionary index 527b1cb5b..3c4931eb8 100755 --- a/cmake/bdm-dictionary +++ b/cmake/bdm-dictionary @@ -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() @@ -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", "");