-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable C++ Modules #385
base: master
Are you sure you want to change the base?
Enable C++ Modules #385
Changes from all commits
1ccfdaf
2e4dcd7
0c3e4c9
aacbf40
9a7680a
e79411f
083b433
8139c5b
21ad68d
68f110d
7bed670
59a6ce7
6a09c01
e7f40b3
23ace61
6f401fe
c9db0b9
77cd6dc
e684441
6d1c574
3791701
6a2743a
55e2592
5de61fe
73b7df5
1b0dee0
e5fc01a
f896784
56a3a8e
8b35112
3f71ebf
f6d897c
a399cb5
43f415d
189438d
540bab0
51f8c0b
5e6acc3
e36e3f7
e67be81
8954286
ba20129
e093b4c
68332b8
2c4114c
ac5524d
7a2d6b3
1f79202
301b75f
8c84c55
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -108,17 +108,33 @@ function(build_shared_library TARGET) | |
# We always need dictionaries for the plugins (plugin manager requires class | ||
# information) | ||
if(dict OR DEFINED ARG_PLUGIN) | ||
# generate dictionary using genreflex | ||
# generate dictionary using rootcling reflex | ||
set(DICT_FILE "${CMAKE_CURRENT_BINARY_DIR}/lib${TARGET}_dict") | ||
set(BDM_DICT_FILE "${CMAKE_CURRENT_BINARY_DIR}/lib${TARGET}_bdm_dict.cc") | ||
set(ROOT_HEADERS) | ||
string(REPLACE "${CMAKE_SOURCE_DIR}/src/" "" ROOT_HEADERS_TEMP "${ARG_HEADERS}") | ||
string(REPLACE "${CMAKE_SOURCE_DIR}/test/" "" ROOT_HEADERS "${ROOT_HEADERS_TEMP}") | ||
|
||
|
||
if (runtime_cxxmodules) | ||
set(MODULEMAP "--moduleMapFile=${CMAKE_BINARY_DIR}/include/module.modulemap") | ||
else() | ||
set(NO_MODULE "NO_CXXMODULE") | ||
endif() | ||
|
||
if (NOT ${TARGET} STREQUAL "biodynamo") | ||
#set(DEPENDENCY_OPTION "-m ${CMAKE_CURRENT_BINARY_DIR}/lib/biodynamo.pcm") | ||
#set(NO_MODULE "NO_CXXMODULE") | ||
#set(MODULEMAP) | ||
endif() | ||
|
||
# Since the location of the CMake files differ in the build and installation | ||
# directory, we check if BDM_CMAKE_DIR is already set (in build directory | ||
# case). Otherwise, set it to the installation directory | ||
if(NOT DEFINED BDM_CMAKE_DIR) | ||
set(BDM_CMAKE_DIR $ENV{BDMSYS}/share/cmake) | ||
endif() | ||
REFLEX_GENERATE_DICTIONARY(${DICT_FILE} ${ARG_HEADERS} SELECTION ${BDM_CMAKE_DIR}/${ARG_SELECTION}) | ||
ROOT_GENERATE_DICTIONARY(${DICT_FILE} ${ROOT_HEADERS} MODULE ${TARGET} LINKDEF ${BDM_CMAKE_DIR}/${ARG_SELECTION} REFLEX ${NO_MODULE} OPTIONS ${DEPENDENCY_OPTION} -I src --inlineInputHeader --noIncludePaths ${MODULEMAP}) | ||
if (BDM_OUT_OF_SOURCE) | ||
set(BDM_DICT_BIN_PATH "$ENV{BDMSYS}/bin") | ||
else() | ||
|
@@ -130,8 +146,11 @@ function(build_shared_library TARGET) | |
else() | ||
set(BDM_OUT_OF_SRC_ARG --bdm-source ${CMAKE_SOURCE_DIR}) | ||
endif() | ||
if (BDM_CXXMODULES) | ||
set(BDM_CXX_MODULES_ARG "--cxxmodules") | ||
endif() | ||
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}) | ||
|
@@ -140,9 +159,9 @@ function(build_shared_library TARGET) | |
endif() | ||
target_link_libraries(${TARGET} ${ARG_LIBRARIES}) | ||
if (DEFINED CMAKE_INSTALL_LIBDIR) | ||
add_custom_command(TARGET ${TARGET} | ||
POST_BUILD | ||
COMMAND ${CMAKE_COMMAND} -E copy ${DICT_FILE}_rdict.pcm ${CMAKE_INSTALL_LIBDIR}) | ||
# add_custom_command(TARGET ${TARGET} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, this code is not longer necessary, as ROOT_GENERATE_DICTIONARY already generates the .pcm in CMAKE_INSTALL_LIBDIR |
||
# POST_BUILD | ||
# COMMAND ${CMAKE_COMMAND} -E copy ${DICT_FILE}_rdict.pcm ${CMAKE_INSTALL_LIBDIR}) | ||
endif() | ||
else() | ||
add_library(${TARGET} SHARED ${ARG_SOURCES}) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -97,108 +97,10 @@ mark_as_advanced(ROOT_CONFIG_EXECUTABLE) | |
include(CMakeParseArguments) | ||
find_program(ROOTCLING_EXECUTABLE rootcling | ||
HINTS "$ENV{ROOTSYS}/bin" "$ENV{BDM_ROOT_DIR}/bin" "${CMAKE_THIRD_PARTY_DIR}/root/bin") | ||
find_program(GENREFLEX_EXECUTABLE genreflex | ||
HINTS "$ENV{ROOTSYS}/bin" "$ENV{BDM_ROOT_DIR}/bin" "${CMAKE_THIRD_PARTY_DIR}/root/bin") | ||
#find_package(GCCXML) | ||
|
||
# We use the launcher script to emulate a `source thisbdm.sh` call | ||
if(NOT BDM_OUT_OF_SOURCE) | ||
set(LAUNCHER ${CMAKE_BINARY_DIR}/launcher.sh) | ||
endif() | ||
|
||
#---------------------------------------------------------------------------- | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This function is now in RootMacros.cmake, imported from the root source code. |
||
# function ROOT_GENERATE_DICTIONARY( dictionary | ||
# header1 header2 ... | ||
# LINKDEF linkdef1 ... | ||
# OPTIONS opt1...) | ||
function(ROOT_GENERATE_DICTIONARY dictionary) | ||
CMAKE_PARSE_ARGUMENTS(ARG "" "" "LINKDEF;OPTIONS" "" ${ARGN}) | ||
#---Get the list of include directories------------------ | ||
get_directory_property(incdirs INCLUDE_DIRECTORIES) | ||
set(includedirs) | ||
foreach( d ${incdirs}) | ||
set(includedirs ${includedirs} -I${d}) | ||
endforeach() | ||
#---Get the list of header files------------------------- | ||
set(headerfiles) | ||
foreach(fp ${ARG_UNPARSED_ARGUMENTS}) | ||
if(${fp} MATCHES "[*?]") # Is this header a globbing expression? | ||
file(GLOB files ${fp}) | ||
foreach(f ${files}) | ||
if(NOT f MATCHES LinkDef) # skip LinkDefs from globbing result | ||
set(headerfiles ${headerfiles} ${f}) | ||
endif() | ||
endforeach() | ||
else() | ||
find_file(headerFile ${fp} HINTS ${incdirs}) | ||
set(headerfiles ${headerfiles} ${headerFile}) | ||
unset(headerFile CACHE) | ||
endif() | ||
endforeach() | ||
#---Get LinkDef.h file------------------------------------ | ||
set(linkdefs) | ||
foreach( f ${ARG_LINKDEF}) | ||
find_file(linkFile ${f} HINTS ${incdirs}) | ||
set(linkdefs ${linkdefs} ${linkFile}) | ||
unset(linkFile CACHE) | ||
endforeach() | ||
#---call rootcling------------------------------------------ | ||
add_custom_command(OUTPUT ${dictionary}.cxx | ||
OUTPUT ${dictionary}_rdict.pcm | ||
COMMAND ${LAUNCHER} ${ROOTCLING_EXECUTABLE} -f ${dictionary}.cxx | ||
${ARG_OPTIONS} ${includedirs} ${headerfiles} ${linkdefs} | ||
DEPENDS ${headerfiles} ${linkdefs} VERBATIM) | ||
endfunction() | ||
|
||
#---------------------------------------------------------------------------- | ||
# function REFLEX_GENERATE_DICTIONARY(dictionary | ||
# header1 header2 ... | ||
# SELECTION selectionfile ... | ||
# OPTIONS opt1...) | ||
function(REFLEX_GENERATE_DICTIONARY dictionary) | ||
CMAKE_PARSE_ARGUMENTS(ARG "" "" "SELECTION;OPTIONS" "" ${ARGN}) | ||
#---Get the list of header files------------------------- | ||
set(headerfiles) | ||
foreach(fp ${ARG_UNPARSED_ARGUMENTS}) | ||
file(GLOB files ${fp}) | ||
if(files) | ||
foreach(f ${files}) | ||
set(headerfiles ${headerfiles} ${f}) | ||
endforeach() | ||
else() | ||
set(headerfiles ${headerfiles} ${fp}) | ||
endif() | ||
endforeach() | ||
#---Get Selection file------------------------------------ | ||
if(IS_ABSOLUTE ${ARG_SELECTION}) | ||
set(selectionfile ${ARG_SELECTION}) | ||
else() | ||
set(selectionfile ${CMAKE_CURRENT_SOURCE_DIR}/${ARG_SELECTION}) | ||
endif() | ||
#---Get the list of include directories------------------ | ||
get_directory_property(incdirs INCLUDE_DIRECTORIES) | ||
set(includedirs) | ||
foreach( d ${incdirs}) | ||
set(includedirs ${includedirs} -I${d}) | ||
endforeach() | ||
#---Get preprocessor definitions-------------------------- | ||
get_directory_property(defs COMPILE_DEFINITIONS) | ||
foreach( d ${defs}) | ||
set(definitions ${definitions} -D${d}) | ||
endforeach() | ||
#---Nanes and others--------------------------------------- | ||
set(gensrcdict ${dictionary}.cc) | ||
if(MSVC) | ||
set(gccxmlopts "--gccxmlopt=\"--gccxml-compiler cl\"") | ||
else() | ||
#set(gccxmlopts "--gccxmlopt=\'--gccxml-cxxflags -m64 \'") | ||
set(gccxmlopts) | ||
endif() | ||
#set(rootmapname ${dictionary}Dict.rootmap) | ||
#set(rootmapopts --rootmap=${rootmapname} --rootmap-lib=${libprefix}${dictionary}Dict) | ||
#---Actual command---------------------------------------- | ||
add_custom_command(OUTPUT ${gensrcdict} ${rootmapname} ${dictionary}_rdict.pcm | ||
COMMAND ${LAUNCHER} ${GENREFLEX_EXECUTABLE} ${headerfiles} -o ${gensrcdict} ${rootmapopts} --select=${selectionfile} --noIncludePaths | ||
${ARG_OPTIONS} ${includedirs} ${definitions} | ||
DEPENDS ${headerfiles} ${selectionfile}) | ||
endfunction() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This if can be removed as is not longer necessary