diff --git a/test/core/ExamplesUnitTests/TribitsExampleProject_Tests.cmake b/test/core/ExamplesUnitTests/TribitsExampleProject_Tests.cmake index 6f0d29527..e5df073d8 100644 --- a/test/core/ExamplesUnitTests/TribitsExampleProject_Tests.cmake +++ b/test/core/ExamplesUnitTests/TribitsExampleProject_Tests.cmake @@ -3274,7 +3274,7 @@ tribits_add_advanced_test( TribitsExampleProject_SimpleCxx_External -DTribitsExProj_ENABLE_SECONDARY_TESTED_CODE=ON -DTribitsExProj_ENABLE_ALL_PACKAGES=ON -DTribitsExProj_ENABLE_TESTS=ON - #-DTribitsExProj_ENABLE_INSTALL_CMAKE_CONFIG_FILES=OFF # Allow WrapExternal enable + -DTribitsExProj_ENABLE_INSTALL_CMAKE_CONFIG_FILES=OFF # Allow WrapExternal enable -DTPL_ENABLE_SimpleCxx=ON -DCMAKE_PREFIX_PATH=../install/simple_cxx -DTPL_ENABLE_MPI=OFF @@ -3300,7 +3300,7 @@ tribits_add_advanced_test( TribitsExampleProject_SimpleCxx_External SKIP_CLEAN_WORKING_DIRECTORY CMND ${CMAKE_CTEST_COMMAND} PASS_REGULAR_EXPRESSION_ALL - "100% tests passed, 0 tests failed out of 7" + "100% tests passed, 0 tests failed out of 8" ALWAYS_FAIL_ON_NONZERO_RETURN ADDED_TEST_NAME_OUT TribitsExampleProject_SimpleCxx_External_NAME diff --git a/tribits/examples/TribitsExampleProject/packages/wrap_external/CMakeLists.txt b/tribits/examples/TribitsExampleProject/packages/wrap_external/CMakeLists.txt index 0efcd994f..ea7161b61 100644 --- a/tribits/examples/TribitsExampleProject/packages/wrap_external/CMakeLists.txt +++ b/tribits/examples/TribitsExampleProject/packages/wrap_external/CMakeLists.txt @@ -7,21 +7,6 @@ # provides libraries that need to be cast as TriBITS CMake libraries. To # make this even more interesting, the external software has dependencies on # upstream TriBITS packages. -# -# An overview of the basic tasks required are: -# -# a) Enumerate the upstream packages and TPLs needed (this is done in the -# cmake/Dependencies.cmake file). -# -# b) Generate an export makefile for the upstream packages and TPLs -# -# c) Call the configure script for the external package passing the compilers, -# compiler flags, and a pointer to the export makefile (which is just used to -# lift the include dirs and libs). -# -# d) Define library targets for the external project and define a build rule -# for generating those libraries given the list of header and source files in -# the external project. tribits_package(WrapExternal) @@ -66,41 +51,51 @@ endif() string(TOUPPER "${CMAKE_BUILD_TYPE}" upperBuildType) -set(includeDirsList - -I ${WithSubpackagesA_SOURCE_DIR} - -I ${SimpleCxx_SOURCE_DIR}/src - -I ${SimpleCxx_BINARY_DIR}/src - ) +get_target_property(simpleCxx_IncludeDirs + SimpleCxx::simplecxx INTERFACE_INCLUDE_DIRECTORIES) + +get_target_property(withSubpackagesA_IncludeDirs + WithSubpackagesA::pws_a INTERFACE_INCLUDE_DIRECTORIES) + +set(includeDirsList ${withSubpackagesA_IncludeDirs} ${simpleCxx_IncludeDirs}) + if (${PACKAGE_NAME}_ENABLE_MixedLang) - list(PREPEND includeDirsList - -I ${MixedLang_SOURCE_DIR}/src - -I ${MixedLang_BINARY_DIR}/src - ) + get_target_property(mixedLang_IncludeDirs + MixedLang::mixedlang INTERFACE_INCLUDE_DIRECTORIES) + list(PREPEND includeDirsList ${mixedLang_IncludeDirs}) endif() -list(JOIN includeDirsList " " includeDirs) -# NOTE: TriBITS export Makefile support used to handle the above stuff -# automatically but that is what you give up when moving to modern CMake. +list(JOIN includeDirsList " -I" includeDirsCompileOptions) +set(includeDirsCompileOptions "-I${includeDirsCompileOptions}") # -# C) Do configuration of the external project +# C) Do configuration of the external project as a build target # set(EXTERNAL_FUNC_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external_func) set(EXTERNAL_FUNC_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/external_func) set(EXTERNAL_FUNC_LIB_FILE ${EXTERNAL_FUNC_BINARY_DIR}/libexternal_func.a) +set(EXTERNAL_FUNC_MAKEFILE ${EXTERNAL_FUNC_BINARY_DIR}/Makefile) file(MAKE_DIRECTORY ${EXTERNAL_FUNC_BINARY_DIR}) -execute_process( +add_custom_command( + OUTPUT ${EXTERNAL_FUNC_MAKEFILE} + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt + ${EXTERNAL_FUNC_SOURCE_DIR}/configure.py COMMAND ${PYTHON_EXECUTABLE} ${EXTERNAL_FUNC_SOURCE_DIR}/configure.py "--cxx=${CMAKE_CXX_COMPILER}" "--cxx-flags=${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${upperBuildType}}" "--ar=${CMAKE_AR}" - "--include-dirs=${includeDirs}" + "--include-dirs=${includeDirsCompileOptions}" "--src-dir=${EXTERNAL_FUNC_SOURCE_DIR}" "--build-dir=${EXTERNAL_FUNC_BINARY_DIR}" ) +# NOTE: Above, we have to run the configure.py script at build time after +# generation because ${includeDirsCompileOptions} contains generation +# expressions that are evaluated at generation time by the +# add_custom_command() call. + # # D) Define a custom build rule and target to create external_func library # @@ -109,6 +104,7 @@ add_custom_command( OUTPUT ${EXTERNAL_FUNC_LIB_FILE} DEPENDS ${EXTERNAL_FUNC_SOURCE_DIR}/external_func.hpp ${EXTERNAL_FUNC_SOURCE_DIR}/external_func.cpp + ${EXTERNAL_FUNC_MAKEFILE} COMMAND make ${CTEST_BUILD_FLAGS} WORKING_DIRECTORY ${EXTERNAL_FUNC_BINARY_DIR} )