diff --git a/contrib/meshgen11_dealii/CMakeLists.txt b/contrib/meshgen11_dealii/CMakeLists.txt index 3073e50..a5db562 100644 --- a/contrib/meshgen11_dealii/CMakeLists.txt +++ b/contrib/meshgen11_dealii/CMakeLists.txt @@ -8,10 +8,10 @@ ## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ## copies of the Software, and to permit persons to whom the Software is ## furnished to do so, subject to the following conditions: -## +## ## The above copyright notice and this permission notice shall be included in ## all copies or substantial portions of the Software. -## +## ## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ## IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -22,65 +22,39 @@ ## ## --------------------------------------------------------------------- -CMAKE_MINIMUM_REQUIRED(VERSION 3.5.0) -set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) -PROJECT(meshgen11_dealii) - -IF(NOT CMAKE_BUILD_TYPE) - SET(CMAKE_BUILD_TYPE "DEBUG") - #SET(CMAKE_BUILD_TYPE "RELEASE") - #SET(CMAKE_BUILD_TYPE "RELWITHDEBINFO") - #SET(CMAKE_BUILD_TYPE "MINSIZEREL") -ENDIF() - -# set(DEAL_II_DIR "/home/xywei/apps" CACHE STRING "Deal.II dir") -# deal.II >= 8.4.1 -FIND_PACKAGE(deal.II REQUIRED - HINTS ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR} $ENV{CONDA_PREFIX} - ) +cmake_minimum_required(VERSION 3.15.0) +project(meshgen11_dealii LANGUAGES CXX) -DEAL_II_INITIALIZE_CACHED_VARIABLES() +set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ version selection") -find_package( PythonInterp 3.8 EXACT ) -find_package( PythonLibs 3.8 EXACT ) +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE "Debug") +endif() -add_subdirectory(pybind11) -pybind11_add_module(meshgen11 meshgen.cpp) -set_target_properties(meshgen11 PROPERTIES PREFIX "") -set_target_properties(meshgen11 PROPERTIES OUTPUT_NAME "meshgen") +# deal.II +find_package(deal.II REQUIRED + HINTS ${DEAL_II_DIR} $ENV{DEAL_II_DIR} $ENV{CONDA_PREFIX}) +deal_ii_initialize_cached_variables() -if(FALSE) - # This script does not work on current Debian testing - DEAL_II_SETUP_TARGET(meshgen11) -else() - SET(_build "RELEASE") - STRING(TOLOWER "${CMAKE_BUILD_TYPE}" _cmake_build_type) - IF("${_cmake_build_type}" MATCHES "debug") - SET(_build "DEBUG") - ENDIF() - SET_PROPERTY(TARGET meshgen11 APPEND PROPERTY - INCLUDE_DIRECTORIES "${DEAL_II_INCLUDE_DIRS}" - ) - SET_PROPERTY(TARGET meshgen11 APPEND PROPERTY - INCLUDE_DIRECTORIES "/usr/include/" - ) - SET_PROPERTY(TARGET meshgen11 APPEND_STRING PROPERTY - COMPILE_FLAGS "${DEAL_II_CXX_FLAGS} ${DEAL_II_CXX_FLAGS_${_build}}" - ) - SET_PROPERTY(TARGET meshgen11 APPEND_STRING PROPERTY - LINK_FLAGS " ${DEAL_II_LINKER_FLAGS} ${DEAL_II_LINKER_FLAGS_${_build}} $ENV{DEAL_II_LINKER_FLAGS}" - ) - SET_PROPERTY(TARGET meshgen11 APPEND PROPERTY - COMPILE_DEFINITIONS "${DEAL_II_USER_DEFINITIONS};${DEAL_II_USER_DEFINITIONS_${_build}}" - ) - GET_PROPERTY(_type TARGET meshgen11 PROPERTY TYPE) - IF(NOT "${_type}" STREQUAL "OBJECT_LIBRARY") - TARGET_LINK_LIBRARIES(meshgen11 PRIVATE ${DEAL_II_TARGET_${_build}}) - ENDIF() +# Python +find_package(Python REQUIRED COMPONENTS Interpreter Development) +find_package(pybind11 CONFIG) +if (NOT pybind11_FOUND) + add_subdirectory(pybind11) endif() -ADD_CUSTOM_COMMAND(TARGET meshgen11 POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy - "meshgen.*.so" - "meshgen.so" - COMMENT "Copied meshgen lib to meshgen.so") +pybind11_add_module(meshgen11 meshgen.cpp) +set_target_properties(meshgen11 PROPERTIES + OUTPUT_NAME "meshgen" + LINK_FLAGS ${DEAL_II_LINKER_FLAGS} ${DEAL_II_LINKER_FLAGS_RELEASE} + COMPILE_DEFINITIONS ${DEAL_II_USER_DEFINITIONS} + INTERPROCEDURAL_OPTIMIZATION ON + VISIBILITY_INLINES_HIDDEN ON) +target_include_directories(meshgen11 PRIVATE ${DEAL_II_INCLUDE_DIRS}) +target_link_libraries(meshgen11 PRIVATE ${DEAL_II_TARGET_RELEASE}) + +add_custom_command(TARGET meshgen11 POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy + "meshgen.*.so" + "meshgen.so" + COMMENT "Copied meshgen lib to meshgen.so") diff --git a/contrib/meshgen11_dealii/README.md b/contrib/meshgen11_dealii/README.md index 1de97ae..c3e7ec7 100644 --- a/contrib/meshgen11_dealii/README.md +++ b/contrib/meshgen11_dealii/README.md @@ -13,9 +13,7 @@ To build `meshgen11`, you need: ## Usage The script `build.sh` also copies the built library to voluemential path so that you can use - -``` +```python import voluemential.meshgen ``` - directly. diff --git a/contrib/meshgen11_dealii/build.sh b/contrib/meshgen11_dealii/build.sh index c2e72f6..5cf490f 100755 --- a/contrib/meshgen11_dealii/build.sh +++ b/contrib/meshgen11_dealii/build.sh @@ -9,10 +9,10 @@ ## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ## copies of the Software, and to permit persons to whom the Software is ## furnished to do so, subject to the following conditions: -## +## ## The above copyright notice and this permission notice shall be included in ## all copies or substantial portions of the Software. -## +## ## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ## IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -25,22 +25,20 @@ set -e -mkdir -p build -cd build -cmake .. -make -cd .. +cmake -Bbuild -DCMAKE_BUILD_TYPE=Release +cmake --build build --verbose -echo Module built: -echo ${PWD}/build/meshgen.so +echo 'Module built:' +echo "${PWD}/build/meshgen.so" +outfile=$(realpath ../../volumential/meshgen_dealii.so) if [ -f build/meshgen.so ]; then - cp build/meshgen.so ../../volumential/meshgen_dealii.so + cp build/meshgen.so "${outfile}" elif [ -f build/meshgen.dylib ]; then - cp build/meshgen.dylib ../../volumential/meshgen_dealii.so + cp build/meshgen.dylib "${outfile}" else echo "Something went wrong. Build failed." exit 1 fi -echo Library copied to volumential path. +echo "Library copied to '${outfile}'." diff --git a/contrib/meshgen11_dealii/meshgen.cpp b/contrib/meshgen11_dealii/meshgen.cpp index 6f3d15d..9ecf545 100644 --- a/contrib/meshgen11_dealii/meshgen.cpp +++ b/contrib/meshgen11_dealii/meshgen.cpp @@ -605,6 +605,7 @@ py::tuple make_uniform_cubic_grid(int q, int level, int dim, return make_uniform_cubic_grid_details<3>(q, level); } else { std::cout << "Dimension must be 1,2 or 3." << std::endl; + return py::tuple(); } }