Skip to content

Commit

Permalink
Merge pull request #5 from nicolasaunai/cmake
Browse files Browse the repository at this point in the history
add cmake config
  • Loading branch information
UCaromel authored Aug 1, 2024
2 parents c8c65b4 + 28f88e8 commit 426cc04
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 0 deletions.
59 changes: 59 additions & 0 deletions CMakeLists.txt
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)




42 changes: 42 additions & 0 deletions pybind.cmake
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)

0 comments on commit 426cc04

Please sign in to comment.