Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FairLogger uses internal fmt version when asked to install, regardless of -DUSE_EXTERNAL_FMT=ON #52

Open
ktf opened this issue Dec 13, 2023 · 5 comments

Comments

@ktf
Copy link
Contributor

ktf commented Dec 13, 2023

I have the strange behaviour where:

 29 cmake $SOURCEDIR                                                 \
 30       ${CXX_COMPILER:+-DCMAKE_CXX_COMPILER=$CXX_COMPILER}        \
 31       ${CMAKE_BUILD_TYPE:+-DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE}  \
 32       ${CXXSTD:+-DCMAKE_CXX_STANDARD=$CXXSTD}                    \
 33       -DPROJECT_GIT_VERSION=$(echo $PKGVERSION | sed -e 's/v//') \
 34       -DBUILD_TESTING=OFF                                        \
 35       -DCMAKE_INSTALL_PREFIX=$INSTALLROOT                        \
 36       -DDISABLE_COLOR=ON                                         \
 37       -DUSE_EXTERNAL_FMT=ON                                      \
 38       -DCMAKE_INSTALL_LIBDIR=lib
 39
 40 cmake --build . ${JOBS:+-- -j$JOBS}
 41 ctest ${JOBS:+-j$JOBS}
 42 cmake --build . --target install ${JOBS:+-- -j$JOBS}

works, while:

cmake --build . --target install ${JOBS:+-- -j$JOBS}

does not and fails with:

In file included from /Users/ktf/src/sw/SOURCES/FairLogger/master/0/logger/Logger.cxx:8:
In file included from /Users/ktf/src/sw/SOURCES/FairLogger/master/0/logger/Logger.h:27:
/Users/ktf/src/sw/SOURCES/FairLogger/master/0/logger/bundled/fmt/core.h:202:20: error: no template named 'result_of' in namespace 'std'; did you mean '::fmt::internal::result_of'?
  typedef typename std::result_of<
                   ^~~~~~~~~~~~~~
                   ::fmt::internal::result_of
/Users/ktf/src/sw/SOURCES/FairLogger/master/0/logger/bundled/fmt/core.h:197:8: note: '::fmt::internal::result_of' declared here
struct result_of;

notice the bundled version of fmt being used.

@ktf
Copy link
Contributor Author

ktf commented Dec 13, 2023

Doing:

cmake --build . ${JOBS:+-- -j$JOBS}
cmake --build . --target install ${JOBS:+-- -j$JOBS}

works as expected.

@dennisklein
Copy link
Member

hm, with a fresh build dir it works for me. What could be the difference?

bundled:

❯ cmake -GNinja -S. -Bbuild -DBUILD_TESTING=OFF -DCMAKE_INSTALL_PREFIX=./install
-- Found Git: /usr/bin/git (found version "2.42.0")
-- The C compiler identification is GNU 13.2.1
-- The CXX compiler identification is GNU 13.2.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/lib64/ccache/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/lib64/ccache/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- FairLogger 1.11.1 from Tue Jun 28 11:23:57 2022 +0200
--
--   CXX STANDARD       C++ (>= C++14, change with -DCMAKE_CXX_STANDARD=17)
--
--   GLOBAL CXX FLAGS   -fdiagnostics-color=always
--
--   BUILD TYPE         CXX FLAGS
--   Debug              -g -Wshadow -Wall -Wextra
--   Release            -O2 -DNDEBUG
-- * RelWithDebInfo     -O2 -g -Wshadow -Wall -Wextra -DNDEBUG
--   Nightly            -O2 -g -Wshadow -Wall -Wextra
--   Profile            -g3 -Wshadow -Wall -Wextra -fno-inline -ftest-coverage -fprofile-arcs
--   Experimental       -O2 -g -Wshadow -Wall -Wextra -DNDEBUG
--   AdressSan          -O2 -g -Wshadow -Wall -Wextra -fsanitize=address -fno-omit-frame-pointer
--   ThreadSan          -O2 -g -Wshadow -Wall -Wextra -fsanitize=thread
--
--   (Change the build type with -DCMAKE_BUILD_TYPE=...)
--
--   COMPONENT  BUILT?  INFO
--   library     YES    (default, always built)
--   tests        NO    (enable with -DBUILD_TESTING=ON)
--
--   FAIR_MIN_SEVERITY  not defined, enabling all severities (change with -DFAIR_MIN_SEVERITY=...)
--
--   INSTALL PREFIX     /home/dklein/projects/FairLogger/install (change with -DCMAKE_INSTALL_PREFIX=...)
--
-- Configuring done (0.3s)
-- Generating done (0.0s)
-- Build files have been written to: /home/dklein/projects/FairLogger/build
❯ cmake --build build --target install -j16
[1/4] Building CXX object CMakeFiles/FairLogger.dir/logger/Logger.cxx.o
In file included from /home/dklein/projects/FairLogger/logger/bundled/fmt/ostream.h:11,
                 from /home/dklein/projects/FairLogger/logger/bundled/fmt/printf.h:14,
                 from /home/dklein/projects/FairLogger/logger/Logger.h:28,
                 from /home/dklein/projects/FairLogger/logger/Logger.cxx:8:
/home/dklein/projects/FairLogger/logger/bundled/fmt/format.h:407:6: warning: identifier ‘char8_t’ is a keyword in C++20 [-Wc++20-compat]
  407 | enum char8_t: unsigned char {};
      |      ^~~~~~~
[3/4] Install the project...
-- Install configuration: "RelWithDebInfo"
-- Installing: /home/dklein/projects/FairLogger/install/lib64/libFairLogger.so.1.11.1
-- Installing: /home/dklein/projects/FairLogger/install/lib64/libFairLogger.so.1.11
-- Set runtime path of "/home/dklein/projects/FairLogger/install/lib64/libFairLogger.so.1.11.1" to "$ORIGIN/../lib64"
-- Installing: /home/dklein/projects/FairLogger/install/lib64/libFairLogger.so
-- Installing: /home/dklein/projects/FairLogger/install/include/fairlogger/Logger.h
-- Installing: /home/dklein/projects/FairLogger/install/include/fairlogger/Version.h
-- Installing: /home/dklein/projects/FairLogger/install/include/fairlogger/bundled
-- Installing: /home/dklein/projects/FairLogger/install/include/fairlogger/bundled/fmt
-- Installing: /home/dklein/projects/FairLogger/install/include/fairlogger/bundled/fmt/chrono.h
-- Installing: /home/dklein/projects/FairLogger/install/include/fairlogger/bundled/fmt/color.h
-- Installing: /home/dklein/projects/FairLogger/install/include/fairlogger/bundled/fmt/core.h
-- Installing: /home/dklein/projects/FairLogger/install/include/fairlogger/bundled/fmt/format-inl.h
-- Installing: /home/dklein/projects/FairLogger/install/include/fairlogger/bundled/fmt/format.h
-- Installing: /home/dklein/projects/FairLogger/install/include/fairlogger/bundled/fmt/locale.h
-- Installing: /home/dklein/projects/FairLogger/install/include/fairlogger/bundled/fmt/ostream.h
-- Installing: /home/dklein/projects/FairLogger/install/include/fairlogger/bundled/fmt/posix.h
-- Installing: /home/dklein/projects/FairLogger/install/include/fairlogger/bundled/fmt/printf.h
-- Installing: /home/dklein/projects/FairLogger/install/include/fairlogger/bundled/fmt/ranges.h
-- Installing: /home/dklein/projects/FairLogger/install/include/fairlogger/bundled/fmt/time.h
-- Installing: /home/dklein/projects/FairLogger/install/lib64/cmake/FairLogger-1.11.1/FairLoggerTargets.cmake
-- Installing: /home/dklein/projects/FairLogger/install/lib64/cmake/FairLogger-1.11.1/FairLoggerTargets-relwithdebinfo.cmake
-- Installing: /home/dklein/projects/FairLogger/install/lib64/cmake/FairLogger-1.11.1/FairLoggerConfig.cmake
-- Installing: /home/dklein/projects/FairLogger/install/lib64/cmake/FairLogger-1.11.1/FairLoggerConfigVersion.cmake

external:

❯ cmake -GNinja -S. -Bbuild2 -DBUILD_TESTING=OFF -DCMAKE_INSTALL_PREFIX=./install2 -DUSE_EXTERNAL_FMT=ON
-- Found Git: /usr/bin/git (found version "2.42.0")
-- The C compiler identification is GNU 13.2.1
-- The CXX compiler identification is GNU 13.2.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/lib64/ccache/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/lib64/ccache/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- FairLogger 1.11.1 from Tue Jun 28 11:23:57 2022 +0200
--
--   CXX STANDARD       C++ (>= C++14, change with -DCMAKE_CXX_STANDARD=17)
--
--   GLOBAL CXX FLAGS   -fdiagnostics-color=always
--
--   BUILD TYPE         CXX FLAGS
--   Debug              -g -Wshadow -Wall -Wextra
--   Release            -O2 -DNDEBUG
-- * RelWithDebInfo     -O2 -g -Wshadow -Wall -Wextra -DNDEBUG
--   Nightly            -O2 -g -Wshadow -Wall -Wextra
--   Profile            -g3 -Wshadow -Wall -Wextra -fno-inline -ftest-coverage -fprofile-arcs
--   Experimental       -O2 -g -Wshadow -Wall -Wextra -DNDEBUG
--   AdressSan          -O2 -g -Wshadow -Wall -Wextra -fsanitize=address -fno-omit-frame-pointer
--   ThreadSan          -O2 -g -Wshadow -Wall -Wextra -fsanitize=thread
--
--   (Change the build type with -DCMAKE_BUILD_TYPE=...)
--
--   DEPENDENCY FOUND     VERSION                   PREFIX
--   fmt                  9.1.0 (>= 5.3.0)          /usr
--
--   COMPONENT  BUILT?  INFO
--   library     YES    (default, always built)
--   tests        NO    (enable with -DBUILD_TESTING=ON)
--
--   FAIR_MIN_SEVERITY  not defined, enabling all severities (change with -DFAIR_MIN_SEVERITY=...)
--
--   INSTALL PREFIX     /home/dklein/projects/FairLogger/install2 (change with -DCMAKE_INSTALL_PREFIX=...)
--
-- Configuring done (0.3s)
-- Generating done (0.0s)
-- Build files have been written to: /home/dklein/projects/FairLogger/build2
❯ cmake --build build2 --target install -j16
[3/4] Install the project...
-- Install configuration: "RelWithDebInfo"
-- Installing: /home/dklein/projects/FairLogger/install2/lib64/libFairLogger.so.1.11.1
-- Installing: /home/dklein/projects/FairLogger/install2/lib64/libFairLogger.so.1.11
-- Set runtime path of "/home/dklein/projects/FairLogger/install2/lib64/libFairLogger.so.1.11.1" to "$ORIGIN/../lib64"
-- Installing: /home/dklein/projects/FairLogger/install2/lib64/libFairLogger.so
-- Installing: /home/dklein/projects/FairLogger/install2/include/fairlogger/Logger.h
-- Installing: /home/dklein/projects/FairLogger/install2/include/fairlogger/Version.h
-- Installing: /home/dklein/projects/FairLogger/install2/lib64/cmake/FairLogger-1.11.1/FairLoggerTargets.cmake
-- Installing: /home/dklein/projects/FairLogger/install2/lib64/cmake/FairLogger-1.11.1/FairLoggerTargets-relwithdebinfo.cmake
-- Installing: /home/dklein/projects/FairLogger/install2/lib64/cmake/FairLogger-1.11.1/FairLoggerConfig.cmake
-- Installing: /home/dklein/projects/FairLogger/install2/lib64/cmake/FairLogger-1.11.1/FairLoggerConfigVersion.cmake

@ktf
Copy link
Contributor Author

ktf commented Dec 13, 2023

I think the problem appears when you have an incompatible fmt installed externally.

@dennisklein
Copy link
Member

if(USE_EXTERNAL_FMT)
target_link_libraries(FairLogger PUBLIC fmt::fmt)
else()
add_library(fmt INTERFACE)
target_include_directories(fmt INTERFACE
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/logger/bundled>
$<INSTALL_INTERFACE:${PROJECT_INSTALL_BUNDLEDINCDIR}>
)
target_compile_features(fmt INTERFACE cxx_std_11)
target_compile_definitions(fmt INTERFACE FMT_HEADER_ONLY)
target_link_libraries(FairLogger PUBLIC fmt)
endif()

hm, the only way the build system could know about the bundled fmt, is, if USE_EXTERNAL_FMT=OFF at some point for a given build dir, or? if this variable is always set to ON, FairLogger's CMake will do a find_package(fmt) and then use the imported target fmt::fmt.

@ktf
Copy link
Contributor Author

ktf commented Dec 13, 2023

Actually what I see is that USE_EXTERNAL_FMT flip flops from ON to OFF in the CMakeCache.txt. Any idea of what could be causing that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants