-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from nicolasaunai/cmake
add cmake config
- Loading branch information
Showing
2 changed files
with
101 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
cmake_minimum_required (VERSION 3.20.1) # released April 8, 2021 - https://www.kitware.com/cmake-3-20-1-available-for-download/ | ||
|
||
project(PHAREMHD VERSION 0.1 LANGUAGES CXX C) | ||
|
||
# Release mode default | ||
if(NOT CMAKE_BUILD_TYPE) | ||
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE) | ||
endif() | ||
|
||
|
||
SET(PYBIND_MIN_VERSION "2.5.0") | ||
find_package(Python 3.8 COMPONENTS Interpreter Development.Module REQUIRED) | ||
find_program(Git git) | ||
include(pybind.cmake) | ||
|
||
set(PHAREMHD_PROJECT_DIR ${CMAKE_CURRENT_SOURCE_DIR}) | ||
set(CMAKE_EXPORT_COMPILE_COMMANDS 1) | ||
|
||
|
||
set(CMAKE_CXX_STANDARD 17) | ||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
|
||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src) | ||
|
||
set(SOURCES | ||
src/ConservativeVariables.cpp | ||
src/ConstrainedTransport.cpp | ||
src/EquationOfState.cpp | ||
src/GodunovFlux.cpp | ||
src/Interface.cpp | ||
src/ModularityUtils.cpp | ||
src/PhareMHD.cpp | ||
src/PhysicalConstants.cpp | ||
src/PrimitiveVariables.cpp | ||
src/RiemannSolver.cpp | ||
src/TimeIntegrator.cpp) | ||
|
||
set(INCLUDES | ||
src/ConservativeVariables.hpp | ||
src/ConstrainedTransport.hpp | ||
src/EquationOfState.hpp | ||
src/GodunovFlux.hpp | ||
src/Interface.hpp | ||
src/ModularityUtils.hpp | ||
src/PhareMHD.hpp | ||
src/PhysicalConstants.hpp | ||
src/PrimitiveVariables.hpp | ||
src/RiemannSolver.hpp | ||
src/TimeIntegrator.hpp) | ||
|
||
add_library(phareMHD SHARED ${SOURCES} ${INCLUDES}) | ||
|
||
|
||
pybind11_add_module(pyMHD pyMHD/pyMHD.cpp) | ||
target_link_libraries(pyMHD PUBLIC phareMHD) | ||
|
||
|
||
|
||
|
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,42 @@ | ||
|
||
SET(PYBIND_MIN_VERSION "2.5.0") | ||
|
||
function(get_pybind) | ||
|
||
# Pybind errors with clang, it is default in GCC | ||
# https://github.com/pybind/pybind11/issues/1604 | ||
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") | ||
set (PHARE_FLAGS ${PHARE_FLAGS} -fsized-deallocation) | ||
endif() | ||
|
||
message("downloading subproject pybind11") | ||
set(PYBIND11_SRCDIR ${CMAKE_CURRENT_SOURCE_DIR}/subprojects/pybind11) | ||
|
||
if (NOT EXISTS ${PYBIND11_SRCDIR}) | ||
message("cloning your mother ${PYBIND11_SRCDIR}") | ||
execute_process( | ||
COMMAND ${Git} clone https://github.com/pybind/pybind11 ${PYBIND11_SRCDIR} --depth 1 -b master | ||
) | ||
else() | ||
if(devMode) | ||
message("downloading latest pybind11 updates") | ||
execute_process(COMMAND ${Git} pull origin master WORKING_DIRECTORY ${PYBIND11_SRCDIR}) | ||
endif(devMode) | ||
endif() | ||
|
||
message("now adding subdir") | ||
add_subdirectory(${PYBIND11_SRCDIR}) | ||
|
||
endfunction(get_pybind) | ||
|
||
if (forceGetPybind) | ||
get_pybind() | ||
else() | ||
|
||
find_package(pybind11 ${PYBIND_MIN_VERSION} CONFIG QUIET) | ||
|
||
if (NOT pybind11_FOUND) | ||
get_pybind() | ||
endif() | ||
|
||
endif(forceGetPybind) |