diff --git a/cmake/Modules/FindGmsh.cmake b/cmake/Modules/FindGmsh.cmake deleted file mode 100644 index 9bf55bf38..000000000 --- a/cmake/Modules/FindGmsh.cmake +++ /dev/null @@ -1,39 +0,0 @@ -# ############################################################################## -# Try to find Gmsh # # Once done this -# will define: # GMSH_FOUND - system has Gmsh # -# GMSH_INC - Gmsh include directory (static or dynamic) # GMSH_LIB - -# Gmsh library # # Usage: # find_package(Gmsh) # # -# Setting these changes the behavior of the search # GMSH_INC - Gmsh -# include directory # GMSH_LIB - Gmsh library path -# (static or dynamic) # -# ############################################################################## - -# Try to set GMSH_LIB and GMSH_INC from environment variables ## -# ############################################################################## - -if(NOT DEFINED GMSH_LIB) - - find_package(Python3 COMPONENTS Interpreter Development) - - if(Python3_FOUND) - message(STATUS "FOUND Python3") - message(STATUS "Python3_LIBRARY_DIRS ${Python3_LIBRARY_DIRS}") - find_library(GMSH_LIB "gmsh" HINTS $ENV{GMSH_LIB} ${Python3_LIBRARY_DIRS} - NO_CACHE) - else() - message(STATUS "NOT FOUND Python3") - find_library(GMSH_LIB "gmsh" HINTS $ENV{GMSH_LIB} NO_CACHE) - endif() -endif() - -# if(NOT DEFINED GMSH_INC) find_path(GMSH_INC "gmsh.h" HINTS $ENV{GMSH_INC} -# NO_CACHE) endif() - -# CMake check and done ## -# ############################################################################## -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args( - Gmsh - "Gmsh could not be found: be sure to set GMSH_LIB and GMSH_INC in your environment variables" - GMSH_LIB) -# GMSH_INC) diff --git a/cmake/addGmsh.cmake b/cmake/addGmsh.cmake index a8e9a6db4..a38b26725 100644 --- a/cmake/addGmsh.cmake +++ b/cmake/addGmsh.cmake @@ -16,16 +16,31 @@ option(USE_GMSH_SDK OFF) if(USE_GMSH_SDK) + + # download the python virtual env + message(STATUS "USING GMSH SDK") + message(STATUS "Making Python Virtual Environment") list(APPEND TARGET_COMPILE_DEF "-DUSE_GMSH_SDK") - find_package(Gmsh REQUIRED) - if(GMSH_FOUND) - message(STATUS "FOUND Gmsh") - message(STATUS "GMSH_LIBRARIES : ${GMSH_LIB}") - target_link_libraries(${PROJECT_NAME} PUBLIC ${GMSH_LIB}) - else() - message(STATUS "NOT FOUND Gmsh") - endif() + + find_package(Python3 REQUIRED COMPONENTS Interpreter) + set(PY_VENV "${CMAKE_INSTALL_PREFIX}/gmsh") + set(PY_BIN_DIR "${PY_VENV}/bin") + set(GMSH_LIBRARIES "${PY_VENV}/lib/libgmsh.so") + + install( + CODE " + MESSAGE(\"Creating PY_VENV from ${Python3_EXECUTABLE} to ${PY_VENV}\") + execute_process(COMMAND_ECHO STDOUT COMMAND ${Python3_EXECUTABLE} -m venv ${PY_VENV} ) + execute_process(COMMAND_ECHO STDOUT COMMAND ${PY_BIN_DIR}/pip install --upgrade gmsh ) +") + + # find_library(GMSH_LIBRARIES NAME gmsh HINTS "${PY_VENV}/lib" REQUIRED) + target_link_libraries(${PROJECT_NAME} INTERFACE ${GMSH_LIBRARIES}) + message(STATUS "GMSH_LIBRARIES : ${GMSH_LIBRARIES}") + else() + message(STATUS "NOT USING GMSH SDK") + endif()