-
Notifications
You must be signed in to change notification settings - Fork 64
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
Project modernization #33
Open
LecrisUT
wants to merge
17
commits into
KarypisLab:master
Choose a base branch
from
LecrisUT:cmake/modernization
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
53b1dac
METIS/CMakeLists.txt require
shengjianda cb4fe3b
GKLib can build as git submodule without the conflict of options.
shengjianda 59963ed
change GKLIB_BUILD_TEST default ON
shengjianda d456681
add GKLIB_NAME which can help metis find the lib is used as git submo…
shengjianda 2b9ae50
Add basic section structure
LecrisUT 2afc71a
Bump cmake_minimum_required to something useful
LecrisUT 30a787e
Rearrange options and implement some defaults
LecrisUT 582cf59
Add C standard specification
LecrisUT cbd7597
CMake project modernization
LecrisUT 56405dc
Add basic GitHub actions
LecrisUT 9d528ad
Add basic CMakePresets
LecrisUT c8ead82
Refactor test-suite
LecrisUT dfdf1aa
Use C standard `thread_local`
LecrisUT 56e93c9
Use standard OpenMP macros
LecrisUT 1ba74b3
Add GitHub action for OpenMP
LecrisUT 592384c
[Temp] Mark some environments as experimental
LecrisUT 1b3441c
Remove outdated files and references
LecrisUT File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: CI | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
branches: [ master ] | ||
push: | ||
branches: [ master ] | ||
|
||
permissions: | ||
contents: read | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
tests: | ||
uses: ./.github/workflows/step_test.yaml | ||
|
||
pass: | ||
needs: [ tests ] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check all CI jobs | ||
uses: re-actors/alls-green@release/v1 | ||
with: | ||
jobs: ${{ toJSON(needs) }} | ||
if: always() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
name: test | ||
run-name: Run tests | ||
|
||
on: | ||
workflow_call: | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
tests: | ||
name: Check ${{ matrix.toolchain }} | ||
runs-on: ${{ matrix.os || 'ubuntu-latest' }} | ||
container: ${{ !matrix.os && 'ghcr.io/lecrisut/dev-env:main' || '' }} | ||
continue-on-error: ${{ matrix.experimental || false }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
toolchain: [ gcc, llvm, intel, windows, macos ] | ||
openmp: [ ON, OFF ] | ||
include: | ||
- os: windows-latest | ||
toolchain: windows | ||
# Need to find how to install on windows | ||
experimental: true | ||
- os: macos-latest | ||
toolchain: macos | ||
- os: macos-latest | ||
toolchain: macos | ||
openmp: ON | ||
# Need to find how to install openmp on macos | ||
experimental: true | ||
env: | ||
WITH_OPENMP: ${{ matrix.openmp }} | ||
steps: | ||
- name: Enable msvc toolchain on windows | ||
uses: ilammy/msvc-dev-cmd@v1 | ||
if: contains(matrix.os, 'windows') | ||
- name: Activate Intel compilers | ||
# Not elegant, it will propagate all environment variable. | ||
# Intel does not provide a way to output the environment variables to a file | ||
# Note: PATH needs to be exported to GITHUB_PATH otherwise it can be overwritten | ||
run: | | ||
source /opt/intel/oneapi/setvars.sh | ||
printenv >> $GITHUB_ENV | ||
echo $PATH >> $GITHUB_PATH | ||
if: matrix.toolchain == 'intel' | ||
- uses: actions/checkout@v4 | ||
- uses: lukka/get-cmake@latest | ||
- name: Run CMake configuration for ${{ matrix.toolchain }} toolchain | ||
uses: lukka/[email protected] | ||
with: | ||
workflowPreset: "${{ matrix.toolchain }}-ci" | ||
pass: | ||
needs: [ tests ] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check test jobs | ||
uses: re-actors/alls-green@release/v1 | ||
with: | ||
jobs: ${{ toJSON(needs) }} | ||
if: always() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,3 +55,7 @@ dkms.conf | |
build/ | ||
lib/ | ||
.svn/ | ||
|
||
### Project specific | ||
CMakeUserPresets.json | ||
cmake-build-* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,209 @@ | ||
cmake_minimum_required(VERSION 2.8) | ||
project(GKlib C) | ||
cmake_minimum_required(VERSION 3.15) | ||
# CMake version compatibility | ||
# TODO: Remove when cmake 3.25 is commonly distributed | ||
if (POLICY CMP0140) | ||
cmake_policy(SET CMP0140 NEW) | ||
endif () | ||
|
||
option(BUILD_SHARED_LIBS "Build shared libraries (.dll/.so) instead of static ones (.lib/.a)" OFF) | ||
#[==============================================================================================[ | ||
# Basic project definition # | ||
]==============================================================================================] | ||
|
||
get_filename_component(abs "." ABSOLUTE) | ||
set(GKLIB_PATH ${abs}) | ||
unset(abs) | ||
include(GKlibSystem.cmake) | ||
list(APPEND CMAKE_MESSAGE_CONTEXT GKlib) | ||
project(GKlib | ||
VERSION 5.3.0 | ||
DESCRIPTION "A library of various helper routines and frameworks used by many of the KarypisLab's software" | ||
HOMEPAGE_URL https://github.com/KarypisLab/GKlib | ||
LANGUAGES C | ||
) | ||
|
||
include_directories(".") | ||
if(MSVC) | ||
include_directories("win32") | ||
file(GLOB win32_sources RELATIVE "win32" "*.c") | ||
else(MSVC) | ||
set(win32_sources, "") | ||
endif(MSVC) | ||
# 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) | ||
else () | ||
set(PROJECT_IS_TOP_LEVEL OFF) | ||
endif () | ||
endif () | ||
|
||
add_library(GKlib ${GKlib_sources} ${win32_sources}) | ||
# Specify C standard | ||
set(CMAKE_C_STANDARD 11) | ||
set(CMAKE_C_STANDARD_REQUIRED ON) | ||
set(CMAKE_C_EXTENSIONS ON) | ||
|
||
if(UNIX) | ||
target_link_libraries(GKlib m) | ||
endif(UNIX) | ||
if (NOT CMAKE_BUILD_TYPE) | ||
set(CMAKE_BUILD_TYPE Release) | ||
endif () | ||
|
||
include_directories("test") | ||
add_subdirectory("test") | ||
#[==============================================================================================[ | ||
# Options # | ||
]==============================================================================================] | ||
|
||
install(TARGETS GKlib | ||
ARCHIVE DESTINATION lib/${LINSTALL_PATH} | ||
LIBRARY DESTINATION lib/${LINSTALL_PATH}) | ||
install(FILES ${GKlib_includes} DESTINATION include/${HINSTALL_PATH}) | ||
include(CMakeDependentOption) | ||
include(FeatureSummary) | ||
option(GKLIB_TESTS "GKlib: Build unit tests" ${PROJECT_IS_TOP_LEVEL}) | ||
option(GKLIB_SHARED_LIBS "GKlib: Build as a shared library" ${PROJECT_IS_TOP_LEVEL}) | ||
option(GKLIB_INSTALL "GKlib: Install project" ${PROJECT_IS_TOP_LEVEL}) | ||
|
||
# TODO: Discuss these options. Non-standard and easily conflicting | ||
option(GKLIB_ASSERT "GKlib: Turn asserts on" OFF) | ||
option(GKLIB_ASSERT2 "GKlib: Additional assertions" OFF) | ||
option(GKLIB_NO_X86 "GKlib: Enable NO_X86 support" ON) | ||
option(GKLIB_GPROF "GKlib: Add gprof support" OFF) | ||
|
||
option(GKLIB_OpenMP "GKlib: Enable OpenMP support" OFF) | ||
add_feature_info(GKLIB_OpenMP GKLIB_OpenMP "OpenMP support") | ||
option(GKLIB_PCRE "GKlib: Enable PCRE support" OFF) | ||
add_feature_info(GKLIB_PCRE GKLIB_PCRE "PCRE support") | ||
cmake_dependent_option(GKLIB_GKREGEX "GKlib: Enable GKREGEX support" OFF "NOT GKLIB_PCRE" OFF) | ||
add_feature_info(GKLIB_GKREGEX GKLIB_GKREGEX "GKREGEX support") | ||
option(GKLIB_GKRAND "GKlib: Enable GKRAND support" OFF) | ||
add_feature_info(GKLIB_GKRAND GKLIB_GKRAND "GKRAND support") | ||
|
||
#[==============================================================================================[ | ||
# Project configuration # | ||
]==============================================================================================] | ||
|
||
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) | ||
|
||
# Include basic tools | ||
include(FetchContent) | ||
if (GKLIB_INSTALL) | ||
include(CMakePackageConfigHelpers) | ||
if (UNIX) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be unconditional, it's not an issue for this on Windows. And also, you use e.g. |
||
include(GNUInstallDirs) | ||
endif () | ||
endif () | ||
|
||
# Define basic parameters | ||
set(BUILD_SHARED_LIBS ${GKLIB_SHARED_LIBS}) | ||
|
||
#[==============================================================================================[ | ||
# External packages # | ||
]==============================================================================================] | ||
|
||
if (GKLIB_OpenMP) | ||
# Normally these packages are pulled outside of if statements to allow to be added optionally. | ||
# Making an exception for basic packages like OpenMP, MPI, etc. that drastically change a | ||
# library's implementation and expected behaviour | ||
find_package(OpenMP COMPONENTS C) | ||
set_package_properties(OpenMP PROPERTIES TYPE REQUIRED) | ||
endif () | ||
if (GKLIB_PCRE) | ||
# TODO: This option should be obsolete and moved to optional find_package control | ||
# TODO: Move to PCRE2, since PCRE1 is dead | ||
# find_package(pcre2 COMPONENTS POSIX) | ||
# set_package_properties(pcre2 PROPERTIES TYPE REQUIRED) | ||
endif () | ||
include(GKlib_PackagesInfo) | ||
|
||
feature_summary( | ||
FILENAME ${CMAKE_CURRENT_BINARY_DIR}/GKlib.info | ||
VAR GKlib_Info | ||
DESCRIPTION "GKlib supported libraries" | ||
FATAL_ON_MISSING_REQUIRED_PACKAGES | ||
WHAT ALL | ||
) | ||
message(STATUS ${GKlib_Info}) | ||
|
||
#[==============================================================================================[ | ||
# Main definition # | ||
]==============================================================================================] | ||
|
||
# Main project | ||
add_library(GKlib_GKlib) | ||
set_target_properties(GKlib_GKlib PROPERTIES | ||
VERSION ${PROJECT_VERSION} | ||
SOVERSION ${PROJECT_VERSION_MAJOR} | ||
EXPORT_NAME GKlib | ||
OUTPUT_NAME gk | ||
) | ||
add_library(GKlib::GKlib ALIAS GKlib_GKlib) | ||
add_subdirectory(include) | ||
add_subdirectory(src) | ||
|
||
|
||
if (GKLIB_TESTS) | ||
enable_testing() | ||
add_subdirectory(test) | ||
endif () | ||
|
||
#[==============================================================================================[ | ||
# Install or Export # | ||
]==============================================================================================] | ||
|
||
# Installation | ||
if (GKLIB_INSTALL) | ||
# pkg-config files | ||
# TODO: Figure how to make this work | ||
# file(GENERATE OUTPUT gklib.pc | ||
# INPUT cmake/gklib.pc.in | ||
# ) | ||
# install(FILES ${CMAKE_CURRENT_BINARY_DIR}/gklib.pc | ||
# DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig | ||
# COMPONENT GKlib_Development | ||
# ) | ||
|
||
# cmake export files | ||
write_basic_package_version_file( | ||
${CMAKE_CURRENT_BINARY_DIR}/GKlibConfigVersion.cmake | ||
VERSION ${PROJECT_VERSION} | ||
COMPATIBILITY SameMajorVersion | ||
) | ||
configure_package_config_file( | ||
cmake/GKlibConfig.cmake.in | ||
${CMAKE_CURRENT_BINARY_DIR}/GKlibConfig.cmake | ||
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/GKlib | ||
) | ||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/GKlibConfigVersion.cmake | ||
${CMAKE_CURRENT_BINARY_DIR}/GKlibConfig.cmake | ||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/GKlib | ||
COMPONENT GKlib_Development | ||
) | ||
export(EXPORT GKlibTargets | ||
FILE GKlibTargets.cmake | ||
NAMESPACE GKlib:: | ||
) | ||
install(EXPORT GKlibTargets | ||
FILE GKlibTargets.cmake | ||
NAMESPACE GKlib:: | ||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/GKlib | ||
COMPONENT GKlib_Development | ||
) | ||
endif () | ||
|
||
# Make project available for FetchContent | ||
if (NOT PROJECT_IS_TOP_LEVEL) | ||
# Set variables for FetchContent | ||
# All variables have to be consistent with GKlibConfig.cmake | ||
set(GKlib_OpenMP GKLIB_OpenMP) | ||
set(GKlib_PCRE GKLIB_PCRE) | ||
set(GKlib_GKREGEX GKLIB_GKREGEX) | ||
set(GKlib_GKRAND GKLIB_GKRAND) | ||
# Propagate variables | ||
if (CMAKE_VERSION VERSION_LESS 3.25) | ||
# TODO: Remove when cmake 3.25 is commonly distributed | ||
set(GKlib_VERSION ${GKlib_VERSION} PARENT_SCOPE) | ||
set(GKlib_VERSION_MAJOR ${GKlib_VERSION_MAJOR} PARENT_SCOPE) | ||
set(GKlib_VERSION_MINOR ${GKlib_VERSION_MINOR} PARENT_SCOPE) | ||
set(GKlib_VERSION_PATCH ${GKlib_VERSION_PATCH} PARENT_SCOPE) | ||
set(GKlib_VERSION_TWEAK ${GKlib_VERSION_TWEAK} PARENT_SCOPE) | ||
set(GKlib_OpenMP ${GKlib_OpenMP} PARENT_SCOPE) | ||
set(GKlib_PCRE ${GKlib_PCRE} PARENT_SCOPE) | ||
set(GKlib_GKREGEX ${GKlib_GKREGEX} PARENT_SCOPE) | ||
set(GKlib_GKRAND ${GKlib_GKRAND} PARENT_SCOPE) | ||
else () | ||
return(PROPAGATE | ||
GKlib_VERSION | ||
GKlib_VERSION_MAJOR | ||
GKlib_VERSION_MINOR | ||
GKlib_VERSION_PATCH | ||
GKlib_VERSION_TWEAK | ||
GKlib_OpenMP | ||
GKlib_PCRE | ||
GKlib_GKREGEX | ||
GKlib_GKRAND | ||
) | ||
endif () | ||
endif () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"version": 6, | ||
"cmakeMinimumRequired": { | ||
"major": 3, | ||
"minor": 25, | ||
"patch": 0 | ||
}, | ||
"include": [ | ||
"cmake/CMakePresets-defaults.json", | ||
"cmake/CMakePresets-CI.json" | ||
] | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Logic error here, it should be