From 73a7fc0b57b382a0e51ccf2a78e7e7956c0c6ee4 Mon Sep 17 00:00:00 2001 From: jcschaff Date: Sun, 2 Jun 2024 14:57:26 -0400 Subject: [PATCH] one /CMakeLists.txt with with OPTION_TARGET_PYTHON_BINDING [true] --- .github/workflows/cd.yml | 4 + .github/workflows/conda.yml | 2 +- .github/workflows/pip.yml | 2 +- .github/workflows/wheels.yml | 8 - CMakeLists.txt | 246 ++++++++------- Dockerfile | 1 + .../pyproject.toml => pyproject.toml | 0 pyvcell-fvsolver/CMakeLists.txt | 168 ----------- pyvcell-fvsolver/README.md | 1 - .../modules/GetGitRevisionDescription.cmake | 284 ------------------ .../GetGitRevisionDescription.cmake.in | 45 --- {pyvcell-fvsolver/src => src}/SolverMain.cpp | 0 {pyvcell-fvsolver/src => src}/SolverMain.h | 0 {pyvcell-fvsolver/src => src}/main.cpp | 0 .../src => src}/pyvcell_fvsolver/__init__.py | 0 {pyvcell-fvsolver/test => test}/test.py | 0 16 files changed, 137 insertions(+), 624 deletions(-) rename pyvcell-fvsolver/pyproject.toml => pyproject.toml (100%) delete mode 100644 pyvcell-fvsolver/CMakeLists.txt delete mode 100644 pyvcell-fvsolver/README.md delete mode 100644 pyvcell-fvsolver/cmake/modules/GetGitRevisionDescription.cmake delete mode 100644 pyvcell-fvsolver/cmake/modules/GetGitRevisionDescription.cmake.in rename {pyvcell-fvsolver/src => src}/SolverMain.cpp (100%) rename {pyvcell-fvsolver/src => src}/SolverMain.h (100%) rename {pyvcell-fvsolver/src => src}/main.cpp (100%) rename {pyvcell-fvsolver/src => src}/pyvcell_fvsolver/__init__.py (100%) rename {pyvcell-fvsolver/test => test}/test.py (100%) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index c6bf330ef..45846e9cb 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -104,6 +104,7 @@ jobs: -G Ninja \ -DCMAKE_C_COMPILER=/opt/homebrew/opt/llvm/bin/clang \ -DCMAKE_CXX_COMPILER=/opt/homebrew/opt/llvm/bin/clang++ \ + -DOPTION_TARGET_PYTHON_BINDING=OFF \ -DOPTION_MINGW=ON \ -DOPTION_TARGET_MESSAGING=OFF \ -DOPTION_TARGET_SMOLDYN_SOLVER=OFF \ @@ -128,6 +129,7 @@ jobs: -G Ninja \ -DCMAKE_C_COMPILER=/usr/local/opt/llvm/bin/clang \ -DCMAKE_CXX_COMPILER=/usr/local/opt/llvm/bin/clang++ \ + -DOPTION_TARGET_PYTHON_BINDING=OFF \ -DOPTION_MINGW=ON \ -DOPTION_TARGET_MESSAGING=OFF \ -DOPTION_TARGET_SMOLDYN_SOLVER=OFF \ @@ -205,6 +207,7 @@ jobs: -G Ninja \ -DCMAKE_C_COMPILER="clang.exe" \ -DCMAKE_CXX_COMPILER="clang++.exe" \ + -DOPTION_TARGET_PYTHON_BINDING=OFF \ -DOPTION_TARGET_MESSAGING=OFF \ -DOPTION_TARGET_SMOLDYN_SOLVER=OFF \ -DOPTION_TARGET_FV_SOLVER=ON \ @@ -253,6 +256,7 @@ jobs: cmake \ -G Ninja \ + -DOPTION_TARGET_PYTHON_BINDING=OFF \ -DOPTION_TARGET_MESSAGING=OFF \ -DOPTION_TARGET_SMOLDYN_SOLVER=OFF \ -DOPTION_TARGET_FV_SOLVER=ON \ diff --git a/.github/workflows/conda.yml b/.github/workflows/conda.yml index fc267d8e7..cd3643f93 100644 --- a/.github/workflows/conda.yml +++ b/.github/workflows/conda.yml @@ -38,7 +38,7 @@ jobs: run: conda build conda.recipe - name: Install - run: conda install -c ${CONDA_PREFIX}/conda-bld/ pyvcell_fvsolver + run: conda install -c ${CONDA_PREFIX}/conda-bld/ . - name: Test run: pytest tests diff --git a/.github/workflows/pip.yml b/.github/workflows/pip.yml index a1f2173ac..933c4cc19 100644 --- a/.github/workflows/pip.yml +++ b/.github/workflows/pip.yml @@ -25,7 +25,7 @@ jobs: python-version: ${{ matrix.python-version }} - name: Build and install - run: pip install --verbose ./pyvcell-fvsolver + run: pip install --verbose . - name: Test run: pytest diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 3fcfe235e..7f1dea9a8 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -27,11 +27,9 @@ jobs: submodules: true - name: Build SDist - working-directory: pyvcell-fvsolver run: pipx run build --sdist - name: Check metadata - working-directory: pyvcell-fvsolver run: pipx run twine check dist/* - name: artifact upload @@ -39,7 +37,6 @@ jobs: with: name: cibw-sdist path: dist/*.tar.gz - working-directory: pyvcell-fvsolver build_wheels: @@ -57,21 +54,17 @@ jobs: - name: build wheel uses: pypa/cibuildwheel@v2.17 - with: - working-directory: pyvcell-fvsolver env: CIBW_ARCHS_MACOS: universal2 CIBW_ARCHS_WINDOWS: auto ARM64 - name: Verify clean directory - working-directory: pyvcell-fvsolver run: git diff --exit-code shell: bash - uses: actions/upload-artifact@v4 with: name: cibw-wheels-${{ matrix.os }} - working-directory: pyvcell-fvsolver path: wheelhouse/*.whl @@ -91,7 +84,6 @@ jobs: - uses: actions/download-artifact@v4 with: - working-directory: pyvcell-fvsolver pattern: cibw-* merge-multiple: true path: dist diff --git a/CMakeLists.txt b/CMakeLists.txt index 2be996eb1..2eab5166d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,8 +1,47 @@ -############################################# -# -# Build 64bit binaries on Mac and target Macos 10.7 or later -# -############################################## +cmake_minimum_required(VERSION 3.27) +option(OPTION_TARGET_PYTHON_BINDING "build Python bindings" ON) +option(OPTION_TARGET_MESSAGING "Messaging (requires libcurl)" off) +option(OPTION_TARGET_DOCS "Generate Doxygen documentation" off) +option(OPTION_TARGET_FV_SOLVER on) +option(OPTION_VCELL "Compile Smoldyn for VCell" ON) +option(OPTION_NSV "Compile Smoldyn with NextSubvolume functionality" OFF) +option(OPTION_USE_OPENGL "Build with OpenGL support" OFF) +option(OPTION_USE_ZLIB "Build with Zlib support" ON) +option(OPTION_USE_LIBTIFF "Build with LibTiff support" OFF) +option(OPTION_USE_ICONV "Build with Libiconv support" OFF) + + +if (OPTION_TARGET_PYTHON_BINDING) + project( + ${SKBUILD_PROJECT_NAME} + VERSION ${SKBUILD_PROJECT_VERSION} + LANGUAGES CXX C Fortran) + set(OPTION_TARGET_MESSAGING OFF) + set(OPTION_TARGET_FV_SOLVER ON) + set(OPTION_TARGET_DOCS OFF) + set(OPTION_VCELL ON) + set(OPTION_NSV OFF) + set(OPTION_USE_OPENGL OFF) + set(OPTION_USE_ZLIB ON) + set(OPTION_USE_LIBTIFF OFF) + set(OPTION_USE_ICONV OFF) +else() + project( + fvsolver + LANGUAGES CXX C Fortran) + set(OPTION_TARGET_LIBSMOLDYN ON) + set(OPTION_VCELL ON) +endif () + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +set(OPTION_USE_OPENGL OFF CACHE BOOL "") + +if(POLICY CMP0057) + cmake_policy(SET CMP0057 NEW) +endif() + if (APPLE) execute_process(COMMAND uname -m OUTPUT_VARIABLE PROCESSOR_ARCHITECTURE OUTPUT_STRIP_TRAILING_WHITESPACE) message("Processor Architecture: ${PROCESSOR_ARCHITECTURE}") @@ -15,13 +54,6 @@ if (APPLE) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__x86_64__") set(CMAKE_OSX_ARCHITECTURES "x86_64") endif() -# set(CMAKE_Fortran_OSX_DEPLOYMENT_TARGET_FLAG "-mmacosx-version-min=10.7" CACHE PATH "") -# set(CMAKE_OSX_DEPLOYMENT_TARGET "10.7" CACHE PATH "") -############################################# -# -# Choose 32bit or 64bit target arch on Linux -# -############################################## elseif (LINUX) option(LINUX_32bit_BINARIES "Build 32bit Linux BINARIES" OFF) option(LINUX_64bit_BINARIES "Build 64bit Linux BINARIES" ON) @@ -44,47 +76,29 @@ elseif (LINUX) endif() endif() -cmake_minimum_required(VERSION 3.17...3.27) -project(fvsolver) -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_CXX_STANDARD_REQUIRED ON) -enable_language(CXX) -enable_language(C) -enable_language(Fortran) - -if(POLICY CMP0057) - cmake_policy(SET CMP0057 NEW) -endif() - set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/") include(GetGitRevisionDescription) git_describe(GIT_DESCRIBE ALLOW_LOOKING_ABOVE_CMAKE_SOURCE_DIR) -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) - -#include (VCellCMakeShowVariables.txt) - -if(DEFINED CMAKE_BUILD_TYPE) - SET(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel.") -else() - SET(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel.") -endif() - include (FindZLIB) -option(OPTION_TARGET_MESSAGING "Messaging (requires libcurl)" off) -option(OPTION_TARGET_DOCS "Generate Doxygen documentation" off) -option(OPTION_TARGET_FV_SOLVER on) -option(OPTION_TARGET_MESSAGING "Messaging (requires libcurl)" off) +if (NOT OPTION_TARGET_PYTHON_BINDING) + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) - -if (${OPTION_TARGET_DOCS}) - add_custom_target(graphviz ALL - "${CMAKE_COMMAND}" "--graphviz=dependencies.dot" . - WORKING_DIRECTORY "${CMAKE_BINARY_DIR}") -endif() + if(DEFINED CMAKE_BUILD_TYPE) + SET(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel.") + else() + SET(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel.") + endif() + + if (${OPTION_TARGET_DOCS}) + add_custom_target(graphviz ALL + "${CMAKE_COMMAND}" "--graphviz=dependencies.dot" . + WORKING_DIRECTORY "${CMAKE_BINARY_DIR}") + endif() +endif(NOT OPTION_TARGET_PYTHON_BINDING) if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") @@ -112,35 +126,24 @@ if (NOT APPLE AND NOT LINUX AND NOT MINGW) message(FATAL_ERROR "Unsupported Operating System or C/C++ Compiler.") endif() -#--------------------------- -# IDE SUPPORT -#--------------------------- -if (MINGW) - set(NETBEANS_WINDOWS TRUE) - set(CMAKE_RC_FLAGS "-DGCC_WINDRES") -endif(MINGW) - add_definitions(-DFORTRAN_UNDERSCORE) ############################################# # installation directories ############################################# -if (NOT OPTION_TARGET_MESSAGING) - set(OPTION_EXE_DIRECTORY "bin" CACHE PATH "installation directory") -else (NOT OPTION_TARGET_MESSAGING) - set(OPTION_EXE_DIRECTORY "../bin" CACHE PATH "installation directory") -endif (NOT OPTION_TARGET_MESSAGING) - -set(OPTION_LIB_DIRECTORY "lib" CACHE PATH "library directory") -set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}") - +if (NOT OPTION_TARGET_PYTHON_BINDING) + if (NOT OPTION_TARGET_MESSAGING) + set(OPTION_EXE_DIRECTORY "bin" CACHE PATH "installation directory") + else (NOT OPTION_TARGET_MESSAGING) + set(OPTION_EXE_DIRECTORY "../bin" CACHE PATH "installation directory") + endif (NOT OPTION_TARGET_MESSAGING) + set(OPTION_LIB_DIRECTORY "lib" CACHE PATH "library directory") + set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}") +endif (NOT OPTION_TARGET_PYTHON_BINDING) add_definitions(-DUNIX) if (OPTION_TARGET_MESSAGING) - #don't need graphics for server side solvers - set(OPTION_USE_OPENGL OFF CACHE BOOL "") - find_package(CURL REQUIRED) set(THREADS_PREFER_PTHREAD_FLAG ON) find_package(Threads REQUIRED) @@ -157,62 +160,73 @@ find_package(HDF5 COMPONENTS HL CXX C) set(HDF_VERSION ${HDF5_VERSION}) ###### ${HDF5_HL_LIBRARIES} ${HDF5_CXX_LIBRARIES} - add_subdirectory(VCellMessaging) - - add_subdirectory(VCellZipUtils) +add_subdirectory(VCellMessaging) - add_subdirectory(libzip-1.2.0) +add_subdirectory(VCellZipUtils) - add_subdirectory(ExpressionParser) +add_subdirectory(libzip-1.2.0) - add_subdirectory(sundials) +add_subdirectory(ExpressionParser) - if (NOT APPLE) - add_subdirectory(blas) - endif() +add_subdirectory(sundials) - option(OPTION_VCELL "Compile Smoldyn for VCell" ON) - option(OPTION_NSV "Compile Smoldyn with NextSubvolume functionality" OFF) - option(OPTION_USE_OPENGL "Build with OpenGL support" OFF) - option(OPTION_USE_ZLIB "Build with Zlib support" ON) - option(OPTION_USE_LIBTIFF "Build with LibTiff support" OFF) - option(OPTION_USE_ICONV "Build with Libiconv support" OFF) - SET(HAVE_ZLIB TRUE) - set(OPTION_TARGET_LIBSMOLDYN ON) - set(OPTION_VCELL ON) - add_subdirectory(bridgeVCellSmoldyn) - add_subdirectory(smoldyn-2.38) - - add_subdirectory(VCell) - add_subdirectory(PCGPack) - add_subdirectory(qhull) - -include(FetchContent) -FetchContent_Declare( - googletest - URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip -) -if (WINDOWS) - # For Windows: Prevent overriding the parent project's compiler/linker settings - set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) +if (NOT APPLE) + add_subdirectory(blas) endif() -FetchContent_MakeAvailable(googletest) -enable_testing() - -get_cmake_property(_variableNames VARIABLES) -list (SORT _variableNames) -foreach (_variableName ${_variableNames}) - message(STATUS "${_variableName}=${${_variableName}}") -endforeach() - -include(CMakePrintHelpers) -cmake_print_variables(OPTION_TARGET_MESSAGING - OPTION_TARGET_DOCS - OPTION_TARGET_FV_SOLVER - OPTION_TARGET_LIBSMOLDYN OPTION_TARGET_VCELL OPTION_TARGET_NSV ) -cmake_print_variables(CMAKE_CXX_FLAGS CMAKE_C_FLAGS CMAKE_Fortran_FLAGS) -cmake_print_variables(CMAKE_SYSTEM_NAME WINDOWS WIN32 MINGW APPLE ARCH_64bit ARCH_32bit) -cmake_print_variables(CMAKE_CPP_COMPILER CMAKE_C_COMPILER CMAKE_CXX_COMPILER CMAKE_Fortran_COMPILER) -cmake_print_variables(HAVE_ZLIB) +SET(HAVE_ZLIB TRUE) +add_subdirectory(bridgeVCellSmoldyn) +add_subdirectory(smoldyn-2.38) + +add_subdirectory(VCell) +add_subdirectory(PCGPack) +add_subdirectory(qhull) + +if (OPTION_TARGET_PYTHON_BINDING) + # Find the module development requirements (requires FindPython from 3.17 or + # scikit-build-core's built-in backport) + find_package(Python REQUIRED COMPONENTS Interpreter Development.Module) + find_package(pybind11 CONFIG REQUIRED) + + # Add a library using FindPython's tooling (pybind11 also provides a helper like this) + python_add_library(_core MODULE src/main.cpp src/SolverMain.cpp src/SolverMain.h WITH_SOABI) + target_link_libraries(_core PRIVATE vcell pybind11::headers) + + # This is passing in the version as a define just as an example + target_compile_definitions(_core PRIVATE VERSION_INFO=${PROJECT_VERSION}) + + # The install directory is the output (wheel) directory + install(TARGETS _core DESTINATION pyvcell_fvsolver) + +else(OPTION_TARGET_PYTHON_BINDING) + + include(FetchContent) + FetchContent_Declare( + googletest + URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip + ) + if (WINDOWS) + # For Windows: Prevent overriding the parent project's compiler/linker settings + set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) + endif() + FetchContent_MakeAvailable(googletest) + enable_testing() + + get_cmake_property(_variableNames VARIABLES) + list (SORT _variableNames) + foreach (_variableName ${_variableNames}) + message(STATUS "${_variableName}=${${_variableName}}") + endforeach() + + include(CMakePrintHelpers) + cmake_print_variables(OPTION_TARGET_MESSAGING + OPTION_TARGET_DOCS + OPTION_TARGET_FV_SOLVER + OPTION_TARGET_LIBSMOLDYN OPTION_TARGET_VCELL OPTION_TARGET_NSV ) + cmake_print_variables(CMAKE_CXX_FLAGS CMAKE_C_FLAGS CMAKE_Fortran_FLAGS) + cmake_print_variables(CMAKE_SYSTEM_NAME WINDOWS WIN32 MINGW APPLE ARCH_64bit ARCH_32bit) + cmake_print_variables(CMAKE_CPP_COMPILER CMAKE_C_COMPILER CMAKE_CXX_COMPILER CMAKE_Fortran_COMPILER) + cmake_print_variables(HAVE_ZLIB) + +endif (OPTION_TARGET_PYTHON_BINDING) \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index f4a40fe15..04521ae87 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,6 +11,7 @@ WORKDIR /vcellroot/build RUN cmake \ -G Ninja \ + -DOPTION_TARGET_PYTHON_BINDING=OFF \ -DOPTION_TARGET_MESSAGING=ON \ -DOPTION_TARGET_SMOLDYN_SOLVER=OFF \ -DOPTION_TARGET_FV_SOLVER=ON \ diff --git a/pyvcell-fvsolver/pyproject.toml b/pyproject.toml similarity index 100% rename from pyvcell-fvsolver/pyproject.toml rename to pyproject.toml diff --git a/pyvcell-fvsolver/CMakeLists.txt b/pyvcell-fvsolver/CMakeLists.txt deleted file mode 100644 index 83c05561d..000000000 --- a/pyvcell-fvsolver/CMakeLists.txt +++ /dev/null @@ -1,168 +0,0 @@ -cmake_minimum_required(VERSION 3.29) - -project( - ${SKBUILD_PROJECT_NAME} - VERSION ${SKBUILD_PROJECT_VERSION} - LANGUAGES CXX C Fortran) - -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_CXX_STANDARD_REQUIRED ON) - -if(POLICY CMP0057) - cmake_policy(SET CMP0057 NEW) -endif() - -############################################# -# -# Build 64bit binaries on Mac and target Macos 10.7 or later -# -############################################## -if (APPLE) - execute_process(COMMAND uname -m OUTPUT_VARIABLE PROCESSOR_ARCHITECTURE OUTPUT_STRIP_TRAILING_WHITESPACE) - message("Processor Architecture: ${PROCESSOR_ARCHITECTURE}") - if (PROCESSOR_ARCHITECTURE STREQUAL "arm64") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__arm64__") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__arm64__") - set(CMAKE_OSX_ARCHITECTURES "arm64") - else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__x86_64__") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__x86_64__") - set(CMAKE_OSX_ARCHITECTURES "x86_64") - endif() -# set(CMAKE_Fortran_OSX_DEPLOYMENT_TARGET_FLAG "-mmacosx-version-min=10.7" CACHE PATH "") -# set(CMAKE_OSX_DEPLOYMENT_TARGET "10.7" CACHE PATH "") -############################################# -# -# Choose 32bit or 64bit target arch on Linux -# -############################################## -elseif (LINUX) - option(LINUX_32bit_BINARIES "Build 32bit Linux BINARIES" OFF) - option(LINUX_64bit_BINARIES "Build 64bit Linux BINARIES" ON) - - if (LINUX_32bit_BINARIES AND LINUX_64bit_BINARIES) - message(FATAL_ERROR "It is required to select either 32bit or 64bit Linux Binaries, not both") - endif() - - if (LINUX_32bit_BINARIES) - set (ARCH_64bit FALSE) - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32") - set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32") - set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -m32") - endif() - - if (LINUX_64bit_BINARIES) - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64") - set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m64") - set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -m64") - endif() -endif() - -if(POLICY CMP0057) - cmake_policy(SET CMP0057 NEW) -endif() - -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/") - -include(GetGitRevisionDescription) -git_describe(GIT_DESCRIBE ALLOW_LOOKING_ABOVE_CMAKE_SOURCE_DIR) - -include (FindZLIB) - -option(OPTION_TARGET_MESSAGING "Messaging (requires libcurl)" off) -option(OPTION_TARGET_DOCS "Generate Doxygen documentation" off) -option(OPTION_TARGET_FV_SOLVER on) -option(OPTION_TARGET_MESSAGING "Messaging (requires libcurl)" off) - - -if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") - set(CMAKE_OSX_DEPLOYMENT_TARGET "10.7" CACHE STRING "Choose minimum deploy target for Macos machines") -endif() - -set(LINUX FALSE) -if (${CMAKE_SYSTEM_NAME} MATCHES Linux) - set(LINUX TRUE) -endif() - -set(WINDOWS FALSE) -if (${CMAKE_SYSTEM_NAME} MATCHES Windows) - set(WINDOWS TRUE) - set(WIN32 TRUE) - set(MINGW TRUE) -endif() - -set (ARCH_64bit FALSE) -if (CMAKE_SIZEOF_VOID_P EQUAL 8) - set (ARCH_64bit TRUE) -endif() - -if (NOT APPLE AND NOT LINUX AND NOT MINGW) - message(FATAL_ERROR "Unsupported Operating System or C/C++ Compiler.") -endif() - -add_definitions(-DFORTRAN_UNDERSCORE) - -set(OPTION_EXE_DIRECTORY "bin" CACHE PATH "installation directory") -set(OPTION_LIB_DIRECTORY "lib" CACHE PATH "library directory") -set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}") - - -add_definitions(-DUNIX) - -set(HDF5_USE_STATIC_LIBRARIES ON) -if(WINDOWS OR WIN32 OR WIN64) - set(HDF5_USE_STATIC_LIBRARIES OFF) - add_definitions(-DZIP_STATIC) -endif () -#CMakeList.txt that comes with hdf5 switches library name if compiled with debug -find_package(HDF5 COMPONENTS HL CXX C) -set(HDF_VERSION ${HDF5_VERSION}) -###### ${HDF5_HL_LIBRARIES} ${HDF5_CXX_LIBRARIES} - - add_subdirectory(../VCellMessaging bin/VCellMessaging) - - add_subdirectory(../VCellZipUtils bin/VCellZipUtils) - - add_subdirectory(../libzip-1.2.0 bin/libzip-1.2.0) - - add_subdirectory(../ExpressionParser bin/ExpressionParser) - - add_subdirectory(../sundials bin/sundials) - - if (NOT APPLE) - add_subdirectory(../blas bin/blas) - endif() - - option(OPTION_VCELL "Compile Smoldyn for VCell" ON) - option(OPTION_NSV "Compile Smoldyn with NextSubvolume functionality" OFF) - option(OPTION_USE_OPENGL "Build with OpenGL support" OFF) - option(OPTION_USE_ZLIB "Build with Zlib support" ON) - option(OPTION_USE_LIBTIFF "Build with LibTiff support" OFF) - option(OPTION_USE_ICONV "Build with Libiconv support" OFF) - SET(HAVE_ZLIB TRUE) - set(OPTION_TARGET_LIBSMOLDYN ON) - set(OPTION_VCELL ON) - add_subdirectory(../bridgeVCellSmoldyn bin/bridgeVCellSmoldyn) - add_subdirectory(../smoldyn-2.38 bin/smoldyn-2.38) - - add_subdirectory(../VCell bin/VCell) - add_subdirectory(../PCGPack bin/PCGPack) - add_subdirectory(../qhull bin/qhull) - - - -# Find the module development requirements (requires FindPython from 3.17 or -# scikit-build-core's built-in backport) -find_package(Python REQUIRED COMPONENTS Interpreter Development.Module) -find_package(pybind11 CONFIG REQUIRED) - -# Add a library using FindPython's tooling (pybind11 also provides a helper like this) -python_add_library(_core MODULE src/main.cpp src/SolverMain.cpp src/SolverMain.h WITH_SOABI) -target_link_libraries(_core PRIVATE vcell pybind11::headers) - -# This is passing in the version as a define just as an example -target_compile_definitions(_core PRIVATE VERSION_INFO=${PROJECT_VERSION}) - -# The install directory is the output (wheel) directory -install(TARGETS _core DESTINATION pyvcell_fvsolver) \ No newline at end of file diff --git a/pyvcell-fvsolver/README.md b/pyvcell-fvsolver/README.md deleted file mode 100644 index b17fbaa4a..000000000 --- a/pyvcell-fvsolver/README.md +++ /dev/null @@ -1 +0,0 @@ -## pyvcell_fvsolver diff --git a/pyvcell-fvsolver/cmake/modules/GetGitRevisionDescription.cmake b/pyvcell-fvsolver/cmake/modules/GetGitRevisionDescription.cmake deleted file mode 100644 index e48b20678..000000000 --- a/pyvcell-fvsolver/cmake/modules/GetGitRevisionDescription.cmake +++ /dev/null @@ -1,284 +0,0 @@ -# - Returns a version string from Git -# -# These functions force a re-configure on each git commit so that you can -# trust the values of the variables in your build system. -# -# get_git_head_revision( [ALLOW_LOOKING_ABOVE_CMAKE_SOURCE_DIR]) -# -# Returns the refspec and sha hash of the current head revision -# -# git_describe( [ ...]) -# -# Returns the results of git describe on the source tree, and adjusting -# the output so that it tests false if an error occurs. -# -# git_describe_working_tree( [ ...]) -# -# Returns the results of git describe on the working tree (--dirty option), -# and adjusting the output so that it tests false if an error occurs. -# -# git_get_exact_tag( [ ...]) -# -# Returns the results of git describe --exact-match on the source tree, -# and adjusting the output so that it tests false if there was no exact -# matching tag. -# -# git_local_changes() -# -# Returns either "CLEAN" or "DIRTY" with respect to uncommitted changes. -# Uses the return code of "git diff-index --quiet HEAD --". -# Does not regard untracked files. -# -# Requires CMake 2.6 or newer (uses the 'function' command) -# -# Original Author: -# 2009-2020 Ryan Pavlik -# http://academic.cleardefinition.com -# -# Copyright 2009-2013, Iowa State University. -# Copyright 2013-2020, Ryan Pavlik -# Copyright 2013-2020, Contributors -# SPDX-License-Identifier: BSL-1.0 -# Distributed under the Boost Software License, Version 1.0. -# (See accompanying file LICENSE_1_0.txt or copy at -# http://www.boost.org/LICENSE_1_0.txt) - -if(__get_git_revision_description) - return() -endif() -set(__get_git_revision_description YES) - -# We must run the following at "include" time, not at function call time, -# to find the path to this module rather than the path to a calling list file -get_filename_component(_gitdescmoddir ${CMAKE_CURRENT_LIST_FILE} PATH) - -# Function _git_find_closest_git_dir finds the next closest .git directory -# that is part of any directory in the path defined by _start_dir. -# The result is returned in the parent scope variable whose name is passed -# as variable _git_dir_var. If no .git directory can be found, the -# function returns an empty string via _git_dir_var. -# -# Example: Given a path C:/bla/foo/bar and assuming C:/bla/.git exists and -# neither foo nor bar contain a file/directory .git. This wil return -# C:/bla/.git -# -function(_git_find_closest_git_dir _start_dir _git_dir_var) - set(cur_dir "${_start_dir}") - set(git_dir "${_start_dir}/.git") - while(NOT EXISTS "${git_dir}") - # .git dir not found, search parent directories - set(git_previous_parent "${cur_dir}") - get_filename_component(cur_dir "${cur_dir}" DIRECTORY) - if(cur_dir STREQUAL git_previous_parent) - # We have reached the root directory, we are not in git - set(${_git_dir_var} - "" - PARENT_SCOPE) - return() - endif() - set(git_dir "${cur_dir}/.git") - endwhile() - set(${_git_dir_var} - "${git_dir}" - PARENT_SCOPE) -endfunction() - -function(get_git_head_revision _refspecvar _hashvar) - _git_find_closest_git_dir("${CMAKE_CURRENT_SOURCE_DIR}" GIT_DIR) - - if("${ARGN}" STREQUAL "ALLOW_LOOKING_ABOVE_CMAKE_SOURCE_DIR") - set(ALLOW_LOOKING_ABOVE_CMAKE_SOURCE_DIR TRUE) - else() - set(ALLOW_LOOKING_ABOVE_CMAKE_SOURCE_DIR FALSE) - endif() - if(NOT "${GIT_DIR}" STREQUAL "") - file(RELATIVE_PATH _relative_to_source_dir "${CMAKE_SOURCE_DIR}" - "${GIT_DIR}") - if("${_relative_to_source_dir}" MATCHES "[.][.]" AND NOT ALLOW_LOOKING_ABOVE_CMAKE_SOURCE_DIR) - # We've gone above the CMake root dir. - set(GIT_DIR "") - endif() - endif() - if("${GIT_DIR}" STREQUAL "") - set(${_refspecvar} - "GITDIR-NOTFOUND" - PARENT_SCOPE) - set(${_hashvar} - "GITDIR-NOTFOUND" - PARENT_SCOPE) - return() - endif() - - # Check if the current source dir is a git submodule or a worktree. - # In both cases .git is a file instead of a directory. - # - if(NOT IS_DIRECTORY ${GIT_DIR}) - # The following git command will return a non empty string that - # points to the super project working tree if the current - # source dir is inside a git submodule. - # Otherwise the command will return an empty string. - # - execute_process( - COMMAND "${GIT_EXECUTABLE}" rev-parse - --show-superproject-working-tree - WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" - OUTPUT_VARIABLE out - ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) - if(NOT "${out}" STREQUAL "") - # If out is empty, GIT_DIR/CMAKE_CURRENT_SOURCE_DIR is in a submodule - file(READ ${GIT_DIR} submodule) - string(REGEX REPLACE "gitdir: (.*)$" "\\1" GIT_DIR_RELATIVE - ${submodule}) - string(STRIP ${GIT_DIR_RELATIVE} GIT_DIR_RELATIVE) - get_filename_component(SUBMODULE_DIR ${GIT_DIR} PATH) - get_filename_component(GIT_DIR ${SUBMODULE_DIR}/${GIT_DIR_RELATIVE} - ABSOLUTE) - set(HEAD_SOURCE_FILE "${GIT_DIR}/HEAD") - else() - # GIT_DIR/CMAKE_CURRENT_SOURCE_DIR is in a worktree - file(READ ${GIT_DIR} worktree_ref) - # The .git directory contains a path to the worktree information directory - # inside the parent git repo of the worktree. - # - string(REGEX REPLACE "gitdir: (.*)$" "\\1" git_worktree_dir - ${worktree_ref}) - string(STRIP ${git_worktree_dir} git_worktree_dir) - _git_find_closest_git_dir("${git_worktree_dir}" GIT_DIR) - set(HEAD_SOURCE_FILE "${git_worktree_dir}/HEAD") - endif() - else() - set(HEAD_SOURCE_FILE "${GIT_DIR}/HEAD") - endif() - set(GIT_DATA "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/git-data") - if(NOT EXISTS "${GIT_DATA}") - file(MAKE_DIRECTORY "${GIT_DATA}") - endif() - - if(NOT EXISTS "${HEAD_SOURCE_FILE}") - return() - endif() - set(HEAD_FILE "${GIT_DATA}/HEAD") - configure_file("${HEAD_SOURCE_FILE}" "${HEAD_FILE}" COPYONLY) - - configure_file("${_gitdescmoddir}/GetGitRevisionDescription.cmake.in" - "${GIT_DATA}/grabRef.cmake" @ONLY) - include("${GIT_DATA}/grabRef.cmake") - - set(${_refspecvar} - "${HEAD_REF}" - PARENT_SCOPE) - set(${_hashvar} - "${HEAD_HASH}" - PARENT_SCOPE) -endfunction() - -function(git_describe _var) - if(NOT GIT_FOUND) - find_package(Git QUIET) - endif() - get_git_head_revision(refspec hash) - if(NOT GIT_FOUND) - set(${_var} - "GIT-NOTFOUND" - PARENT_SCOPE) - return() - endif() - if(NOT hash) - set(${_var} - "HEAD-HASH-NOTFOUND" - PARENT_SCOPE) - return() - endif() - - # TODO sanitize - #if((${ARGN}" MATCHES "&&") OR - # (ARGN MATCHES "||") OR - # (ARGN MATCHES "\\;")) - # message("Please report the following error to the project!") - # message(FATAL_ERROR "Looks like someone's doing something nefarious with git_describe! Passed arguments ${ARGN}") - #endif() - - #message(STATUS "Arguments to execute_process: ${ARGN}") - - execute_process( - COMMAND "${GIT_EXECUTABLE}" describe --tags --always ${hash} ${ARGN} - WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" - RESULT_VARIABLE res - OUTPUT_VARIABLE out - ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) - if(NOT res EQUAL 0) - set(out "${out}-${res}-NOTFOUND") - endif() - - set(${_var} - "${out}" - PARENT_SCOPE) -endfunction() - -function(git_describe_working_tree _var) - if(NOT GIT_FOUND) - find_package(Git QUIET) - endif() - if(NOT GIT_FOUND) - set(${_var} - "GIT-NOTFOUND" - PARENT_SCOPE) - return() - endif() - - execute_process( - COMMAND "${GIT_EXECUTABLE}" describe --dirty ${ARGN} - WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" - RESULT_VARIABLE res - OUTPUT_VARIABLE out - ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) - if(NOT res EQUAL 0) - set(out "${out}-${res}-NOTFOUND") - endif() - - set(${_var} - "${out}" - PARENT_SCOPE) -endfunction() - -function(git_get_exact_tag _var) - git_describe(out --exact-match ${ARGN}) - set(${_var} - "${out}" - PARENT_SCOPE) -endfunction() - -function(git_local_changes _var) - if(NOT GIT_FOUND) - find_package(Git QUIET) - endif() - get_git_head_revision(refspec hash) - if(NOT GIT_FOUND) - set(${_var} - "GIT-NOTFOUND" - PARENT_SCOPE) - return() - endif() - if(NOT hash) - set(${_var} - "HEAD-HASH-NOTFOUND" - PARENT_SCOPE) - return() - endif() - - execute_process( - COMMAND "${GIT_EXECUTABLE}" diff-index --quiet HEAD -- - WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" - RESULT_VARIABLE res - OUTPUT_VARIABLE out - ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) - if(res EQUAL 0) - set(${_var} - "CLEAN" - PARENT_SCOPE) - else() - set(${_var} - "DIRTY" - PARENT_SCOPE) - endif() -endfunction() diff --git a/pyvcell-fvsolver/cmake/modules/GetGitRevisionDescription.cmake.in b/pyvcell-fvsolver/cmake/modules/GetGitRevisionDescription.cmake.in deleted file mode 100644 index 27982af58..000000000 --- a/pyvcell-fvsolver/cmake/modules/GetGitRevisionDescription.cmake.in +++ /dev/null @@ -1,45 +0,0 @@ -# -# Internal file for GetGitRevisionDescription.cmake -# -# Requires CMake 2.6 or newer (uses the 'function' command) -# -# Original Author: -# 2009-2010 Ryan Pavlik -# http://academic.cleardefinition.com -# Iowa State University HCI Graduate Program/VRAC -# -# Copyright 2009-2012, Iowa State University -# Copyright 2011-2015, Contributors -# Distributed under the Boost Software License, Version 1.0. -# (See accompanying file LICENSE_1_0.txt or copy at -# http://www.boost.org/LICENSE_1_0.txt) -# SPDX-License-Identifier: BSL-1.0 - -set(HEAD_HASH) - -file(READ "@HEAD_FILE@" HEAD_CONTENTS LIMIT 1024) - -string(STRIP "${HEAD_CONTENTS}" HEAD_CONTENTS) -if(HEAD_CONTENTS MATCHES "ref") - # named branch - string(REPLACE "ref: " "" HEAD_REF "${HEAD_CONTENTS}") - if(EXISTS "@GIT_DIR@/${HEAD_REF}") - configure_file("@GIT_DIR@/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY) - else() - if(EXISTS "@GIT_DIR@/packed-refs") - configure_file("@GIT_DIR@/packed-refs" "@GIT_DATA@/packed-refs" COPYONLY) - file(READ "@GIT_DATA@/packed-refs" PACKED_REFS) - if(${PACKED_REFS} MATCHES "([0-9a-z]*) ${HEAD_REF}") - set(HEAD_HASH "${CMAKE_MATCH_1}") - endif() - endif() - endif() -else() - # detached HEAD - configure_file("@GIT_DIR@/HEAD" "@GIT_DATA@/head-ref" COPYONLY) -endif() - -if(NOT HEAD_HASH) - file(READ "@GIT_DATA@/head-ref" HEAD_HASH LIMIT 1024) - string(STRIP "${HEAD_HASH}" HEAD_HASH) -endif() diff --git a/pyvcell-fvsolver/src/SolverMain.cpp b/src/SolverMain.cpp similarity index 100% rename from pyvcell-fvsolver/src/SolverMain.cpp rename to src/SolverMain.cpp diff --git a/pyvcell-fvsolver/src/SolverMain.h b/src/SolverMain.h similarity index 100% rename from pyvcell-fvsolver/src/SolverMain.h rename to src/SolverMain.h diff --git a/pyvcell-fvsolver/src/main.cpp b/src/main.cpp similarity index 100% rename from pyvcell-fvsolver/src/main.cpp rename to src/main.cpp diff --git a/pyvcell-fvsolver/src/pyvcell_fvsolver/__init__.py b/src/pyvcell_fvsolver/__init__.py similarity index 100% rename from pyvcell-fvsolver/src/pyvcell_fvsolver/__init__.py rename to src/pyvcell_fvsolver/__init__.py diff --git a/pyvcell-fvsolver/test/test.py b/test/test.py similarity index 100% rename from pyvcell-fvsolver/test/test.py rename to test/test.py