Skip to content

Commit

Permalink
use cmake to fetch dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
lobis committed Dec 1, 2023
1 parent 9c218b8 commit 2314976
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 25 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Log in to the GitHub Container registry
uses: docker/login-action@v3
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Get conda
uses: conda-incubator/setup-miniconda@v3
Expand Down
6 changes: 0 additions & 6 deletions .gitmodules

This file was deleted.

41 changes: 34 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

set(AWKWARD_VERSION "v2.5.0")
set(PYBIND11_VERSION "v2.11.1")

find_package(
Python
COMPONENTS Interpreter Development.Module
Expand All @@ -25,8 +28,30 @@ 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)
include(FetchContent)

FetchContent_Declare(
awkward-headers
URL https://github.com/scikit-hep/awkward/releases/download/${AWKWARD_VERSION}/header-only.zip
)
FetchContent_GetProperties(awkward-headers)
if (NOT awkward-headers_POPULATED)
FetchContent_Populate(awkward-headers)
add_subdirectory(${awkward-headers_SOURCE_DIR}
${awkward-headers_BINARY_DIR} EXCLUDE_FROM_ALL)
endif ()

FetchContent_Declare(
pybind11
GIT_REPOSITORY https://github.com/pybind/pybind11.git
GIT_TAG ${PYBIND11_VERSION}
DOWNLOAD_EXTRACT_TIMESTAMP 1)
FetchContent_GetProperties(pybind11)
if (NOT pybind11_POPULATED)
FetchContent_Populate(pybind11)
add_subdirectory(${pybind11_SOURCE_DIR} ${pybind11_BINARY_DIR}
EXCLUDE_FROM_ALL)
endif ()

file(GLOB_RECURSE SOURCES CONFIGURE_DEPENDS
"${PROJECT_SOURCE_DIR}/src/geant4_application/src/*.cpp")
Expand All @@ -37,13 +62,15 @@ file(GLOB_RECURSE PYTHON_SOURCES CONFIGURE_DEPENDS
pybind11_add_module(${PYTHON_MODULE_NAME} MODULE ${SOURCES} ${PYTHON_SOURCES})

target_compile_definitions(
${PYTHON_MODULE_NAME} PRIVATE VERSION_INFO=${PROJECT_VERSION}
GEANT4_VERSION=${Geant4_VERSION}
)
${PYTHON_MODULE_NAME}
PRIVATE VERSION_INFO=${PROJECT_VERSION} GEANT4_VERSION=${Geant4_VERSION}
AWKWARD_VERSION=${AWKWARD_VERSION}
PYBIND11_VERSION=${PYBIND11_VERSION})

target_include_directories(
${PYTHON_MODULE_NAME} PRIVATE ${PROJECT_SOURCE_DIR}/src/geant4_application/include
${Geant4_INCLUDE_DIRS})
${PYTHON_MODULE_NAME}
PRIVATE ${PROJECT_SOURCE_DIR}/src/geant4_application/include
${Geant4_INCLUDE_DIRS})

target_link_libraries(
${PYTHON_MODULE_NAME} PRIVATE ${Geant4_LIBRARIES} awkward::layout-builder
Expand Down
1 change: 0 additions & 1 deletion external/awkward
Submodule awkward deleted from ffc153
1 change: 0 additions & 1 deletion external/pybind11
Submodule pybind11 deleted from 8a099e
10 changes: 4 additions & 6 deletions src/geant4_python_application/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from __future__ import annotations

import os
import sys
import ctypes
import subprocess
import os
import shutil
import subprocess
import sys
import warnings

geant4_config = shutil.which("geant4-config")
Expand Down Expand Up @@ -55,9 +55,7 @@ def datasets() -> list[(str, str, str)]:
datasets = subprocess.check_output(
[geant4_config, "--datasets"], encoding="utf-8"
).strip()
return [
tuple(line.split()) for line in datasets.split("\n") if line.strip() != ""
]
return [tuple(line.split()) for line in datasets.split("\n") if line.strip() != ""]


def check_datasets() -> bool:
Expand Down

0 comments on commit 2314976

Please sign in to comment.