diff --git a/CMakeLists.txt b/CMakeLists.txt index 1dccb27..16ec696 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,151 +1,130 @@ cmake_minimum_required(VERSION 3.1..3.19) # Basic settings # ============== project(GooseFEM) option(BUILD_TESTS "${PROJECT_NAME}: Build tests" OFF) option(BUILD_EXAMPLES "${PROJECT_NAME}: Build examples" OFF) option(BUILD_DOCS "${PROJECT_NAME}: Build docs" OFF) -option(CHECK_DOCS "${PROJECT_NAME}: Check docs (throw error for every warning)" OFF) # Version # ======= execute_process( COMMAND python -c "from setuptools_scm import get_version; print(get_version())" WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} OUTPUT_VARIABLE ${PROJECT_NAME}_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE) message(STATUS "Building ${PROJECT_NAME} ${${PROJECT_NAME}_VERSION}") # Set target # ========== find_package(xtensor REQUIRED) add_library(${PROJECT_NAME} INTERFACE) target_include_directories(${PROJECT_NAME} INTERFACE $ $) target_link_libraries(${PROJECT_NAME} INTERFACE xtensor) # Installation # ============ include(CMakePackageConfigHelpers) include(GNUInstallDirs) install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/" DESTINATION include) configure_file("include/${PROJECT_NAME}/version.h" "${CMAKE_CURRENT_BINARY_DIR}/version.h" @ONLY) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/version.h" DESTINATION "include/${PROJECT_NAME}/") install(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}-targets) install( EXPORT ${PROJECT_NAME}-targets FILE "${PROJECT_NAME}Targets.cmake" DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}") set(_${PROJECT_NAME} ${CMAKE_SIZEOF_VOID_P}) unset(CMAKE_SIZEOF_VOID_P) write_basic_package_version_file( - "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Version.cmake" - VERSION ${${PROJECT_NAME}_VERSION} + "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake" + VERSION "${${PROJECT_NAME}_VERSION}" COMPATIBILITY AnyNewerVersion) set(CMAKE_SIZEOF_VOID_P ${_${PROJECT_NAME}}) install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}Config.cmake" "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake" DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}") configure_file("${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.pc.in" "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc" @ONLY) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig/") # Add builds # ========== include("${PROJECT_NAME}Config.cmake") include(CTest) # Tests if(BUILD_TESTS) enable_testing() add_subdirectory(test/basic) enable_testing() add_subdirectory(test/gmat) endif() # Examples if(BUILD_EXAMPLES) enable_testing() add_subdirectory(docs/examples) endif() -# Check docs: only this library, throw error for every warning - -if(CHECK_DOCS) - find_package(Doxygen REQUIRED) - - set(DOXYGEN_EXCLUDE_SYMBOLS detail) - set(DOXYGEN_CASE_SENSE_NAMES YES) - set(DOXYGEN_USE_MATHJAX YES) - set(DOXYGEN_QUIET YES) - set(DOXYGEN_WARN_IF_UNDOCUMENTED YES) - set(DOXYGEN_WARN_AS_ERROR YES) - - set(DOXYGEN_ALIASES - "rst=\\verbatim embed:rst:leading-asterisk" - "endrst=\\endverbatim" - "license=@par License:") - - doxygen_add_docs(check_docs "${CMAKE_CURRENT_SOURCE_DIR}/include") -endif() - # Build docs: include dependencies if(BUILD_DOCS) find_package(Doxygen REQUIRED) set(DOXYGEN_EXCLUDE_SYMBOLS detail) set(DOXYGEN_CASE_SENSE_NAMES YES) set(DOXYGEN_USE_MATHJAX YES) set(DOXYGEN_GENERATE_TREEVIEW YES) set(DOXYGEN_JAVADOC_AUTOBRIEF YES) set(DOXYGEN_MACRO_EXPANSION YES) set(DOXYGEN_SOURCE_BROWSER YES) set(DOXYGEN_GENERATE_XML YES) set(DOXYGEN_QUIET YES) set(DOXYGEN_WARN_IF_UNDOCUMENTED YES) + set(DOXYGEN_WARN_AS_ERROR NO) set(DOXYGEN_HTML_EXTRA_STYLESHEET "${CMAKE_CURRENT_SOURCE_DIR}/docs/doxystyle/doxygen-awesome.css" "${CMAKE_CURRENT_SOURCE_DIR}/docs/doxystyle/custom.css") set(DOXYGEN_ALIASES "rst=\\verbatim embed:rst:leading-asterisk" "endrst=\\endverbatim" "license=@par License:") set(DOXYGEN_STRIP_FROM_INC_PATH "${CMAKE_CURRENT_SOURCE_DIR}/include") set(DOXYGEN_STRIP_FROM_PATH "${CMAKE_CURRENT_SOURCE_DIR}/include") - doxygen_add_docs(docs "${CMAKE_CURRENT_SOURCE_DIR}/include") endif() diff --git a/include/GooseFEM/version.h b/include/GooseFEM/version.h index 4b89a58..5953c45 100644 --- a/include/GooseFEM/version.h +++ b/include/GooseFEM/version.h @@ -1,65 +1,65 @@ /** Version information. \file version.h \copyright Copyright 2017. Tom de Geus. All rights reserved. \license This project is released under the GNU Public License (GPLv3). */ #ifndef GOOSEFEM_VERSION_H #define GOOSEFEM_VERSION_H #include "config.h" /** Current version. Either: - Configure using CMake at install time. Internally uses:: python -c "from setuptools_scm import get_version; print(get_version())" - Define externally using:: -DGOOSEFEM_VERSION="`python -c "from setuptools_scm import get_version; print(get_version())"`" From the root of this project. This is what ``setup.py`` does. Note that both ``CMakeLists.txt`` and ``setup.py`` will construct the version using ``setuptools_scm``. Tip: use the environment variable ``SETUPTOOLS_SCM_PRETEND_VERSION`` to overwrite the automatic version. */ #ifndef GOOSEFEM_VERSION -#define GOOSEFEM_VERSION "@GOOSEFEM_VERSION@" +#define GOOSEFEM_VERSION "@GooseFEM_VERSION@" #endif namespace GooseFEM { /** Return version string, e.g.:: "0.8.0" \return std::string */ inline std::string version(); /** Return versions of this library and of all of its dependencies. The output is a list of strings, e.g.:: "goosefem=0.7.0", "xtensor=0.20.1" ... \return List of strings. */ inline std::vector version_dependencies(); } // namespace GooseFEM #include "version.hpp" #endif diff --git a/setup.py b/setup.py index 18f27b0..c7dd2f8 100644 --- a/setup.py +++ b/setup.py @@ -1,52 +1,51 @@ from setuptools import setup, Extension import re import os import pybind11 import pyxtensor -from os import environ from setuptools_scm import get_version version = get_version() include_dirs = [ os.path.abspath('include/'), pyxtensor.find_pyxtensor(), pyxtensor.find_pybind11(), pyxtensor.find_xtensor(), pyxtensor.find_xtl(), pyxtensor.find_eigen()] build = pyxtensor.BuildExt xsimd = pyxtensor.find_xsimd() if xsimd: if len(xsimd) > 0: include_dirs += [xsimd] build.c_opts['unix'] += ['-march=native', '-DXTENSOR_USE_XSIMD'] build.c_opts['msvc'] += ['/DXTENSOR_USE_XSIMD'] build.c_opts['unix'] += ['-DGOOSEFEM_VERSION="{0:s}"'.format(version)] build.c_opts['msvc'] += ['/DGOOSEFEM_VERSION="{0:s}"'.format(version)] ext_modules = [Extension( 'GooseFEM', ['python/main.cpp'], include_dirs = include_dirs, language = 'c++')] setup( name = 'GooseFEM', description = 'Finite element meshes, quadrature, and assembly tools', long_description = 'Finite element meshes, quadrature, and assembly tools', version = version, license = 'GPLv3', author = 'Tom de Geus', author_email = 'tom@geus.me', url = 'https://github.com/tdegeus/GooseFEM', ext_modules = ext_modules, setup_requires = ['pybind11', 'pyxtensor'], cmdclass = {'build_ext': build}, zip_safe = False)