diff --git a/CMakeLists.txt b/CMakeLists.txt index 6412a8c9af..a6f68ee5c3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -119,74 +119,116 @@ if(EXODUSII_LIBRARY) endif() # Add libspatialindex -FetchContent_Declare(libspatialindex - GIT_REPOSITORY https://github.com/libspatialindex/libspatialindex - GIT_TAG origin/master - LOG_DOWNLOAD ON - LOG_CONFIGURE ON - LOG_BUILD ON - LOG_INSTALL ON -) +if(DEFINED USE_BUNDLED_LIBSPATIALINDEX) + FetchContent_Declare(libspatialindex + SOURCE_DIR ${CMAKE_SOURCE_DIR}/spatialindex-1.8.0 + LOG_CONFIGURE ON + LOG_BUILD ON + LOG_INSTALL ON + ) +else() + FetchContent_Declare(libspatialindex + GIT_REPOSITORY https://github.com/libspatialindex/libspatialindex + GIT_TAG origin/master + LOG_DOWNLOAD ON + LOG_CONFIGURE ON + LOG_BUILD ON + LOG_INSTALL ON + ) +endif() FetchContent_MakeAvailable(libspatialindex) # Add Judy -ExternalProject_Add(libjudy - PREFIX libjudy - URL https://sourceforge.net/projects/judy/files/judy/Judy-1.0.5/Judy-1.0.5.tar.gz/download - CONFIGURE_COMMAND ./configure --enable-64-bit --prefix= - BUILD_COMMAND make - BUILD_IN_SOURCE TRUE - INSTALL_COMMAND make install exec_prefix= - TEST_COMMAND make check - TEST_BEFORE_INSTALL TRUE - LOG_DOWNLOAD ON - LOG_CONFIGURE ON - LOG_BUILD ON - LOG_INSTALL ON - LOG_TEST ON -) +if(DEFINED USE_BUNDLED_LIBJUDY) + ExternalProject_Add(libjudy + SOURCE_DIR ${CMAKE_SOURCE_DIR}/libjudy + CONFIGURE_COMMAND ./configure --enable-64-bit --prefix= + BUILD_COMMAND make + BUILD_IN_SOURCE TRUE + INSTALL_COMMAND make install exec_prefix= + TEST_COMMAND make check + TEST_BEFORE_INSTALL TRUE + LOG_CONFIGURE ON + LOG_BUILD ON + LOG_INSTALL ON + LOG_TEST ON + ) +else() + ExternalProject_Add(libjudy + PREFIX libjudy + URL https://sourceforge.net/projects/judy/files/judy/Judy-1.0.5/Judy-1.0.5.tar.gz/download + CONFIGURE_COMMAND ./configure --enable-64-bit --prefix= + BUILD_COMMAND make + BUILD_IN_SOURCE TRUE + INSTALL_COMMAND make install exec_prefix= + TEST_COMMAND make check + TEST_BEFORE_INSTALL TRUE + LOG_DOWNLOAD ON + LOG_CONFIGURE ON + LOG_BUILD ON + LOG_INSTALL ON + LOG_TEST ON + ) +endif() ExternalProject_Add_Step(libjudy byproducts DEPENDEES install BYPRODUCTS /lib/libJudy.a LOG ON ) ExternalProject_Get_property(libjudy SOURCE_DIR) -set(libjudy_SOURCE_DIR ${SOURCE_DIR}) + add_library(Judy STATIC IMPORTED) set_target_properties(Judy - PROPERTIES IMPORTED_LOCATION ${libjudy_SOURCE_DIR}/lib/libJudy.a + PROPERTIES IMPORTED_LOCATION ${SOURCE_DIR}/lib/libJudy.a ) +set(LIBJUDY_INCLUDE_DIR ${SOURCE_DIR}/src) + # Add Zoltan -set(ZOLTAN_CONFIGURE "../libzoltan/configure --enable-f90interface --with-gnumake --with-scotch --with-parmetis") -if(${CMAKE_C_COMPILER_VERSION} GREATER_EQUAL 10) - string(APPEND ZOLTAN_CONFIGURE " FCFLAGS=-fallow-argument-mismatch") -endif() -if(DEFINED ENV{PETSC_ARCH}) - string(APPEND ZOLTAN_CONFIGURE " --with-scotch-incdir=$ENV{PETSC_DIR}/$ENV{PETSC_ARCH}/include --with-scotch-libdir=$ENV{PETSC_DIR}/$ENV{PETSC_ARCH}/lib --with-parmetis-incdir=$ENV{PETSC_DIR}/$ENV{PETSC_ARCH}/include --with-parmetis-libdir=$ENV{PETSC_DIR}/$ENV{PETSC_ARCH}/lib") - else() - string(APPEND ZOLTAN_CONFIGURE " --with-scotch-incdir=$ENV{PETSC_DIR}/include --with-scotch-libdir=$ENV{PETSC_DIR}/lib --with-parmetis-incdir=$ENV{PETSC_DIR}/include --with-parmetis-libdir=$ENV{PETSC_DIR}/lib") +if(DEFINED USE_EXISTING_ZOLTAN) + find_library(ZOLTAN_LIBRARY zoltan HINTS ${USE_EXISTING_ZOLTAN} REQUIRED) + find_path(ZOLTAN_INCLUDE_DIR zoltan.h HINTS ${USE_EXISTING_ZOLTAN} REQUIRED) + + add_library(Zoltan STATIC IMPORTED) + set_target_properties(Zoltan PROPERTIES IMPORTED_LOCATION ${ZOLTAN_LIBRARY}) + +else() + set(ZOLTAN_CONFIGURE "../libzoltan/configure --enable-f90interface --with-gnumake --with-scotch --with-parmetis") + + if(${CMAKE_C_COMPILER_VERSION} GREATER_EQUAL 10) + string(APPEND ZOLTAN_CONFIGURE " FCFLAGS=-fallow-argument-mismatch") + endif() + + if(DEFINED ENV{PETSC_ARCH}) + string(APPEND ZOLTAN_CONFIGURE " --with-scotch-incdir=$ENV{PETSC_DIR}/$ENV{PETSC_ARCH}/include --with-scotch-libdir=$ENV{PETSC_DIR}/$ENV{PETSC_ARCH}/lib --with-parmetis-incdir=$ENV{PETSC_DIR}/$ENV{PETSC_ARCH}/include --with-parmetis-libdir=$ENV{PETSC_DIR}/$ENV{PETSC_ARCH}/lib") + else() + string(APPEND ZOLTAN_CONFIGURE " --with-scotch-incdir=$ENV{PETSC_DIR}/include --with-scotch-libdir=$ENV{PETSC_DIR}/lib --with-parmetis-incdir=$ENV{PETSC_DIR}/include --with-parmetis-libdir=$ENV{PETSC_DIR}/lib") + endif() + + separate_arguments(ZOLTAN_CONFIGURE UNIX_COMMAND ${ZOLTAN_CONFIGURE}) + + ExternalProject_Add(libzoltan + PREFIX Zoltan + GIT_REPOSITORY https://github.com/sandialabs/Zoltan + GIT_TAG origin/main + CONFIGURE_COMMAND ${ZOLTAN_CONFIGURE} + BUILD_COMMAND make everything + BUILD_BYPRODUCTS /src/libzoltan.a + INSTALL_COMMAND "" + LOG_DOWNLOAD ON + LOG_CONFIGURE ON + LOG_BUILD ON + ) + ExternalProject_Get_property(libzoltan BINARY_DIR) + + add_library(Zoltan STATIC IMPORTED) + add_dependencies(Zoltan libzoltan) + set_target_properties(Zoltan + PROPERTIES IMPORTED_LOCATION ${BINARY_DIR}/src/libzoltan.a + ) + + set(ZOLTAN_INCLUDE_DIR ${BINARY_DIR}/src) endif() -separate_arguments(ZOLTAN_CONFIGURE UNIX_COMMAND ${ZOLTAN_CONFIGURE}) -ExternalProject_Add(libzoltan - PREFIX Zoltan - GIT_REPOSITORY https://github.com/sandialabs/Zoltan - GIT_TAG origin/main - CONFIGURE_COMMAND ${ZOLTAN_CONFIGURE} - BUILD_COMMAND make everything - BUILD_BYPRODUCTS /src/libzoltan.a - INSTALL_COMMAND "" - LOG_DOWNLOAD ON - LOG_CONFIGURE ON - LOG_BUILD ON -) -ExternalProject_Get_property(libzoltan BINARY_DIR) -set(Zoltan_BINARY_DIR ${BINARY_DIR}) -add_library(Zoltan STATIC IMPORTED) -add_dependencies(Zoltan libzoltan) -set_target_properties(Zoltan - PROPERTIES IMPORTED_LOCATION ${Zoltan_BINARY_DIR}/src/libzoltan.a -) # Generate some source files add_custom_command( @@ -369,8 +411,8 @@ target_include_directories(fluidity PUBLIC $<$:${EXODUSII_INCLUDE_DIR}> ${libspatialindex_SOURCE_DIR}/include - ${libjudy_SOURCE_DIR}/src - ${Zoltan_BINARY_DIR}/src + ${LIBJUDY_INCLUDE_DIR} + ${ZOLTAN_INCLUDE_DIR} ${CMAKE_BINARY_DIR}/include ${CMAKE_SOURCE_DIR}/include @@ -430,6 +472,16 @@ add_executable(fluidity_binary main.cpp) set_target_properties(fluidity_binary PROPERTIES OUTPUT_NAME fluidity) target_link_libraries(fluidity_binary fluidity) +# Install Python packages included in Fluidity's repository +add_custom_target(install_python_packages) +add_dependencies(install_python_packages fluidity_python spud_diamond spud_dxdiff spud_python) + +# Uninstall Python packages included in Fluidity's repository +add_custom_target(uninstall_python_packages + COMMAND ${Python3_EXECUTABLE} -m pip uninstall -y diamond dxdiff fluidity libspud + VERBATIM +) + # Build the fluidity manual add_custom_target(manual COMMAND make diff --git a/docker/Dockerfile.jammy b/docker/Dockerfile.jammy index 0152394b71..cfbef1bab6 100644 --- a/docker/Dockerfile.jammy +++ b/docker/Dockerfile.jammy @@ -41,7 +41,7 @@ RUN apt-get update && apt-get install -y \ texlive-latex-extra \ texlive-pstricks \ texlive-science \ - && rm -rf /var/lib/apt/lists/* + && rm -rf /var/lib/apt/lists/* WORKDIR /usr/local @@ -85,6 +85,7 @@ WORKDIR /home/Softwares/fluidity/build RUN cmake -G Ninja -D GITHUB_ACTIONS=1 .. RUN ninja +RUN ninja install_python_packages RUN ninja manual RUN python3 -m pip install --user assess diff --git a/libspud/diamond/CMakeLists.txt b/libspud/diamond/CMakeLists.txt index e1cf5f9793..36cea53fad 100644 --- a/libspud/diamond/CMakeLists.txt +++ b/libspud/diamond/CMakeLists.txt @@ -1,6 +1,6 @@ add_subdirectory(diamond) -add_custom_target(spud_diamond ALL +add_custom_target(spud_diamond COMMAND ${Python3_EXECUTABLE} -m pip install --force-reinstall . WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} VERBATIM diff --git a/libspud/dxdiff/CMakeLists.txt b/libspud/dxdiff/CMakeLists.txt index 9cf127d2b5..b1f232e1c9 100644 --- a/libspud/dxdiff/CMakeLists.txt +++ b/libspud/dxdiff/CMakeLists.txt @@ -1,4 +1,4 @@ -add_custom_target(spud_dxdiff ALL +add_custom_target(spud_dxdiff COMMAND ${Python3_EXECUTABLE} -m pip install --user --force-reinstall . WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} VERBATIM diff --git a/libspud/python/CMakeLists.txt b/libspud/python/CMakeLists.txt index 61fe8ecb8c..9ca9cbb06c 100644 --- a/libspud/python/CMakeLists.txt +++ b/libspud/python/CMakeLists.txt @@ -1,6 +1,6 @@ configure_file(setup.py.in ${CMAKE_CURRENT_SOURCE_DIR}/setup.py) -add_custom_target(spud_python ALL +add_custom_target(spud_python COMMAND ${Python3_EXECUTABLE} -m pip install --user --force-reinstall . WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} VERBATIM diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 9db5ebbdf6..2469977bb9 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -1,4 +1,4 @@ -add_custom_target(fluidity_python ALL +add_custom_target(fluidity_python COMMAND ${Python3_EXECUTABLE} -m pip install --force-reinstall . WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} VERBATIM