diff --git a/.github/workflows/osx.yml b/.github/workflows/osx.yml index 0e3692c8a39..ad898cedda0 100644 --- a/.github/workflows/osx.yml +++ b/.github/workflows/osx.yml @@ -62,5 +62,3 @@ jobs: cd build make install make test_install - make genexdebug - LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH make test_exportbuild_pkgconfig diff --git a/.github/workflows/windows-msvc-ref.yml b/.github/workflows/windows-msvc-ref.yml index 7ee64499e75..9237022ceb1 100644 --- a/.github/workflows/windows-msvc-ref.yml +++ b/.github/workflows/windows-msvc-ref.yml @@ -57,9 +57,3 @@ jobs: cd build cmake --install . --config ${{ matrix.config.build_type }} cmake --build . --target test_install --config ${{ matrix.config.build_type }} - cmake --build . --target genexdebug --config ${{ matrix.config.build_type }} - echo "PKG $env:PKG_CONFIG_PATH" - $env:PKG_CONFIG_PATH="C:\Program Files (x86)\Ginkgo\lib\pkgconfig" - echo "PKG $env:PKG_CONFIG_PATH" - cat "C:\Program Files (x86)\Ginkgo\lib\pkgconfig\ginkgo.pc" - cmake --build . --target test_exportbuild_pkgconfig --config ${{ matrix.config.build_type }} diff --git a/.gitlab/scripts.yml b/.gitlab/scripts.yml index f621f52799f..71e696a458f 100644 --- a/.gitlab/scripts.yml +++ b/.gitlab/scripts.yml @@ -51,7 +51,6 @@ -DGINKGO_DPCPP_SINGLE_MODE=${DPCPP_SINGLE_MODE} -DGINKGO_EXPORT_BUILD_DIR=${EXPORT_BUILD_DIR} - ninja -j${NUM_CORES} -l${CI_LOAD_LIMIT} install - - ninja genexdebug - if [ "${EXPORT_BUILD_DIR}" == "ON" ]; then ninja test_exportbuild; fi - LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH ninja test_exportbuild_pkgconfig dependencies: [] @@ -122,7 +121,6 @@ ninja validate_all_examples fi fi - - ninja genexdebug - if [ -n "${SYCL_DEVICE_TYPE}" ]; then unset SYCL_DEVICE_TYPE; fi - if [ -n "${SYCL_DEVICE_FILTER}" ]; then unset SYCL_DEVICE_FILTER; fi - if [ "${EXPORT_BUILD_DIR}" == "ON" ]; then ninja test_exportbuild; fi diff --git a/CMakeLists.txt b/CMakeLists.txt index f832046d2ed..5aed0560d8f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -345,6 +345,13 @@ if(GINKGO_BUILD_DOC) add_subdirectory(doc) endif() + +# add escape character '\' and convert the list to string +string(REPLACE " " "\ " PKG_CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}") +list(TRANSFORM GINKGO_INTERFACE_LINK_FLAGS REPLACE " " "\\\\ ") +list(TRANSFORM GINKGO_INTERFACE_CXX_FLAGS REPLACE " " "\\\\ ") +string(REPLACE ";" " " GINKGO_INTERFACE_CXX_FLAGS "${GINKGO_INTERFACE_CXX_FLAGS}") +string(REPLACE ";" " " GINKGO_INTERFACE_LINK_FLAGS "${GINKGO_INTERFACE_LINK_FLAGS}") configure_file(${Ginkgo_SOURCE_DIR}/cmake/ginkgo.pc.in ${Ginkgo_BINARY_DIR}/ginkgo.pc.in @ONLY) file(GENERATE OUTPUT ${Ginkgo_BINARY_DIR}/ginkgo_$.pc @@ -366,7 +373,6 @@ set(GINKGO_TEST_EXPORTBUILD_PKGCONFIG_BIN_DIR "${Ginkgo_BINARY_DIR}/test/test_ex get_property(GINKGO_USE_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) # GINKGO_CONFIG_PREFIX contains / in the end. set(GINKGO_CONFIG_PREFIX "$<$:$/>") -add_custom_target(genexdebug COMMAND ${CMAKE_COMMAND} -E echo "GINKGO_CONFIG_PREFIX ${GINKGO_CONFIG_PREFIX}") set(GINKGO_TEST_INSTALL_CMD ${GINKGO_TEST_INSTALL_BIN_DIR}/${GINKGO_CONFIG_PREFIX}test_install) set(GINKGO_TEST_EXPORTBUILD_CMD ${GINKGO_TEST_EXPORTBUILD_BIN_DIR}/${GINKGO_CONFIG_PREFIX}test_exportbuild) set(GINKGO_TEST_EXPORTBUILD_PKGCONFIG_CMD ${GINKGO_TEST_EXPORTBUILD_PKGCONFIG_BIN_DIR}/${GINKGO_CONFIG_PREFIX}test_exportbuild_pkgconfig) diff --git a/cmake/ginkgo.pc.in b/cmake/ginkgo.pc.in index 9d5aeb65808..25eb7791ff2 100644 --- a/cmake/ginkgo.pc.in +++ b/cmake/ginkgo.pc.in @@ -1,4 +1,4 @@ -prefix=@CMAKE_INSTALL_PREFIX@ +prefix=@PKG_CMAKE_INSTALL_PREFIX@ libdir=${prefix}/@GINKGO_INSTALL_LIBRARY_DIR@ includedir=${prefix}/@GINKGO_INSTALL_INCLUDE_DIR@ diff --git a/cmake/information_helpers.cmake b/cmake/information_helpers.cmake index 660e0d46ecd..aead7339472 100644 --- a/cmake/information_helpers.cmake +++ b/cmake/information_helpers.cmake @@ -20,96 +20,57 @@ function(filter_generator_expressions INPUT OUTPUT) endfunction() macro(ginkgo_interface_libraries_recursively INTERFACE_LIBS) - message(STATUS "INTERFACE_LIBS ${INTERFACE_LIBS}") + # always add the interface to the list to keep the order information + # Currently, it does not support the circular dependence and MSVC. foreach(_libs ${INTERFACE_LIBS}) - - if (NOT "${_libs}" IN_LIST GINKGO_INTERFACE_LIBS_FOUND - AND NOT "-l${_libs}" IN_LIST GINKGO_INTERFACE_LIBS_FOUND - AND NOT "-l${_libs}${CMAKE_DEBUG_POSTFIX}" IN_LIST GINKGO_INTERFACE_LIBS_FOUND) - message(STATUS "handles ${_libs}") - if (TARGET ${_libs}) - message(STATUS "${_libs} is TARGET") - if (upper_CMAKE_BUILD_TYPE STREQUAL "DEBUG" AND "${_libs}" MATCHES "ginkgo.*") - set(GINKGO_INTERFACE_LIB_NAME "-l${_libs}${CMAKE_DEBUG_POSTFIX}") - elseif("${_libs}" MATCHES "ginkgo.*") # Ginkgo libs are appended in the form -l - set(GINKGO_INTERFACE_LIB_NAME "-l${_libs}") + if (TARGET ${_libs}) + if("${_libs}" MATCHES "ginkgo.*") + set(GINKGO_INTERFACE_LIB_NAME "-l${_libs}") + if(upper_CMAKE_BUILD_TYPE STREQUAL "DEBUG") + set(GINKGO_INTERFACE_LIB_NAME "${GINKGO_INTERFACE_LIB_NAME}${CMAKE_DEBUG_POSTFIX}") endif() - - # Get the link flags and treat them - get_target_property(GINKGO_INTERFACE_LIBS_LINK_FLAGS "${_libs}" - INTERFACE_LINK_OPTIONS) - if (GINKGO_INTERFACE_LIBS_LINK_FLAGS) - filter_generator_expressions("${GINKGO_INTERFACE_LIBS_LINK_FLAGS}" - GINKGO_INTERFACE_LIB_NAME) - endif() - if (NOT "${GINKGO_INTERFACE_LIB_NAME}" IN_LIST GINKGO_INTERFACE_LIBS_FOUND) - list(APPEND GINKGO_INTERFACE_LIBS_FOUND "${GINKGO_INTERFACE_LIB_NAME}") - endif() - - # Populate the include directories - get_target_property(GINKGO_LIBS_INTERFACE_INCS "${_libs}" - INTERFACE_INCLUDE_DIRECTORIES) - foreach(_incs ${GINKGO_LIBS_INTERFACE_INCS}) - filter_generator_expressions("${_incs}" GINKGO_INTERFACE_INC_FILTERED) - if (GINKGO_INTERFACE_INC_FILTERED AND NOT - "-I${GINKGO_INTERFACE_INC_FILTERED}" IN_LIST GINKGO_INTERFACE_CFLAGS_FOUND) - list(APPEND GINKGO_INTERFACE_CFLAGS_FOUND "-I${GINKGO_INTERFACE_INC_FILTERED}") - endif() - endforeach() - - # Populate the compiler options and definitions if needed - get_target_property(GINKGO_LIBS_INTERFACE_DEFS "${_libs}" - INTERFACE_COMPILE_DEFINITIONS) - if (GINKGO_LIBS_INTERFACE_DEFS) - list(APPEND GINKGO_INTERFACE_CFLAGS_FOUND "${GINKGO_LIBS_INTERFACE_DEFS}") - endif() - get_target_property(GINKGO_LIBS_INTERFACE_OPTS "${_libs}" - INTERFACE_COMPILE_OPTIONS) - filter_generator_expressions("${GINKGO_LIBS_INTERFACE_OPTS}" GINKGO_LIBS_INTERFACE_OPTS_FILTERED) - if (GINKGO_LIBS_INTERFACE_OPTS) - list(APPEND GINKGO_INTERFACE_CFLAGS_FOUND "${GINKGO_LIBS_INTERFACE_OPTS_FILTERED}") + list(APPEND GINKGO_INTERFACE_LIBS_FOUND "${GINKGO_INTERFACE_LIB_NAME}") + endif() + # Get the link flags and treat them + get_target_property(GINKGO_INTERFACE_LIBS_LINK_FLAGS "${_libs}" + INTERFACE_LINK_OPTIONS) + if (GINKGO_INTERFACE_LIBS_LINK_FLAGS) + filter_generator_expressions("${GINKGO_INTERFACE_LIBS_LINK_FLAGS}" + GINKGO_INTERFACE_LIB_NAME) + endif() + # Populate the include directories + get_target_property(GINKGO_LIBS_INTERFACE_INCS "${_libs}" + INTERFACE_INCLUDE_DIRECTORIES) + foreach(_incs ${GINKGO_LIBS_INTERFACE_INCS}) + filter_generator_expressions("${_incs}" GINKGO_INTERFACE_INC_FILTERED) + if (GINKGO_INTERFACE_INC_FILTERED AND NOT + "-I${GINKGO_INTERFACE_INC_FILTERED}" IN_LIST GINKGO_INTERFACE_CFLAGS_FOUND) + list(APPEND GINKGO_INTERFACE_CFLAGS_FOUND "-I${GINKGO_INTERFACE_INC_FILTERED}") endif() + endforeach() - # Keep recursing through the libraries - get_target_property(GINKGO_LIBS_INTERFACE_LIBS "${_libs}" - INTERFACE_LINK_LIBRARIES) - ginkgo_interface_libraries_recursively("${GINKGO_LIBS_INTERFACE_LIBS}") - elseif(EXISTS "${_libs}") - message(STATUS "${_libs} is EXISTED") - if ("${_libs}" MATCHES "${PROJECT_BINARY_DIR}.*hwloc.so") - list(APPEND GINKGO_INTERFACE_LIBS_FOUND "${CMAKE_INSTALL_PREFIX}/${GINKGO_INSTALL_LIBRARY_DIR}/libhwloc.so") - else() - list(APPEND GINKGO_INTERFACE_LIBS_FOUND "${_libs}") - message(STATUS "GINKGO_INTERFACE_LIBS_FOUND ${GINKGO_INTERFACE_LIBS_FOUND}") - endif() + # Populate the compiler options and definitions if needed + get_target_property(GINKGO_LIBS_INTERFACE_DEFS "${_libs}" + INTERFACE_COMPILE_DEFINITIONS) + if (GINKGO_LIBS_INTERFACE_DEFS) + list(APPEND GINKGO_INTERFACE_CFLAGS_FOUND "${GINKGO_LIBS_INTERFACE_DEFS}") endif() - else() - message(STATUS "add ${_libs}") - # Still add the existed lib into the list such that keep the track of the dependency - if (TARGET ${_libs}) - if (upper_CMAKE_BUILD_TYPE STREQUAL "DEBUG" AND "${_libs}" MATCHES "ginkgo.*") - set(GINKGO_INTERFACE_LIB_NAME "-l${_libs}${CMAKE_DEBUG_POSTFIX}") - elseif("${_libs}" MATCHES "ginkgo.*") # Ginkgo libs are appended in the form -l - set(GINKGO_INTERFACE_LIB_NAME "-l${_libs}") - endif() - # Get the link flags and treat them - get_target_property(GINKGO_INTERFACE_LIBS_LINK_FLAGS "${_libs}" - INTERFACE_LINK_OPTIONS) - if (GINKGO_INTERFACE_LIBS_LINK_FLAGS) - filter_generator_expressions("${GINKGO_INTERFACE_LIBS_LINK_FLAGS}" - GINKGO_INTERFACE_LIB_NAME) - endif() - list(APPEND GINKGO_INTERFACE_LIBS_FOUND "${GINKGO_INTERFACE_LIB_NAME}") - # Keep recursing through the libraries - get_target_property(GINKGO_LIBS_INTERFACE_LIBS "${_libs}" - INTERFACE_LINK_LIBRARIES) - ginkgo_interface_libraries_recursively("${GINKGO_LIBS_INTERFACE_LIBS}") - elseif(EXISTS "${_libs}") - if ("${_libs}" MATCHES "${PROJECT_BINARY_DIR}.*hwloc.so") - list(APPEND GINKGO_INTERFACE_LIBS_FOUND "${CMAKE_INSTALL_PREFIX}/${GINKGO_INSTALL_LIBRARY_DIR}/libhwloc.so") - else() - list(APPEND GINKGO_INTERFACE_LIBS_FOUND "${_libs}") - endif() + get_target_property(GINKGO_LIBS_INTERFACE_OPTS "${_libs}" + INTERFACE_COMPILE_OPTIONS) + filter_generator_expressions("${GINKGO_LIBS_INTERFACE_OPTS}" GINKGO_LIBS_INTERFACE_OPTS_FILTERED) + if (GINKGO_LIBS_INTERFACE_OPTS) + list(APPEND GINKGO_INTERFACE_CFLAGS_FOUND "${GINKGO_LIBS_INTERFACE_OPTS_FILTERED}") + endif() + + # Keep recursing through the libraries + get_target_property(GINKGO_LIBS_INTERFACE_LIBS "${_libs}" + INTERFACE_LINK_LIBRARIES) + ginkgo_interface_libraries_recursively("${GINKGO_LIBS_INTERFACE_LIBS}") + elseif(EXISTS "${_libs}") + if ("${_libs}" MATCHES "${PROJECT_BINARY_DIR}.*hwloc.so") + list(APPEND GINKGO_INTERFACE_LIBS_FOUND "${CMAKE_INSTALL_PREFIX}/${GINKGO_INSTALL_LIBRARY_DIR}/libhwloc.so") + else() + list(APPEND GINKGO_INTERFACE_LIBS_FOUND "${_libs}") endif() endif() endforeach() @@ -136,23 +97,19 @@ macro(ginkgo_interface_information) # Format and store the interface libraries found # remove duplicates on the reversed list to keep the dependecy in the end of list. - message(STATUS "ORIGINAL ${GINKGO_INTERFACE_LIBS_FOUND}") list(REVERSE GINKGO_INTERFACE_LIBS_FOUND) list(REMOVE_DUPLICATES GINKGO_INTERFACE_LIBS_FOUND) list(REVERSE GINKGO_INTERFACE_LIBS_FOUND) list(REMOVE_ITEM GINKGO_INTERFACE_LIBS_FOUND "") - message(STATUS "AFTER ${GINKGO_INTERFACE_LIBS_FOUND}") - string(REPLACE ";" " " - GINKGO_FORMATTED_INTERFACE_LIBS_FOUND "${GINKGO_INTERFACE_LIBS_FOUND}") + # keep it as list set(GINKGO_INTERFACE_LINK_FLAGS - "${GINKGO_INTERFACE_LINK_FLAGS} ${GINKGO_FORMATTED_INTERFACE_LIBS_FOUND}") + ${GINKGO_INTERFACE_LINK_FLAGS} ${GINKGO_INTERFACE_LIBS_FOUND}) unset(GINKGO_INTERFACE_LIBS_FOUND) # Format and store the interface cflags found list(REMOVE_DUPLICATES GINKGO_INTERFACE_CFLAGS_FOUND) list(REMOVE_ITEM GINKGO_INTERFACE_CFLAGS_FOUND "") - string(REPLACE ";" " " - GINKGO_FORMATTED_INTERFACE_CFLAGS_FOUND "${GINKGO_INTERFACE_CFLAGS_FOUND}") - set(GINKGO_INTERFACE_CXX_FLAGS "${GINKGO_FORMATTED_INTERFACE_CFLAGS_FOUND}") + # Keep it as list + set(GINKGO_INTERFACE_CXX_FLAGS ${GINKGO_INTERFACE_CFLAGS_FOUND}) unset(GINKGO_INTERFACE_CFLAGS_FOUND) endmacro(ginkgo_interface_information) diff --git a/test/test_exportbuild_pkgconfig/CMakeLists.txt b/test/test_exportbuild_pkgconfig/CMakeLists.txt index 61f04283b5b..6d1c5d534f8 100644 --- a/test/test_exportbuild_pkgconfig/CMakeLists.txt +++ b/test/test_exportbuild_pkgconfig/CMakeLists.txt @@ -4,27 +4,13 @@ project(GinkgoExportBuildWithPkgConfigTest LANGUAGES CXX) find_package(PkgConfig REQUIRED) pkg_check_modules(GINKGO REQUIRED IMPORTED_TARGET ginkgo) -message(STATUS "GINKGO_LIBRARIES ${GINKGO_LIBRARIES}") -message(STATUS "GINKGO_INCLUDE_DIRS ${GINKGO_INCLUDE_DIRS}") -message(STATUS "GINKGO_CFLAGS ${GINKGO_CFLAGS}") -message(STATUS "GINKGO_LDFLAGS ${GINKGO_LDFLAGS}") - # Here, we use test install without any data. We instantiate the # interface only. add_executable(test_exportbuild_pkgconfig ../test_install/test_install.cpp) target_compile_features(test_exportbuild_pkgconfig PUBLIC cxx_std_14) -get_target_property(LINK_LIBRARIES PkgConfig::GINKGO INTERFACE_LINK_LIBRARIES) -message(STATUS "LINK_LIBRARIES ${LINK_LIBRARIES}") -get_target_property(INC PkgConfig::GINKGO INTERFACE_INCLUDE_DIRECTORIES) -message(STATUS "INC ${INC}") -# target_link_libraries(test_exportbuild_pkgconfig PRIVATE PkgConfig::GINKGO) -# target_link_libraries(test_exportbuild_pkgconfig PRIVATE -l/usr/lib/libpapi.so) # CMake PkgConfig only puts the -l, -L, and -framework into link_libraries and others into link_options -# When linking the target, the linking option will be before the compiled object such that the linking error +# When linking the target, the linking option will be before the compiled object to lead the linking error set_property(TARGET PkgConfig::GINKGO PROPERTY INTERFACE_LINK_LIBRARIES "${GINKGO_LDFLAGS}") set_property(TARGET PkgConfig::GINKGO PROPERTY INTERFACE_LINK_OPTIONS "") target_link_libraries(test_exportbuild_pkgconfig PRIVATE PkgConfig::GINKGO) -# target_link_libraries(test_exportbuild_pkgconfig PRIVATE ${GINKGO_LIBRARIES}) -# target_link_libraries(test_exportbuild_pkgconfig PRIVATE ${GINKGO_LDFLAGS}) -# target_include_directories(test_exportbuild_pkgconfig PUBLIC ${GINKGO_INCLUDE_DIRS})