Skip to content

Commit

Permalink
Elements should now work as a cmake library
Browse files Browse the repository at this point in the history
  • Loading branch information
djdunning committed Nov 15, 2023
1 parent 94fe880 commit e11177b
Show file tree
Hide file tree
Showing 11 changed files with 55 additions and 48 deletions.
22 changes: 6 additions & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,6 @@ add_subdirectory(slam)
add_subdirectory(swage)
add_subdirectory(io)

# Tests
if (BUILD_TESTS)
add_subdirectory(tests)
endif()

# Examples
if (BUILD_EXAMPLES)
add_subdirectory(examples)
endif()

# Documentation
if (WITH_DOCS)
add_subdirectory(docs)
Expand All @@ -96,12 +86,12 @@ add_subdirectory(mesh_tools)
# subdirectories looking for anything that matches the pattern "*.h" is
# indiscriminate, and the resulting include/ directory isn't affected by
# distclean. If there's a better way to do this, please introduce it here.)
add_library(Elements SHARED src/elements_lib_dummy.cpp)
add_library(Elements INTERFACE)

file(GLOB_RECURSE ALL_HEADERS elements/*.h geometry/*.h slam/*.h swage/*.h common/*.h swage2vtk/*.h)
install(FILES ${ALL_HEADERS} DESTINATION include)

target_include_directories(Elements PUBLIC
target_include_directories(Elements INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
Expand Down Expand Up @@ -137,16 +127,16 @@ set_target_properties(Elements
install(EXPORT ElementsTargets DESTINATION lib/cmake/Elements)
install(FILES "${PROJECT_BINARY_DIR}/ElementsConfigVersion.cmake"
"${PROJECT_BINARY_DIR}/ElementsConfig.cmake"
DESTINATION lib/cmake/elements)
DESTINATION lib/cmake/Elements)

# Install libraries in lib/ subdirectory of the specified install directory
if (WITH_VTK AND VTK_FOUND)
install(TARGETS swage2vtk EXPORT ElementsTargets DESTINATION lib)
endif()

target_link_libraries(Elements elements geometry slam swage common)
target_link_libraries(Elements INTERFACE elements geometry slam swage common)
if (WITH_VTK AND VTK_FOUND)
target_link_libraries(Elements PUBLIC swage2vtk)
target_link_libraries(Elements INTERFACE swage2vtk)
endif()
target_link_libraries(Elements matar)
target_link_libraries(Elements INTERFACE matar)

5 changes: 5 additions & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
project(Examples)

# CMake version > 3.8 required for C++17 standard
cmake_minimum_required(VERSION 3.8)

find_package(Elements)
if(Matar_ENABLE_KOKKOS)
find_package(Kokkos)
Expand Down
9 changes: 5 additions & 4 deletions examples/average/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ set(Average_SRC_CXX average.cpp)

add_executable(Average ${Average_SRC_CXX})

target_link_libraries (Average swage)
target_link_libraries (Average elements)
target_link_libraries (Average geometry)
target_link_libraries (Average input)
#target_link_libraries (Average swage)
#target_link_libraries (Average elements)
#target_link_libraries (Average geometry)
#target_link_libraries (Average input)
target_link_libraries (Average Elements input)
2 changes: 1 addition & 1 deletion matar
3 changes: 0 additions & 3 deletions scripts/build-elements.sh
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,10 @@ source setup-env.sh ${machine} ${kokkos_build_type} ${build_cores}
# Next, do action based on args
if [ "$build_action" = "full-app" ]; then
source kokkos-install.sh ${kokkos_build_type}
source matar-install.sh ${kokkos_build_type}
source elements-install.sh ${kokkos_build_type}
source cmake_build_${execution}.sh ${kokkos_build_type}
elif [ "$build_action" = "install-kokkos" ]; then
source kokkos-install.sh ${kokkos_build_type}
elif [ "$build_action" = "install-matar" ]; then
source matar-install.sh ${kokkos_build_type}
elif [ "$build_action" = "install-elements" ]; then
source elements-install.sh ${kokkos_build_type}
elif [ "$build_action" = "elements" ]; then
Expand Down
1 change: 0 additions & 1 deletion scripts/cmake_build_examples.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ fi

cmake_options=(
-D CMAKE_PREFIX_PATH="${ELEMENTS_INSTALL_DIR};${KOKKOS_INSTALL_DIR}"
-D BUILD_EXAMPLES=ON
)

if [ "$kokkos_build_type" = "none" ]; then
Expand Down
6 changes: 3 additions & 3 deletions scripts/cmake_build_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ then
fi

cmake_options=(
-D CMAKE_PREFIX_PATH="${MATAR_INSTALL_DIR};${KOKKOS_INSTALL_DIR}"
-D CMAKE_PREFIX_PATH="${ELEMENTS_INSTALL_DIR};${KOKKOS_INSTALL_DIR}"
)

if [ "$kokkos_build_type" = "none" ]; then
cmake_options+=(
-D KOKKOS=OFF
-D Matar_ENABLE_KOKKOS=OFF
)
else
cmake_options+=(
-D KOKKOS=ON
-D Matar_ENABLE_KOKKOS=ON
)
fi

Expand Down
14 changes: 7 additions & 7 deletions scripts/elements-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ mkdir -p ${ELEMENTS_BUILD_DIR}

cmake_options=(
-D CMAKE_INSTALL_PREFIX="${ELEMENTS_INSTALL_DIR}"
-D CMAKE_PREFIX_PATH="${MATAR_INSTALL_DIR};${KOKKOS_INSTALL_DIR}"
-D CMAKE_PREFIX_PATH="${KOKKOS_INSTALL_DIR}"
)

if [ "$kokkos_build_type" = "none" ]; then
Expand All @@ -23,15 +23,15 @@ fi
# Print CMake options for reference
echo "CMake Options: ${cmake_options[@]}"

# Configure Matar
# Configure Elements
cmake "${cmake_options[@]}" -B "${ELEMENTS_BUILD_DIR}" -S "${ELEMENTS_SOURCE_DIR}"

# Build Matar
echo "Building Matar..."
# Build Elements
echo "Building Elements..."
make -C ${ELEMENTS_BUILD_DIR} -j${ELEMENTS_BUILD_CORES}

# Install Matar
echo "Installing Matar..."
# Install Elements
echo "Installing Elements..."
make -C ${ELEMENTS_BUILD_DIR} install

echo "Matar installation complete"
echo "Elements installation complete"
4 changes: 2 additions & 2 deletions scripts/setup-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ machine="$1"
kokkos_build_type="$2"
build_cores="$3"

my_build="build-matar-${kokkos_build_type}"
my_build="build-elements-${kokkos_build_type}"

export scriptdir=`pwd`

Expand All @@ -20,7 +20,7 @@ export installdir=${basedir}/install
export EXAMPLE_SOURCE_DIR=${basedir}/examples
export EXAMPLE_BUILD_DIR=${builddir}

export TEST_SOURCE_DIR=${basedir}/test
export TEST_SOURCE_DIR=${basedir}/tests
export TEST_BUILD_DIR=${builddir}

export ELEMENTS_SOURCE_DIR=${basedir}
Expand Down
3 changes: 0 additions & 3 deletions src/elements_lib_dummy.cpp

This file was deleted.

34 changes: 26 additions & 8 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
project(Tests)

# CMake version > 3.8 required for C++17 standard
cmake_minimum_required(VERSION 3.8)

find_package(Elements)
if(Matar_ENABLE_KOKKOS)
find_package(Kokkos)
endif()

# Test SLAM
add_executable(
test_slam_math
test_slam_math.cpp
)

target_link_libraries(
slam
test_slam_math
Elements
# slam
)

# Test Lagrange polynomials
Expand All @@ -16,7 +28,8 @@ add_executable(

target_link_libraries(
test_lagrange_polynomials
elements
Elements
#elements
)

# Test Lagrange element
Expand All @@ -26,7 +39,8 @@ add_executable(
)
target_link_libraries(
test_lagrange_element
elements
Elements
#elements
)

# Test Legendre polynomials
Expand All @@ -36,7 +50,8 @@ add_executable(
)
target_link_libraries(
test_legendre_polynomials
elements
Elements
#elements
)

# Test Legendre element
Expand All @@ -46,7 +61,8 @@ add_executable(
)
target_link_libraries(
test_legendre_element
elements
Elements
#elements
)


Expand All @@ -57,7 +73,8 @@ add_executable(
)
target_link_libraries(
test_legendre_ref_integration
elements
Elements
#elements
)


Expand All @@ -70,8 +87,9 @@ if (ENABLE_BLAS_LAPACK)
)
target_link_libraries(
test_gauss_jacobi_quadrature
common
elements
Elements
#common
#elements
${BLAS_LIBRARIES}
${LAPACK_LIBRARIES}
)
Expand Down

0 comments on commit e11177b

Please sign in to comment.