8000 Feature/generate export header by ClausKlein · Pull Request #439 · spglib/spglib · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Feature/generate export header #439

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .cmake-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
format:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discuss in #221

tab_size: 8
line_width: 80
dangle_parens: true
use_tabchars: true
separate_ctrl_name_with_space: true

markup:
enable_markup: false
6 changes: 3 additions & 3 deletions .github/workflows/step_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,17 @@ jobs:
# - os: windows-2019
# toolchain: windows
# python-version: "3.x"
- os: macos-11
- os: macos-13
toolchain: macos
python-version: "3.x"
- os: windows-latest
toolchain: windows
python-version: "3.x"
experimental: true
- os: macos-latest
- os: macos-14
toolchain: macos
python-version: "3.x"
experimental: true
# experimental: true
# - python-version: "3.13"
# experimental: true
# pre: true
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,4 @@ venv
env
.venv
.env
.vs/
62 changes: 41 additions & 21 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.20...3.29)
cmake_minimum_required(VERSION 3.25...3.29)

#[=============================================================================[
# Basic project definition #
Expand All @@ -13,30 +13,47 @@ dynamic_version(
list(APPEND CMAKE_MESSAGE_CONTEXT Spglib)
project(Spglib
VERSION ${PROJECT_VERSION}
LANGUAGES C)
LANGUAGES C CXX
)
set(Spglib_VERSION_FULL ${PROJECT_VERSION_FULL})
set(Spglib_COMMIT ${GIT_COMMIT})

# Back-porting to PROJECT_IS_TOP_LEVEL to older cmake
# TODO: Remove when requiring cmake >= 3.21
if (NOT DEFINED Spglib_IS_TOP_LEVEL)
if (CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
set(PROJECT_IS_TOP_LEVEL ON)
set(Spglib_IS_TOP_LEVEL ON)
else ()
set(PROJECT_IS_TOP_LEVEL OFF)
set(Spglib_IS_TOP_LEVEL OFF)
endif ()
if (PROJECT_IS_TOP_LEVEL)
set(Spglib_IS_TOP_LEVEL ON)
else ()
set(Spglib_IS_TOP_LEVEL OFF)
endif ()

set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS OFF)
if (NOT DEFINED CMAKE_C_STANDARD)
set(CMAKE_C_STANDARD 17)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS OFF)
endif ()

if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif ()

set(stageDir ${CMAKE_CURRENT_BINARY_DIR})
include(GNUInstallDirs)

add_library(Spglib_symspg)

if (NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${stageDir}/${CMAKE_INSTALL_BINDIR})
add_custom_command(
TARGET Spglib_symspg POST_BUILD
COMMAND
${CMAKE_COMMAND} -E make_directory ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
)
endif ()
if (NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${stageDir}/${CMAKE_INSTALL_LIBDIR})
endif ()
if (NOT CMAKE_ARCHIVE_OUTPUT_DIRECTORY)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${stageDir}/${CMAKE_INSTALL_LIBDIR})
endif ()

#[=============================================================================[
# Options #
]=============================================================================]
Expand Down Expand Up @@ -71,9 +88,6 @@ include(cmake/PackageCompsHelper.cmake)
include(FetchContent)
if (SPGLIB_INSTALL)
include(CMakePackageConfigHelpers)
if (UNIX)
include(GNUInstallDirs)
endif ()
endif ()

# Define basic parameters
Expand All @@ -88,7 +102,6 @@ set(CMAKE_MACOSX_RPATH 1)
# Windows setup
if (WIN32)
# Make sure there is a .lib file to link to
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
# Add appropriate debug flags
set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<$<CONFIG:Debug,RelWithDebInfo>:ProgramDatabase>")
endif ()
Expand All @@ -111,14 +124,19 @@ endif ()
# Main definition #
]=============================================================================]

# Hide things by default
set(CMAKE_C_VISIBILITY_PRESET hidden)
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN YES)

# Main project
add_library(Spglib_symspg)
set_target_properties(Spglib_symspg PROPERTIES
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR}
EXPORT_NAME symspg
OUTPUT_NAME symspg)
add_library(Spglib::symspg ALIAS Spglib_symspg)

# Main definitions inside src
add_subdirectory(src)

Expand Down Expand Up @@ -149,6 +167,8 @@ configure_file(cmake/PackageCompsHelper.cmake PackageCompsHelper.cmake COPYONLY)
# Check how bundled cmake searches CMAKE_MODULE_DIR and add accordingly
# (use SKBUILD_PLATLIB_DIR for install root)
if (NOT SKBUILD AND SPGLIB_INSTALL)
include(CPack)

# pkg-config files
configure_file(cmake/spglib.pc.in spglib.pc @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/spglib.pc
Expand All @@ -173,7 +193,7 @@ if (NOT SKBUILD AND SPGLIB_INSTALL)
endif ()

# Make project available for FetchContent
if(NOT PROJECT_IS_TOP_LEVEL)
if (NOT PROJECT_IS_TOP_LEVEL)
# Set variables for FetchContent
# All variables have to be consistent with SpglibConfig.cmake
set(Spglib_Fortran ${SPGLIB_WITH_Fortran})
Expand Down
F438
17 changes: 9 additions & 8 deletions cmake/CMakePresets-CI.json
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,12 @@
"inherits": [
"ci-base"
],
"description": "This preset is only available on Windows",
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Windows"
},
"binaryDir": "cmake-build-ci-windows",
"cacheVariables": {
"CMAKE_C_COMPILER": {
Expand All @@ -181,14 +187,9 @@
"type": "FILEPATH",
"value": "cl"
},
"SPGLIB_WITH_Fortran": {
"type": "BOOL",
"value": false
},
"SPGLIB_SHARED_LIBS": {
"type": "BOOL",
"value": false
}
"SPGLIB_WITH_Fortran": false,
"SPGLIB_WITH_Python": false,
"SPGLIB_SHARED_LIBS": true
}
},
{
Expand Down
35 changes: 35 additions & 0 deletions cmake/CMakePresets-defaults.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,20 @@
{
"name": "default",
"displayName": "Default configuration preset",
"generator": "Ninja",
"binaryDir": "cmake-build-release",
"installDir": "${sourceDir}/stagedir",
"cacheVariables": {
"CMAKE_C_STANDARD": "17",
"CMAKE_C_EXTENSIONS": false,
"CMAKE_C_STANDARD_REQUIRED": true,
"CMAKE_EXPORT_COMPILE_COMMANDS": true,
"CMAKE_UNITY_BUILD": false,
"BUILD_SHARED_LIBS": true,
"CMAKE_PREFIX_PATH": {
"type": "path",
"value": "${sourceDir}/stagedir"
},
"CMAKE_BUILD_TYPE": {
"type": "STRING",
"value": "Release"
Expand All @@ -22,7 +34,13 @@
"name": "default",
"displayName": "Default build preset",
"configurePreset": "default"
},
{
"name": "install",
"configurePreset": "default",
"targets": ["install"]
}

],
"testPresets": [
{
Expand All @@ -31,6 +49,15 @@
"configurePreset": "default"
}
],
"packagePresets": [
{
"name": "default",
"configurePreset": "default",
"generators": [
"TGZ"
]
}
],
"workflowPresets": [
{
"name": "default",
Expand All @@ -44,9 +71,17 @@
"type": "build",
"name": "default"
},
{
"type": "build",
"name": "install"
},
{
"type": "test",
"name": "default"
},
{
"type": "package",
"name": "default"
}
]
}
Expand Down
2 changes: 1 addition & 1 deletion fortran/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.20...3.29)
cmake_minimum_required(VERSION 3.25...3.29)

#[=============================================================================[
# Basic project definition #
Expand Down
10 changes: 6 additions & 4 deletions python/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.20...3.29)
cmake_minimum_required(VERSION 3.25...3.29)

#[=============================================================================[
# Basic project definition #
Expand All @@ -18,9 +18,11 @@ if (NOT DEFINED Spglib_Python_IS_TOP_LEVEL)
endif ()
endif ()

set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS OFF)
if (NOT DEFINED CMAKE_C_STANDARD)
set(CMAKE_C_STANDARD 17)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS OFF)
endif ()

if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
Expand Down
8 changes: 8 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cmake-format>=0.6.13
pre-commit==3.6.1
iniconfig==2.0.0
numpy==1.26.4
packaging==23.2
pluggy==1.4.0
pytest==8.0.1
PyYAML==6.0.1
Loading
0