Skip to content

Commit

Permalink
ENH: Address comments on external libraries and Python packages
Browse files Browse the repository at this point in the history
  • Loading branch information
Patol75 committed Aug 22, 2022
1 parent df09291 commit 3c87987
Show file tree
Hide file tree
Showing 6 changed files with 113 additions and 60 deletions.
162 changes: 107 additions & 55 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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=<SOURCE_DIR>
BUILD_COMMAND make
BUILD_IN_SOURCE TRUE
INSTALL_COMMAND make install exec_prefix=<SOURCE_DIR>
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=<SOURCE_DIR>
BUILD_COMMAND make
BUILD_IN_SOURCE TRUE
INSTALL_COMMAND make install exec_prefix=<SOURCE_DIR>
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=<SOURCE_DIR>
BUILD_COMMAND make
BUILD_IN_SOURCE TRUE
INSTALL_COMMAND make install exec_prefix=<SOURCE_DIR>
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 <SOURCE_DIR>/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 <BINARY_DIR>/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 <BINARY_DIR>/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(
Expand Down Expand Up @@ -369,8 +411,8 @@ target_include_directories(fluidity PUBLIC
$<$<BOOL:${EXODUSII_INCLUDE_DIR}>:${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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion docker/Dockerfile.jammy
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion libspud/diamond/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion libspud/dxdiff/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion libspud/python/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion python/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 3c87987

Please sign in to comment.