| 1 |
cmake_minimum_required(VERSION 3.23.1) |
| 2 |
|
| 3 |
project(TribitsOldSimpleExApp |
| 4 |
DESCRIPTION |
| 5 |
"Example raw CMake project using packages installed from new or old TribitsExampleProject" |
| 6 |
VERSION 0.0.0 |
| 7 |
LANGUAGES NONE # Defined below after reading in compilers |
| 8 |
) |
| 9 |
|
| 10 |
find_package(TribitsExProj REQUIRED |
| 11 |
COMPONENTS SimpleCxx MixedLang WithSubpackages) |
| 12 |
|
| 13 |
message("Setting compilers and flags read in from 'TribitsExProjConfig.cmake' file:") |
| 14 |
|
| 15 |
set(CMAKE_CXX_COMPILER ${TribitsExProj_CXX_COMPILER} ) |
| 16 |
set(CMAKE_C_COMPILER ${TribitsExProj_C_COMPILER} ) |
| 17 |
set(CMAKE_Fortran_COMPILER ${TribitsExProj_Fortran_COMPILER} ) |
| 18 |
|
| 19 |
set(CMAKE_CXX_FLAGS "${TribitsExProj_CXX_COMPILER_FLAGS} ${CMAKE_CXX_FLAGS}") |
| 20 |
set(CMAKE_C_FLAGS "${TribitsExProj_C_COMPILER_FLAGS} ${CMAKE_C_FLAGS}") |
| 21 |
set(CMAKE_Fortran_FLAGS "${TribitsExProj_Fortran_COMPILER_FLAGS} ${CMAKE_Fortran_FLAGS}") |
| 22 |
|
| 23 |
# Enable the compilers now that we have gotten them from TribitsExProjConfig.cmake |
| 24 |
enable_language(C) |
| 25 |
enable_language(CXX) |
| 26 |
if (CMAKE_Fortran_COMPILER) |
| 27 |
enable_language(Fortran) |
| 28 |
endif() |
| 29 |
|
| 30 |
# Build a utility and link to libraries from WithSubpackagesB |
| 31 |
add_executable(util util.cpp) |
| 32 |
if (${PROJECT_NAME}_USE_DEPRECATED_TARGETS) |
| 33 |
target_link_libraries(util PRIVATE pws_b) |
| 34 |
# NOTE: Above will generate a DEPRECATION warning for newer TriBITS |
| 35 |
# versions! |
| 36 |
else() |
| 37 |
target_link_libraries(util PRIVATE ${WithSubpackagesB_LIBRARIES}) |
| 38 |
# NOTE: Above is the correct way to link against libraries from an |
| 39 |
# individual package for old and new TriBITS! |
| 40 |
endif() |
| 41 |
target_include_directories(util |
| 42 |
PRIVATE ${SimpleCxx_INCLUDE_DIRS} ${SimpleCxx_TPL_INCLUDE_DIRS}) |
| 43 |
|
| 44 |
# Build the APP and link to libraries from TribitsExProj packages |
| 45 |
add_executable(app app.cpp) |
| 46 |
target_link_libraries(app |
| 47 |
PRIVATE ${TribitsExProj_LIBRARIES} ${TribitsExProj_TPL_LIBRARIES}) |
| 48 |
target_include_directories(app |
| 49 |
PRIVATE ${TribitsExProj_INCLUDE_DIRS} ${TribitsExProj_TPL_INCLUDE_DIRS}) |
| 50 |
|
| 51 |
# Set up tests |
| 52 |
|
| 53 |
enable_testing() |
| 54 |
|
| 55 |
if ("SimpleTpl" IN_LIST TribitsExProj_TPL_LIST OR TARGET SimpleTpl::all_libs) |
| 56 |
set(simpleCxxDeps "simpletpl headeronlytpl") |
| 57 |
else() |
| 58 |
set(simpleCxxDeps "headeronlytpl") |
| 59 |
endif() |
| 60 |
# NOTE: Above, TribitsExProj_TPL_LIST does not exist in new TriBITS so to make |
| 61 |
# this work for new TriBITS as well, we need to check for target |
| 62 |
# SimpleTpl::all_libs. Small price to pay for progress! |
| 63 |
|
| 64 |
add_test(NAME util_test COMMAND util) |
| 65 |
set_tests_properties(util_test PROPERTIES |
| 66 |
PASS_REGULAR_EXPRESSION "Util Deps: B A SimpleCxx ${simpleCxxDeps} SimpleCxx ${simpleCxxDeps}" |
| 67 |
) |
| 68 |
|
| 69 |
add_test(NAME app_test COMMAND app) |
| 70 |
set_tests_properties(app_test PROPERTIES |
| 71 |
PASS_REGULAR_EXPRESSION "Full Deps: WithSubpackages:B A SimpleCxx ${simpleCxxDeps} SimpleCxx ${simpleCxxDeps} A SimpleCxx ${simpleCxxDeps}[;] MixedLang:Mixed Language[;] SimpleCxx:${simpleCxxDeps}" |
| 72 |
) |