Skip to content

Commit

Permalink
add test for downstream using with cmake via prefix path (#1136)
Browse files Browse the repository at this point in the history
* add test for downstream using with cmake via prefix path
  • Loading branch information
cyrush committed Jul 14, 2023
1 parent dbeaca3 commit 5aef054
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 2 deletions.
22 changes: 22 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,28 @@ stages:
./conduit_example
displayName: 'Test vs Install (using-with-cmake)'
- script: |
#######################################
# using with cmake prefix path example
#######################################
export CC=${COMPILER_CC}
export CXX=${COMPILER_CXX}
export FC=${COMPILER_FC}
pwd
ls -l
# find spack installed cmake
export ROOT_DIR=`pwd`
export CMAKE_BIN_DIR=`ls -d ${ROOT_DIR}/uberenv_libs/spack/opt/spack/*/*/cmake*/bin`
export PATH=${CMAKE_BIN_DIR}:$PATH
echo $PATH
which cmake
cd install/examples/conduit/using-with-cmake-prefix-path
cmake -DCMAKE_PREFIX_PATH=${ROOT_DIR}/install -B build -S .
cmake --build build
cd build
./conduit_example
displayName: 'Test vs Install (using-with-cmake-prefix-path)'
- script: |
###########################
# using with make example
Expand Down
1 change: 1 addition & 0 deletions src/examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ add_subdirectory(staging)
# install using and python examples
install(DIRECTORY using-with-cmake
using-with-cmake-mpi
using-with-cmake-prefix-path
using-with-make
python
cpp_fort_and_py
Expand Down
57 changes: 57 additions & 0 deletions src/examples/using-with-cmake-prefix-path/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Copyright (c) Lawrence Livermore National Security, LLC and other Conduit
# Project developers. See top-level LICENSE AND COPYRIGHT files for dates and
# other details. No copyright assignment is required to contribute to Conduit.
###############################################################################
#
# Example that shows how to use an installed instance of Conduit passed
# via cmake prefix path in another CMake-based build system.
#
# To build:
# cmake -DCMAKE_PREFIX_PATH={conduit install path} ../ -B build -S .
# cmake --build build
# cd build
# ./conduit_example
#
#
###############################################################################

cmake_minimum_required(VERSION 3.0)

project(using_with_cmake_prefix_path)

################################################################
# Import conduit using find_package search
################################################################
#
# Add Conduit's install path to CMAKE_PREFIX_PATH
# and use following find_package call to import conduit's targets
#
find_package(Conduit REQUIRED)


######
# If Conduit was built with c++11 support, make sure we enable it
######
if(CONDUIT_USE_CXX11)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif()

#######################################################
# create our example
#######################################################
add_executable(conduit_example conduit_example.cpp)

# link to conduit targets
target_link_libraries(conduit_example conduit::conduit)

# if you are using conduit's python CAPI capsule interface
# target_link_libraries(conduit_example conduit::conduit_python)


# if you are using conduit's mpi features
# if(NOT MPI_FOUND)
# find_package(MPI COMPONENTS CXX)
# endif()
# target_link_libraries(conduit_example conduit::conduit_mpi)

29 changes: 29 additions & 0 deletions src/examples/using-with-cmake-prefix-path/conduit_example.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright (c) Lawrence Livermore National Security, LLC and other Conduit
// Project developers. See top-level LICENSE AND COPYRIGHT files for dates and
// other details. No copyright assignment is required to contribute to Conduit.

//-----------------------------------------------------------------------------
///
/// file: conduit_example.cpp
///
//-----------------------------------------------------------------------------

#include <iostream>

#include "conduit.hpp"
#include "conduit_relay.hpp"
#include "conduit_blueprint.hpp"


int main(int argc, char **argv)
{
conduit::Node about;
conduit::about(about["conduit"]);
conduit::relay::about(about["conduit/relay"]);
conduit::relay::io::about(about["conduit/relay/io"]);
conduit::blueprint::about(about["conduit/blueprint"]);

std::cout << about.to_yaml() << std::endl;
}


2 changes: 1 addition & 1 deletion src/examples/using-with-cmake/conduit_example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

//-----------------------------------------------------------------------------
///
/// file: example.cpp
/// file: conduit_example.cpp
///
//-----------------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion src/examples/using-with-make/conduit_example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

//-----------------------------------------------------------------------------
///
/// file: example.cpp
/// file: conduit_example.cpp
///
//-----------------------------------------------------------------------------

Expand Down

0 comments on commit 5aef054

Please sign in to comment.