-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
224 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,52 @@ | ||
cmake_minimum_required(VERSION 3.25) | ||
cmake_minimum_required(VERSION 3.15...3.27) | ||
|
||
project( | ||
${SKBUILD_PROJECT_NAME} | ||
VERSION ${SKBUILD_PROJECT_VERSION} | ||
LANGUAGES CXX) | ||
${SKBUILD_PROJECT_NAME} | ||
VERSION ${SKBUILD_PROJECT_VERSION} | ||
LANGUAGES CXX) | ||
|
||
set(PYTHON_MODULE_NAME _core) | ||
|
||
set(CMAKE_CXX_STANDARD 20) | ||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
set(CMAKE_CXX_EXTENSIONS OFF) | ||
|
||
find_package(Geant4 REQUIRED CONFIG COMPONENTS gdml) | ||
find_package( | ||
Python3 | ||
COMPONENTS Interpreter Development.Module | ||
REQUIRED) | ||
Python | ||
COMPONENTS Interpreter Development.Module | ||
REQUIRED) | ||
find_package(Geant4 REQUIRED CONFIG COMPONENTS gdml) | ||
|
||
message(STATUS "Using Geant4 ${Geant4_VERSION} from ${Geant4_DIR}") | ||
message(STATUS "Using Python ${Python_VERSION} from ${Python_EXECUTABLE}") | ||
|
||
add_subdirectory(external/awkward/header-only) | ||
add_subdirectory(external/pybind11) | ||
|
||
file(GLOB_RECURSE SOURCES CONFIGURE_DEPENDS | ||
"${PROJECT_SOURCE_DIR}/src/geant4/*.cpp") | ||
|
||
set(PYTHON_MODULE_NAME _core) | ||
file(GLOB_RECURSE PYTHON_SOURCES CONFIGURE_DEPENDS | ||
"${PROJECT_SOURCE_DIR}/src/python/*.cpp") | ||
|
||
pybind11_add_module(${PYTHON_MODULE_NAME} ${PYTHON_SOURCES}) | ||
target_compile_options(${PYTHON_MODULE_NAME} PRIVATE -fPIC) | ||
pybind11_add_module(${PYTHON_MODULE_NAME} ${SOURCES} ${PYTHON_SOURCES}) | ||
|
||
target_compile_definitions(${PYTHON_MODULE_NAME} | ||
PRIVATE VERSION_INFO=${PROJECT_VERSION}) | ||
|
||
target_include_directories( | ||
${PYTHON_MODULE_NAME} PUBLIC ${PROJECT_SOURCE_DIR}/include | ||
${Geant4_INCLUDE_DIRS}) | ||
target_sources(${PYTHON_MODULE_NAME} PRIVATE ${SOURCES}) | ||
${PYTHON_MODULE_NAME} PRIVATE ${PROJECT_SOURCE_DIR}/include | ||
${Geant4_INCLUDE_DIRS}) | ||
|
||
target_link_libraries( | ||
${PYTHON_MODULE_NAME} | ||
PRIVATE ${Geant4_LIBRARIES} | ||
awkward::layout-builder | ||
pybind11::embed | ||
pybind11::module | ||
${Python3_LIBRARY} | ||
Python3::Module | ||
pybind11::headers) | ||
${PYTHON_MODULE_NAME} PRIVATE ${Geant4_LIBRARIES} awkward::layout-builder | ||
pybind11::headers) | ||
|
||
set_target_properties( | ||
${PYTHON_MODULE_NAME} | ||
PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib | ||
ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib | ||
CXX_VISIBILITY_PRESET hidden | ||
VISIBILITY_INLINES_HIDDEN ON | ||
CXX_EXTENSIONS NO) | ||
${PYTHON_MODULE_NAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY | ||
${PROJECT_BINARY_DIR}/${PROJECT_NAME}) | ||
|
||
install( | ||
TARGETS ${PYTHON_MODULE_NAME} | ||
LIBRARY DESTINATION ${PROJECT_NAME} | ||
RUNTIME DESTINATION ${PROJECT_NAME} | ||
ARCHIVE DESTINATION ${PROJECT_NAME}) | ||
TARGETS ${PYTHON_MODULE_NAME} | ||
LIBRARY DESTINATION ${PROJECT_NAME} | ||
RUNTIME DESTINATION ${PROJECT_NAME} | ||
ARCHIVE DESTINATION ${PROJECT_NAME}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,19 @@ | ||
from __future__ import annotations | ||
|
||
lib_path = "" | ||
# sys.path.append(lib_path) | ||
from geant4_python_application._core import ( | ||
Application, | ||
PrimaryGeneratorAction, | ||
StackingAction, | ||
__doc__, | ||
__version__, | ||
) | ||
from geant4_python_application.gdml import basic_gdml | ||
|
||
from ._core import * | ||
__all__ = [ | ||
"__doc__", | ||
"__version__", | ||
"Application", | ||
"PrimaryGeneratorAction", | ||
"StackingAction", | ||
"basic_gdml", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
from __future__ import annotations | ||
|
||
basic_gdml = R"""<?xml version="1.0" encoding="utf-8" standalone="no" ?> | ||
<gdml xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="http://service-spi.web.cern.ch/service-spi/app/releases/GDML/schema/gdml.xsd"> | ||
<define> | ||
<constant name="worldSize" value="1000"/> | ||
<constant name="boxSize" value="500"/> | ||
</define> | ||
<solids> | ||
<box name="WorldSolid" x="worldSize" y="worldSize" z="worldSize" lunit="mm"/> | ||
<box name="boxSolid" x="boxSize" y="boxSize" z="boxSize" lunit="mm"/> | ||
</solids> | ||
<structure> | ||
<volume name="boxVolume"> | ||
<materialref ref="G4_WATER"/> | ||
<solidref ref="boxSolid"/> | ||
</volume> | ||
<volume name="World"> | ||
<materialref ref="G4_AIR"/> | ||
<solidref ref="WorldSolid"/> | ||
<physvol name="box"> | ||
<volumeref ref="boxVolume"/> | ||
<position name="boxPosition" unit="mm" x="0" y="0" z="0"/> | ||
</physvol> | ||
</volume> | ||
</structure> | ||
<setup name="Default" version="1.0"> | ||
<world ref="World"/> | ||
</setup> | ||
</gdml> | ||
""" |
Oops, something went wrong.