Skip to content

Commit

Permalink
WIP: Beginning of TribitsExampleProject2 (TriBITSPub#299, TriBITSPub#427
Browse files Browse the repository at this point in the history
)
  • Loading branch information
bartlettroscoe committed Nov 12, 2021
1 parent 89136bb commit ea111b2
Show file tree
Hide file tree
Showing 13 changed files with 126 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tribits/examples/TribitsExampleProject2/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
################################################################################
# #
# TribitsExampleProject2 #
# #
################################################################################

cmake_minimum_required(VERSION 3.17.0 FATAL_ERROR)
include("${CMAKE_CURRENT_SOURCE_DIR}/ProjectName.cmake")
project(${PROJECT_NAME} LANGUAGES NONE)
set(${PROJECT_NAME}_TRIBITS_DIR
"${CMAKE_CURRENT_LIST_DIR}/../.." CACHE STRING
"TriBITS base directory (default assumes in TriBITS source tree)")
include("${${PROJECT_NAME}_TRIBITS_DIR}/TriBITS.cmake")
tribits_project()
3 changes: 3 additions & 0 deletions tribits/examples/TribitsExampleProject2/PackagesList.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
tribits_repository_define_packages(
Package1 packages/package1 PT
)
2 changes: 2 additions & 0 deletions tribits/examples/TribitsExampleProject2/ProjectName.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
set(PROJECT_NAME TribitsExProj2)
set(${PROJECT_NAME}_ENABLE_INSTALL_CMAKE_CONFIG_FILES_DEFAULT ON)
3 changes: 3 additions & 0 deletions tribits/examples/TribitsExampleProject2/TPLsList.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
tribits_repository_define_tpls(
Tpl1 "cmake/tpls/" PT
)
5 changes: 5 additions & 0 deletions tribits/examples/TribitsExampleProject2/Version.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
set(${REPOSITORY_NAME}_VERSION 1.1)
set(${REPOSITORY_NAME}_MAJOR_VERSION 01)
set(${REPOSITORY_NAME}_MAJOR_MINOR_VERSION 010100)
set(${REPOSITORY_NAME}_VERSION_STRING "1.1 (Dev)")
set(${REPOSITORY_NAME}_ENABLE_DEVELOPMENT_MODE_DEFAULT ON) # Change to 'OFF' for a release
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
include(TribitsGetImportedLocationProperty)

set(REQUIRED_HEADERS Tpl1.hpp)
set(REQUIRED_LIBS_NAMES tpl1)

tribits_tpl_allow_pre_find_package(Tpl1 Tpl1_ALLOW_PREFIND)

if (Tpl1_ALLOW_PREFIND)
message("-- Using find_package(Tpl1 ...) ...")
find_package(Tpl1)
if (Tpl1_FOUND)
message("-- Found Tpl1_DIR='${Tpl1_DIR}'")
get_target_property(inclDirs tpl1::tpl1 INTERFACE_INCLUDE_DIRECTORIES)
tribits_get_imported_location_property(tpl1::tpl1 libfile)
#print_var(inclDirs)
#print_var(libfile)
set(TPL_Tpl1_INCLUDE_DIRS "${inclDirs}" CACHE PATH "Include dirs for Tpl1")
set(TPL_Tpl1_LIBRARIES "${libfile}" CACHE PATH "Libraries for Tpl1")
# ToDo: Put in a call to find_dependency() in the generated
# Tpl1Config.cmake file and set Tpl1_DIR in that file to the found path so
# it finds the same file. For now, just getting the include directories
# and the library path is enough.
endif()
endif()

tribits_tpl_find_include_dirs_and_libraries( Tpl1
REQUIRED_HEADERS ${REQUIRED_HEADERS}
REQUIRED_LIBS_NAMES ${REQUIRED_LIBS_NAMES}
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
tribits_package(Package1)
add_subdirectory(src)
tribits_add_test_directories(test)
tribits_package_postprocess()
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
tribits_package_define_dependencies(
LIB_REQUIRED_TPLS Tpl1
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
set(HEADERS "")
set(SOURCES "")

include_directories(${CMAKE_CURRENT_SOURCE_DIR})

append_set(HEADERS
Package1_HelloWorld.hpp
)
append_set(SOURCES
Package1_HelloWorld.cpp
)

tribits_add_library(
package1
HEADERS ${HEADERS}
SOURCES ${SOURCES}
)

tribits_add_executable(package1-helloworld NOEXEPREFIX NOEXESUFFIX
SOURCES Package1_HelloWorld_Prog.cpp
INSTALLABLE
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

#include "Package1_HelloWorld.hpp"
#include "Tpl1.hpp"

std::string Package1::deps()
{
std::string deps;
deps = Tpl1::itsme();
return deps;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#ifndef PACKAGE1_HELLO_WOLRD_HPP
#define PACKAGE1_HELLO_WOLRD_HPP


#include <ostream>


namespace Package1 {

/** \brief . */
std::string deps();

} // namespace Package1


#endif // PACKAGE1_HELLO_WOLRD_HPP
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include <iostream>

#include "Package1_HelloWorld.hpp"

int main()
{
std::cout << "Package1 Deps: " << Package1::deps() << "\n";
return 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
tribits_add_test(package1-helloworld NOEXEPREFIX NOEXESUFFIX
NAME HelloWorldProg
DIRECTORY ${PACKAGE_BINARY_DIR}/src
NUM_MPI_PROCS 1
PASS_REGULAR_EXPRESSION "Package1 Deps: tpl1"
)

0 comments on commit ea111b2

Please sign in to comment.