-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: Add support for installing with spack
- Loading branch information
Riccardo Milani
committed
Feb 14, 2024
1 parent
c5ee234
commit 30676c5
Showing
6 changed files
with
281 additions
and
0 deletions.
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
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,13 @@ | ||
diff --git a/config_files/comma.pc.in b/config_files/comma.pc.in | ||
index f0ccb5c..d28433a 100644 | ||
--- a/config_files/comma.pc.in | ||
+++ b/config_files/comma.pc.in | ||
@@ -1,7 +1,7 @@ | ||
prefix="@CMAKE_INSTALL_PREFIX@" | ||
exec_prefix="${prefix}" | ||
libdir="@CMAKE_INSTALL_FULL_LIBDIR@" | ||
-includedir="@CMAKE_INSTALL_FULL_INCLUDEDIR@" | ||
+includedir="@CMAKE_INSTALL_FULL_INCLUDEDIR@/@CMAKE_PROJECT_NAME@" | ||
|
||
Name: @PROJECT_NAME@ | ||
Description: @CMAKE_PROJECT_DESCRIPTION@ |
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,99 @@ | ||
# CoMMA | ||
# | ||
# Copyright © 2024 ONERA | ||
# | ||
# Authors: Nicolas Lantos, Alberto Remigi, and Riccardo Milani | ||
# Contributors: Karim Anemiche | ||
# | ||
# Any copyright is dedicated to the Public Domain. | ||
# https://creativecommons.org/publicdomain/zero/1.0/ | ||
|
||
from spack.package import * | ||
|
||
|
||
class Comma(CMakePackage): | ||
"""CoMMA (COarse Mesh Multigrid Agglomerator).""" | ||
|
||
homepage = "https://github.com/onera/CoMMA" | ||
url = "https://github.com/onera/CoMMA" | ||
git = "https://github.com/onera/CoMMA.git" | ||
|
||
submodules = True | ||
submodules_to_delete = ["perfetto"] | ||
# Not sure if something as what follows is possible | ||
# if not run_tests: | ||
# submodules_delete.append("Catch2") | ||
|
||
maintainers("RiMillo") | ||
|
||
version("develop", branch="main", submodules_delete=submodules_to_delete) | ||
version("1.3.2", tag="v1.3.2", submodules_delete=submodules_to_delete, preferred=True) | ||
version("1.3.1", tag="v1.3.1", submodules_delete=submodules_to_delete) | ||
# Named 1.3, but as we have a 1.3.1 that changes patches, let us do this differently | ||
version("1.3.0", tag="v1.3", submodules_delete=submodules_to_delete) | ||
version("1.2", tag="v1.2", submodules_delete=submodules_to_delete) | ||
version("1.1", tag="v1.1", submodules_delete=submodules_to_delete) | ||
version("1.0", tag="v1.0", submodules_delete=submodules_to_delete) | ||
|
||
# Add install methods | ||
patch("v1.3_install.patch", when="@1.2:1.3.0") # Works for version 1.2 and 1.3 | ||
patch("v1.1_install.patch", when="@1.1") | ||
patch("v1.0_install.patch", when="@1.0") | ||
|
||
# Fix problems with path | ||
patch("fix_pkgconfig_v1.3.1.patch", when="@1.3.1") | ||
|
||
variant("python", when="@1.2:", description="Install python bindings", default=True) | ||
variant("codaflags", when="@1.1:", description="Compile with usual CODA flags", default=False) | ||
variant("doc", when="@1.3.1:", description="Build Doxygen documentation", default=False) | ||
variant( | ||
"pkgconfig", when="@1.3.1:", description="Add pkg-config configuration file", default=True | ||
) | ||
variant( | ||
"int64", | ||
when="@1.3.2:", | ||
default=False, | ||
description="Set size of integer types to 64 b (true) or 32 b (false)", | ||
) | ||
variant( | ||
"real64", | ||
when="@1.3.2:", | ||
default=True, | ||
description="Set size of real types to 64 b (double, true) or 32 b (false)", | ||
) | ||
|
||
depends_on("[email protected]:", type=("build")) | ||
depends_on("doxygen", type=("build",), when="+doc") | ||
|
||
extends("python", when="+python") | ||
depends_on("python", type=("build", "link", "run"), when="+python") | ||
|
||
# older versions always had a Python dependency | ||
extends("python", when="@1.0:1.1") | ||
depends_on("python", type=("build", "link", "run"), when="@1.0:1.1") | ||
|
||
# Require C++17 compilers | ||
conflicts("%gcc@:8.1.9", msg="Compiler supporting C++17 required") | ||
conflicts("%clang@:5.9.9", msg="Compiler supporting C++17 required") | ||
conflicts("%intel@:19.9.9", msg="Compiler supporting C++17 required") | ||
|
||
def cmake_args(self): | ||
args = super(Comma, self).cmake_args() | ||
args += [ | ||
self.define_from_variant("CODAFLAGS", "codaflags"), | ||
self.define_from_variant("BUILD_PYTHON_BINDINGS", "python"), | ||
self.define_from_variant("BUILD_DOC", "doc"), | ||
self.define_from_variant("PKGCONFIG_SUPPORT", "pkgconfig"), | ||
# `make test` added in v1.3.1 | ||
self.define("BUILD_TESTS", self.run_tests and self.spec.satisfies("@1.3.1:")), | ||
] | ||
|
||
if self.spec.satisfies("@1.3.2:"): | ||
bit_int = 64 if "+int64" in self.spec else 32 | ||
args += [ | ||
self.define("INDEX_T", "uint{}_t".format(bit_int)), | ||
self.define("INT_T", "int{}_t".format(bit_int)), | ||
self.define("REAL_T", "double" if "+real64" in self.spec else "float"), | ||
] | ||
|
||
return args |
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,73 @@ | ||
diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
index cc76cf5..70ebc71 100644 | ||
--- a/CMakeLists.txt | ||
+++ b/CMakeLists.txt | ||
@@ -10,7 +10,7 @@ set(CMAKE_BUILD_TYPE Debug) # Debug version | ||
|
||
|
||
set(CMAKE_CXX_STANDARD 17) | ||
-# for linker in MAC read: | ||
+# for linker in MAC read: | ||
# https://github.com/catchorg/Catch2/issues/1204 | ||
|
||
################################### PROJECT ################################# | ||
@@ -48,20 +48,20 @@ set(INTERFACCIA | ||
set(SOURCE_FILES | ||
${SOURCE_DIR}/Tree.cpp | ||
) | ||
-set(PROFILING | ||
+set(PROFILING | ||
perfetto/sdk/perfetto.h | ||
${PROFILING_DIR}/profiling/trace_categories.h | ||
${PROFILING_DIR}/profiling/trace_categories.cpp | ||
${PROFILING_DIR}/header_profile.h | ||
) | ||
|
||
-set(PROFILING_SOURCE | ||
- ${PROFILING_DIR}/input/DualGPy.h | ||
+set(PROFILING_SOURCE | ||
+ ${PROFILING_DIR}/input/DualGPy.h | ||
${PROFILING_DIR}/test_profile.cpp | ||
) | ||
|
||
-set(PROFILING_PERF | ||
- ${PROFILING_DIR}/input/DualGPy.h | ||
+set(PROFILING_PERF | ||
+ ${PROFILING_DIR}/input/DualGPy.h | ||
${PROFILING_DIR}/test_perf.cpp | ||
) | ||
|
||
@@ -96,13 +96,33 @@ SET(TESTS ${IMPLEMENTATION} | ||
|
||
# Generate a test executable | ||
include_directories(Catch2/single_include) | ||
-add_compile_options("--coverage") | ||
+# add_compile_options("--coverage") | ||
add_executable("Comma_test" ${TESTS}) | ||
target_link_libraries(Comma_test gcov) | ||
#target_link_libraries(Comma_test Boost) | ||
#set_source_files_properties( Comma_test PROPERTIES COMPILE_FLAGS "--coverage" ) | ||
######################## Pybind11 bindings #################################### | ||
+find_package(Python COMPONENTS Interpreter Development) | ||
add_subdirectory(pybind11) | ||
pybind11_add_module(CoMMA ${IMPLEMENTATION} ${INTERFACCIA} ${SOURCE_FILES}) | ||
|
||
- | ||
+# installation | ||
+include(GNUInstallDirs) | ||
+install(DIRECTORY ${SOURCE_DIR}/ | ||
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME} | ||
+ FILES_MATCHING PATTERN "*.h" | ||
+ REGEX "deprecated" EXCLUDE | ||
+) | ||
+install(DIRECTORY ${SOURCE_DIR} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) | ||
+install(FILES LICENSE DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}) | ||
+ | ||
+if (BUILD_PYTHON_BINDINGS) | ||
+ set(PYTHON_SUB_DIR "python${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}/site-packages") | ||
+ install(TARGETS CoMMA | ||
+ COMPONENT python | ||
+ RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" | ||
+ LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/${PYTHON_SUB_DIR}" | ||
+ ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}/${PYTHON_SUB_DIR}") | ||
+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,46 @@ | ||
diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
index a2e301f..edab066 100644 | ||
--- a/CMakeLists.txt | ||
+++ b/CMakeLists.txt | ||
@@ -3,7 +3,7 @@ | ||
|
||
############################### CMAKE VERSION and FLAGS ########################## | ||
|
||
-cmake_minimum_required(VERSION 3.14) | ||
+cmake_minimum_required(VERSION 3.15) | ||
|
||
set(CMAKE_BUILD_TYPE Debug) # Debug version | ||
|
||
@@ -97,11 +97,33 @@ SET(TESTS | ||
|
||
# Generate a test executable with covergae report | ||
include_directories(Catch2/single_include) | ||
-add_compile_options("--coverage") | ||
+# add_compile_options("--coverage") | ||
add_executable("Comma_test" ${TESTS}) | ||
target_link_libraries(Comma_test gcov) | ||
#target_link_libraries(Comma_test Boost) | ||
#set_source_files_properties( Comma_test PROPERTIES COMPILE_FLAGS "--coverage" ) | ||
######################## Pybind11 bindings #################################### | ||
+find_package(Python COMPONENTS Interpreter Development) | ||
add_subdirectory(pybind11) | ||
pybind11_add_module(CoMMA ${PYTHONBIND}) | ||
+ | ||
+# installation | ||
+include(GNUInstallDirs) | ||
+install(DIRECTORY ${SOURCE_DIR}/ | ||
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME} | ||
+ FILES_MATCHING PATTERN "*.h" | ||
+ REGEX "deprecated" EXCLUDE | ||
+) | ||
+install(DIRECTORY ${SOURCE_DIR} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) | ||
+install(FILES LICENSE DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}) | ||
+ | ||
+if (BUILD_PYTHON_BINDINGS) | ||
+ set(PYTHON_SUB_DIR "python${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}/site-packages") | ||
+ install(TARGETS CoMMA | ||
+ COMPONENT python | ||
+ RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" | ||
+ LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/${PYTHON_SUB_DIR}" | ||
+ ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}/${PYTHON_SUB_DIR}") | ||
+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,41 @@ | ||
diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
index 72bc024..c747d57 100644 | ||
--- a/CMakeLists.txt | ||
+++ b/CMakeLists.txt | ||
@@ -3,7 +3,7 @@ | ||
|
||
############################### CMAKE VERSION and FLAGS ########################## | ||
|
||
-cmake_minimum_required(VERSION 3.14) | ||
+cmake_minimum_required(VERSION 3.15) | ||
|
||
if(NOT CMAKE_BUILD_TYPE) | ||
message("No build type received, using Debug") | ||
@@ -124,6 +124,29 @@ endif() | ||
######################## Pybind11 bindings #################################### | ||
if ( BUILD_PYTHON_BINDINGS ) | ||
message("Python bindings enabled") | ||
+ # find the Python interpreter (including pybind might lead to other find files being used) | ||
+ find_package(Python COMPONENTS Interpreter Development) | ||
add_subdirectory(pybind11) | ||
pybind11_add_module(${PROJECT_NAME} ${PYTHONBIND}) | ||
endif() | ||
+ | ||
+# installation | ||
+include(GNUInstallDirs) | ||
+install(DIRECTORY ${SOURCE_DIR}/ | ||
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME} | ||
+ FILES_MATCHING PATTERN "*.h" | ||
+ REGEX "deprecated" EXCLUDE | ||
+) | ||
+install(DIRECTORY ${SOURCE_DIR} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) | ||
+install(FILES LICENSE DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}) | ||
+ | ||
+if (BUILD_PYTHON_BINDINGS) | ||
+ set(PYTHON_SUB_DIR "python${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}/site-packages") | ||
+ install(TARGETS ${PROJECT_NAME} | ||
+ COMPONENT python | ||
+ RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" | ||
+ LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/${PYTHON_SUB_DIR}" | ||
+ ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}/${PYTHON_SUB_DIR}") | ||
+endif() |