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

First try to test with modules under OSX #2

Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ jobs:
CXXFLAGS: ${{format('-stdlib={0}', matrix.lib)}}

- name: Build
run: cmake --build ../build
run: |
cmake --build ../build --target fmt
cmake --build ../build

- name: Test
run: ctest -j `nproc` --test-dir ../build
env:
Expand Down
34 changes: 21 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.8...3.25)
cmake_minimum_required(VERSION 3.8...3.26)

# Fallback for using newer policies on CMake <3.12.
if(${CMAKE_VERSION} VERSION_LESS 3.12)
Expand All @@ -15,6 +15,10 @@ if (NOT DEFINED FMT_MASTER_PROJECT)
endif ()
endif ()

# Maby you must set C++ extensions being off. Clang's modules support may have trouble with extensions.
set(CMAKE_CXX_STANDARD_REQUIRED YES)
set(CMAKE_CXX_EXTENSIONS NO)

# Joins arguments and places the results in ${result_var}.
function(join result_var)
set(result "")
Expand All @@ -25,6 +29,7 @@ function(join result_var)
endfunction()

function(enable_module target)
message(STATUS "FMT_MODULE: Build the CXX-MODULE")
if (MSVC)
if (${CMAKE_GENERATOR} STREQUAL "Ninja")
set(BMI ${CMAKE_BINARY_DIR}/fmt.ifc)
Expand All @@ -35,13 +40,15 @@ function(enable_module target)
PRIVATE /interface /dxifcInlineFunctions-
INTERFACE /reference fmt=${BMI})
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(BMI ${CMAKE_CURRENT_BINARY_DIR}/fmt.pcm)
set(BMI ${CMAKE_BINARY_DIR}/fmt.pcm)
target_compile_options(${target}
PRIVATE -fmodule-output=${BMI} -x c++-module
INTERFACE -fmodule-file=fmt=${BMI})
endif ()
set_target_properties(${target} PROPERTIES ADDITIONAL_CLEAN_FILES ${BMI})
set_source_files_properties(${BMI} PROPERTIES GENERATED ON)

set(BMI ${BMI} PARENT_SCOPE)
endfunction()

include(CMakeParseArguments)
Expand Down Expand Up @@ -92,20 +99,19 @@ option(FMT_OS "Include core requiring OS (Windows/Posix) " ON)
option(FMT_MODULE "Build a module instead of a traditional library." OFF)
option(FMT_SYSTEM_HEADERS "Expose headers with marking them as system." OFF)

set(FMT_CAN_MODULE OFF)
if (CMAKE_CXX_STANDARD GREATER 17 AND (
(MSVC AND MSVC_VERSION GREATER 1933) OR
((CMAKE_CXX_COMPILER_ID MATCHES "Clang") AND
(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "16.0"))))
set(FMT_CAN_MODULE ON)
set(FMT_CAN_MODULE ${FMT_MODULE})
if (CMAKE_CXX_STANDARD GREATER 17)
if (MSVC_VERSION GREATER 1933 OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(FMT_CAN_MODULE ON)
endif ()
endif ()
if (NOT FMT_CAN_MODULE)
if (FMT_MODULE AND NOT FMT_CAN_MODULE)
set(FMT_MODULE OFF)
message(STATUS "Module support is disabled.")
message(WARNING "Module support is disabled!")
endif ()
if (FMT_TEST AND FMT_MODULE)
# The tests require {fmt} to be compiled as traditional library
message(STATUS "Testing is incompatible with build mode 'module'.")
message(WARNING "FMT_MODULE: Some test are incompatible and disabled!")
endif ()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Diese drei Änderungen bringen keine funktionalen Vorteile. Erst Funktion, später Kosmetik. Immerhin muß das muß das Eingang in das originale {fmt} Repository finden und dann will Victor wissen, wozu das gut ist.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Solange nicht alle Tests laufen finde ich das wichtig, dann kann das wieder raus.

set(FMT_SYSTEM_HEADERS_ATTRIBUTE "")
if (FMT_SYSTEM_HEADERS)
Expand Down Expand Up @@ -243,12 +249,14 @@ endif ()
if (FMT_PEDANTIC)
target_compile_options(fmt PRIVATE ${PEDANTIC_COMPILE_FLAGS})
endif ()

if (FMT_MODULE)
target_compile_features(fmt PUBLIC cxx_std_20)
enable_module(fmt)
else ()
target_compile_features(fmt PUBLIC cxx_std_11)
endif ()

target_compile_features(fmt PUBLIC cxx_std_11)

target_include_directories(fmt ${FMT_SYSTEM_HEADERS_ATTRIBUTE} PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${FMT_INC_DIR}>)
Expand Down
77 changes: 77 additions & 0 deletions TODO.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
bash-3.2$ popd
/Users/clausklein/Workspace/cpp/fmt

CXX=clang-16 cmake -S . -B build -G Ninja -D CMAKE_CXX_COMPILER_LAUNCHER=/usr/local/bin/ccache -D CMAKE_BUILD_TYPE=Debug -D CMAKE_PREFIX_PATH=/Users/clausklein/Workspace/cpp/stagedir -D CMAKE_CXX_STANDARD=20

-- CMake version: 3.26.3
-- The CXX compiler identification is Clang 16.0.1
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/local/opt/llvm/bin/clang-16 - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Warning at CMakeLists.txt:120 (message):
FMT_MODULE: Some test are incompatible and disabled!


-- Version: 9.1.1
-- Build type: Debug
-- Performing Test HAS_NULLPTR_WARNING
-- Performing Test HAS_NULLPTR_WARNING - Success
-- FMT_MODULE: Build the CXX-MODULE
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- FMT_MODULE: Build the CXX-MODULE
-- ADD_FMT_TEST_MODULE: Test module-test
-- Configuring done (2.2s)
-- Generating done (0.0s)
-- Build files have been written to: /Users/clausklein/Workspace/cpp/fmt/build
bash-3.2$

pushd build
ninja

ninja: error: '/Users/clausklein/Workspace/cpp/fmt/build/fmt.pcm', needed by 'bin/module-test', missing and no known rule to make it

ninja fmt

bash-3.2$ ninja
[1/1] Linking CXX executable bin/module-test
FAILED: bin/module-test

: && /usr/local/opt/llvm/bin/clang++-16 -g -isysroot \
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk -Wl,-search_paths_first \
-Wl,-headerpad_max_install_names test/CMakeFiles/test-module.dir/__/src/fmt.cc.o \
test/CMakeFiles/module-test.dir/module-test.cc.o test/CMakeFiles/module-test.dir/test-main.cc.o -o bin/module-test \
test/libtest-main.a /Users/clausklein/Workspace/cpp/fmt/build/test/fmt.pcm test/gtest/libgtest.a && :

Undefined symbols for architecture x86_64:
"fmt::v9::vsystem_error(int, fmt::v9::basic_string_view<char>, fmt::v9::basic_format_args<fmt::v9::basic_format_context<fmt::v9::appender, char>>)", referenced from:
std::__1::system_error fmt::v9::system_error<>(int, fmt::v9::basic_format_string<char>) in libtest-main.a(gtest-extra.cc.o)
"fmt::v9::file::dup(int)", referenced from:
output_redirect::output_redirect(__sFILE*) in libtest-main.a(gtest-extra.cc.o)
"fmt::v9::file::dup2(int)", referenced from:
output_redirect::output_redirect(__sFILE*) in libtest-main.a(gtest-extra.cc.o)
output_redirect::restore() in libtest-main.a(gtest-extra.cc.o)
"fmt::v9::file::pipe(fmt::v9::file&, fmt::v9::file&)", referenced from:
output_redirect::output_redirect(__sFILE*) in libtest-main.a(gtest-extra.cc.o)
"fmt::v9::file::read(void*, unsigned long)", referenced from:
output_redirect::restore_and_read() in libtest-main.a(gtest-extra.cc.o)
read(fmt::v9::file&, unsigned long) in libtest-main.a(gtest-extra.cc.o)
"fmt::v9::file::close()", referenced from:
fmt::v9::file::operator=(fmt::v9::file&&) in libtest-main.a(gtest-extra.cc.o)
output_redirect::restore() in libtest-main.a(gtest-extra.cc.o)
output_redirect::restore_and_read() in libtest-main.a(gtest-extra.cc.o)
"fmt::v9::file::~file()", referenced from:
output_redirect::output_redirect(__sFILE*) in libtest-main.a(gtest-extra.cc.o)
output_redirect::~output_redirect() in libtest-main.a(gtest-extra.cc.o)
ld: symbol(s) not found for architecture x86_64
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Das sieht so aus, als ob format.o fehlt.
Der Test hat alle Symbole doppelt: einmal im Modul fmt and damit attached an das Modul mit anderem Mangling, und ein zweites Mal in der Test-Infrastruktur (libtest-main mit gtestund fmt) als traditioneller Build mit normalem Mangling.

clang-16: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
bash-3.2$

/Users/clausklein/Workspace/cpp/fmt/build
bash-3.2$ find . -name '*.pcm' | xargs ls -l
-rw-r--r-- 1 clausklein staff 21292040 Apr 26 10:41 ./fmt.pcm
bash-3.2$
112 changes: 59 additions & 53 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ set(TEST_MAIN_SRC test-main.cc gtest-extra.cc gtest-extra.h util.cc)
add_library(test-main STATIC ${TEST_MAIN_SRC})
target_include_directories(test-main PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>)
target_link_libraries(test-main gtest fmt)
target_link_libraries(test-main gtest)

function(add_fmt_executable name)
add_executable(${name} ${ARGN})
Expand All @@ -31,19 +31,21 @@ function(add_fmt_test name)

set(sources ${name}.cc ${ADD_FMT_TEST_UNPARSED_ARGUMENTS})
if (ADD_FMT_TEST_HEADER_ONLY)
set(sources ${sources} ${TEST_MAIN_SRC} ../src/os.cc)
message(STATUS "ADD_FMT_TEST_HEADER_ONLY: Test ${name}")
set(sources ${sources} ${TEST_MAIN_SRC} ${PROJECT_SOURCE_DIR}/src/os.cc)
set(libs gtest fmt-header-only)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Das hat nicht mit dem Module zu tun.
Bitte keine Änderungsvorschläge, die die funktionalen Tests von {fmt} betreffen.

Copy link
Author

@ClausKlein ClausKlein Apr 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ich will nur sehen, was tatsächlich wie gebaut werden soll, kann dann wieder raus.

Tatsächlich kann man so sehen, das kein test bei euch baut worden ist bisher!

if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(PEDANTIC_COMPILE_FLAGS ${PEDANTIC_COMPILE_FLAGS} -Wno-weak-vtables)
endif ()
elseif (ADD_FMT_TEST_MODULE)
message(STATUS "ADD_FMT_TEST_MODULE: Test ${name}")
set(libs test-main test-module)
set_source_files_properties(${name}.cc PROPERTIES OBJECT_DEPENDS test-module)
else ()
set(libs test-main fmt)
endif ()
add_fmt_executable(${name} ${sources})
target_link_libraries(${name} ${libs})
target_link_libraries(${name} PRIVATE ${libs})

# Define if certain C++ features can be used.
if (FMT_PEDANTIC)
Expand All @@ -55,56 +57,54 @@ function(add_fmt_test name)
add_test(NAME ${name} COMMAND ${name})
endfunction()

if (FMT_MODULE)
return ()
endif ()

Comment on lines -58 to -61
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: Es sind nie die test mit module kompiliert worden bisher!

add_fmt_test(args-test)
add_fmt_test(assert-test)
add_fmt_test(chrono-test)
add_fmt_test(color-test)
add_fmt_test(core-test)
add_fmt_test(gtest-extra-test)
add_fmt_test(format-test mock-allocator.h)
if (MSVC)
target_compile_options(format-test PRIVATE /bigobj)
endif ()
if (NOT (MSVC AND BUILD_SHARED_LIBS))
add_fmt_test(format-impl-test HEADER_ONLY header-only-test.cc)
endif ()
add_fmt_test(ostream-test)
add_fmt_test(compile-test)
add_fmt_test(compile-fp-test HEADER_ONLY)
if (MSVC)
# Without this option, MSVC returns 199711L for the __cplusplus macro.
target_compile_options(compile-fp-test PRIVATE /Zc:__cplusplus)
endif()
add_fmt_test(printf-test)
add_fmt_test(ranges-test ranges-odr-test.cc)
if (NOT FMT_MODULE)
add_fmt_test(args-test)
add_fmt_test(assert-test)
add_fmt_test(chrono-test)
add_fmt_test(color-test)
add_fmt_test(core-test)
add_fmt_test(gtest-extra-test)
add_fmt_test(format-test mock-allocator.h)
if (MSVC)
target_compile_options(format-test PRIVATE /bigobj)
endif ()
if (NOT (MSVC AND BUILD_SHARED_LIBS))
add_fmt_test(format-impl-test HEADER_ONLY header-only-test.cc)
endif ()
add_fmt_test(ostream-test)
add_fmt_test(compile-test)
add_fmt_test(compile-fp-test HEADER_ONLY)
if (MSVC)
# Without this option, MSVC returns 199711L for the __cplusplus macro.
target_compile_options(compile-fp-test PRIVATE /Zc:__cplusplus)
endif()
add_fmt_test(printf-test)
add_fmt_test(ranges-test ranges-odr-test.cc)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Die funktionalen Tests sollen auf jeden Fall mitlaufen. Bei Compilern, die Modules beherrschen (und nur dort!) sollen zusätzlich die beiden Targets test-module (Erstellen des BMI und der Lib) und module-test (Nutzen des BMI) erstellt und getestet werden.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Klar, bisher wurde aber mit der Module version gar kein test compiliert!

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Und einfach so von der Kommandozeile? (Dateien passend zurechtgelegt)

clang++ -std=c++20 -fmodule-output -c -x c++ fmt.cc
clang++ -std=c++20 -I. -stdlib=libc++ test-main.cc gtest-extra.cc util.cc format.cc os.cc gmock-gtest-all.cc
clang++ -std=c++20 -I. -stdlib=libc++ -fprebuilt-module-path=. module-test.cc test-main.o gtest-extra.o util.o format.o os.o gmock-gtest-all.o fmt.o -o module-test.exe

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With a little more love it works:

#!/bin/sh

files="
../test/args-test.cc
../test/std-test.cc
../test/os-test.cc
../test/module-test.cc
../test/gtest-extra.cc
../test/chrono-test.cc
../test/ranges-test.cc
../test/cuda-test/cpp14.cc
../test/ostream-test.cc
../test/unicode-test.cc
../test/test-main.cc
../test/compile-test.cc
../test/scan-test.cc
../test/gtest-extra-test.cc
../test/noexception-test.cc
../test/enforce-checks-test.cc
../test/xchar-test.cc
../test/util.cc
../test/gtest/gmock-gtest-all.cc
../test/assert-test.cc
../test/ranges-odr-test.cc
../test/detect-stdfs.cc
../test/compile-fp-test.cc
../test/posix-mock-test.cc
../test/core-test.cc
../test/format-test.cc
../test/header-only-test.cc
../test/color-test.cc
../test/printf-test.cc
../test/format-impl-test.cc
../src/os.cc
../src/format.cc
../src/fmt.cc
"
for f in $files; do ln -s $f .; done

clang++ -std=c++20 -fmodule-output=fmt.pcm -I../include -c -x c++-module fmt.cc
clang++ -std=c++20 -I../include -I../test/gtest -I../test -stdlib=libc++ test-main.cc gtest-extra.cc util.cc format.cc os.cc gmock-gtest-all.cc -c
clang++ -std=c++20 -I../test -stdlib=libc++ -fprebuilt-module-path=. module-test.cc *.o -o module-test

exit

#######################
bash-3.2$ ./module-test
[==========] Running 45 tests from 1 test suite.
[----------] Global test environment set-up.
[----------] 45 tests from module_test
[ RUN      ] module_test.namespace
[       OK ] module_test.namespace (0 ms)
[ RUN      ] module_test.detail_namespace
[       OK ] module_test.detail_namespace (0 ms)
[ RUN      ] module_test.macros
[       OK ] module_test.macros (0 ms)
[ RUN      ] module_test.to_string
[       OK ] module_test.to_string (0 ms)
[ RUN      ] module_test.format
[       OK ] module_test.format (0 ms)
[ RUN      ] module_test.format_to
[       OK ] module_test.format_to (0 ms)
[ RUN      ] module_test.formatted_size
[       OK ] module_test.formatted_size (0 ms)
[ RUN      ] module_test.format_to_n
[       OK ] module_test.format_to_n (0 ms)
[ RUN      ] module_test.format_args
[       OK ] module_test.format_args (0 ms)
[ RUN      ] module_test.wformat_args
[       OK ] module_test.wformat_args (0 ms)
[ RUN      ] module_test.dynamic_format_args
[       OK ] module_test.dynamic_format_args (0 ms)
[ RUN      ] module_test.vformat
[       OK ] module_test.vformat (0 ms)
[ RUN      ] module_test.vformat_to
[       OK ] module_test.vformat_to (0 ms)
[ RUN      ] module_test.vformat_to_n
[       OK ] module_test.vformat_to_n (0 ms)
[ RUN      ] module_test.print
module-test.cc:256: Failure
fmt::print(L"{}µ", 42) produces different output.
Expected: 4\0\0\02\0\0\0?\0\0\0
  Actual: 42?
module-test.cc:257: Failure
fmt::print(__stderrp, L"{}µ", 4.2) produces different output.
Expected: 4\0\0\0.\0\0\02\0\0\0?\0\0\0
  Actual: 4.2?
[  FAILED  ] module_test.print (0 ms)
[ RUN      ] module_test.vprint
module-test.cc:265: Failure
fmt::vprint(L"{:}µ", fmt::make_wformat_args(42)) produces different output.
Expected: 4\0\0\02\0\0\0?\0\0\0
  Actual: 42?
module-test.cc:267: Failure
fmt::vprint(__stderrp, L"{}", fmt::make_wformat_args(42)) produces different output.
Expected: 4\0\0\02\0\0\0
  Actual: 42
[  FAILED  ] module_test.vprint (0 ms)
[ RUN      ] module_test.named_args
[       OK ] module_test.named_args (0 ms)
[ RUN      ] module_test.literals
[       OK ] module_test.literals (0 ms)
[ RUN      ] module_test.locale
[       OK ] module_test.locale (0 ms)
[ RUN      ] module_test.string_view
[       OK ] module_test.string_view (0 ms)
[ RUN      ] module_test.memory_buffer
[       OK ] module_test.memory_buffer (0 ms)
[ RUN      ] module_test.is_char
[       OK ] module_test.is_char (0 ms)
[ RUN      ] module_test.ptr
[       OK ] module_test.ptr (0 ms)
[ RUN      ] module_test.errors
[       OK ] module_test.errors (4 ms)
[ RUN      ] module_test.error_code
[       OK ] module_test.error_code (0 ms)
[ RUN      ] module_test.format_int
[       OK ] module_test.format_int (0 ms)
[ RUN      ] module_test.formatter
[       OK ] module_test.formatter (0 ms)
[ RUN      ] module_test.join
[       OK ] module_test.join (0 ms)
[ RUN      ] module_test.time
[       OK ] module_test.time (1 ms)
[ RUN      ] module_test.time_point
[       OK ] module_test.time_point (0 ms)
[ RUN      ] module_test.time_duration
[       OK ] module_test.time_duration (0 ms)
[ RUN      ] module_test.weekday
[       OK ] module_test.weekday (0 ms)
[ RUN      ] module_test.printf
[       OK ] module_test.printf (0 ms)
[ RUN      ] module_test.fprintf
[       OK ] module_test.fprintf (0 ms)
[ RUN      ] module_test.sprintf
[       OK ] module_test.sprintf (0 ms)
[ RUN      ] module_test.vprintf
[       OK ] module_test.vprintf (0 ms)
[ RUN      ] module_test.vfprintf
[       OK ] module_test.vfprintf (0 ms)
[ RUN      ] module_test.vsprintf
[       OK ] module_test.vsprintf (0 ms)
[ RUN      ] module_test.color
[       OK ] module_test.color (0 ms)
[ RUN      ] module_test.cstring_view
[       OK ] module_test.cstring_view (0 ms)
[ RUN      ] module_test.buffered_file
[       OK ] module_test.buffered_file (0 ms)
[ RUN      ] module_test.output_file
[=disabled=] Clang 16.0 emits multiple copies of vtables
[       OK ] module_test.output_file (0 ms)
[ RUN      ] module_test.custom_context
[       OK ] module_test.custom_context (0 ms)
[ RUN      ] module_test.compile_format_string
[=disabled=] Clang 16.0 fails to import user-defined literals
[       OK ] module_test.compile_format_string (0 ms)
[ RUN      ] module_test.std_types
[       OK ] module_test.std_types (0 ms)
[----------] 45 tests from module_test (7 ms total)

[----------] Global test environment tear-down
[==========] 45 tests from 1 test suite ran. (7 ms total)
[  PASSED  ] 43 tests.
[  FAILED  ] 2 tests, listed below:
[  FAILED  ] module_test.print
[  FAILED  ] module_test.vprint

 2 FAILED TESTS
bash-3.2$

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some progress! 🎉
The test failures are possibly related to some encoding issues. There are no functional tests for fmt::print with wide strings in format-test.cc. May be you want to add them there for a cross-check.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, nun war ich ins Englische abgerutscht 🤦‍♀️
Ich bin nicht sicher, ob Deutsch deine Muttersprache ist. Dein Name könnte auch Schwedisch sein 😉

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mein Name ist Claus Klein aus Schwäbisch Hall (gebürtiger Pfälzer) ;-)

add_fmt_test(scan-test)
check_symbol_exists(strptime "time.h" HAVE_STRPTIME)
if (HAVE_STRPTIME)
target_compile_definitions(scan-test PRIVATE FMT_HAVE_STRPTIME)
endif ()
add_fmt_test(scan-test)
check_symbol_exists(strptime "time.h" HAVE_STRPTIME)
if (HAVE_STRPTIME)
target_compile_definitions(scan-test PRIVATE FMT_HAVE_STRPTIME)
endif ()

add_fmt_test(std-test)
try_compile(compile_result_unused
${CMAKE_CURRENT_BINARY_DIR}
SOURCES ${CMAKE_CURRENT_LIST_DIR}/detect-stdfs.cc
OUTPUT_VARIABLE RAWOUTPUT)
string(REGEX REPLACE ".*libfound \"([^\"]*)\".*" "\\1" STDLIBFS "${RAWOUTPUT}")
if (STDLIBFS)
target_link_libraries(std-test ${STDLIBFS})
endif ()
add_fmt_test(unicode-test HEADER_ONLY)
if (MSVC)
target_compile_options(unicode-test PRIVATE /utf-8)
add_fmt_test(std-test)
try_compile(compile_result_unused
${CMAKE_CURRENT_BINARY_DIR}
SOURCES ${CMAKE_CURRENT_LIST_DIR}/detect-stdfs.cc
OUTPUT_VARIABLE RAWOUTPUT)
string(REGEX REPLACE ".*libfound \"([^\"]*)\".*" "\\1" STDLIBFS "${RAWOUTPUT}")
if (STDLIBFS)
target_link_libraries(std-test ${STDLIBFS})
endif ()
add_fmt_test(unicode-test HEADER_ONLY)
if (MSVC)
target_compile_options(unicode-test PRIVATE /utf-8)
endif ()
add_fmt_test(xchar-test)
add_fmt_test(enforce-checks-test)
target_compile_definitions(enforce-checks-test PRIVATE
-DFMT_ENFORCE_COMPILE_STRING)
endif ()
add_fmt_test(xchar-test)
add_fmt_test(enforce-checks-test)
target_compile_definitions(enforce-checks-test PRIVATE
-DFMT_ENFORCE_COMPILE_STRING)

if (FMT_CAN_MODULE)
# The tests need {fmt} to be compiled as traditional library
Expand All @@ -123,9 +123,15 @@ if (FMT_CAN_MODULE)
/Zc:externConstexpr /Zc:inline)
target_compile_options(module-test PRIVATE /utf-8 /Zc:__cplusplus
/Zc:externConstexpr /Zc:inline)
else ()
target_link_libraries(module-test PRIVATE ${CMAKE_BINARY_DIR}/${BMI})
endif ()
endif ()

if (FMT_CAN_MODULE)
return ()
endif ()

if (NOT DEFINED MSVC_STATIC_RUNTIME AND MSVC)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wenn die Test-Runner damit glücklich sind, bin ich's auch 😊

Copy link
Author

@ClausKlein ClausKlein Apr 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nur solange nicht alle tests linken, und war sowie drinnen, nur ganz oben!
Ich bin im Moment nur am linken des module tests interessiert, solange der nicht geht.

foreach (flag_var
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
Expand All @@ -139,7 +145,7 @@ endif()

if (NOT MSVC_STATIC_RUNTIME)
add_fmt_executable(posix-mock-test
posix-mock-test.cc ../src/format.cc ${TEST_MAIN_SRC})
posix-mock-test.cc ${PROJECT_SOURCE_DIR}/src/format.cc ${TEST_MAIN_SRC})
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Das und die beiden nachfolgenden Änderungen haben nicht mit dem Module zu tun! Also bitte nicht ändern, wie alle anderen bestehenden funktionalen Test aus dem Original-Repo bei Victor.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

des .. gibt eine __ im binary dir path!

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Da kann ich leider nichts beitragen. Meine Grundlage ist das originale CMakeLists.txt mit meinen Änderungen für Modules aus 2019, welche die letzten beiden Jahre bei Victor nicht überlebt haben. CMake war unfähig, ordentliche Projekte für den GitHub CI zu erzeugen.

Copy link
Author

@ClausKlein ClausKlein Apr 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CMake macht das, was man in den CMakeLists.txt modelliert!

Die Tests sind undurchsichtig, für mich nicht nachvollziehbar modelliert?

Warum wird nicht die vorgebaute fmt lib verwendet?
Die libfmt.a wird 2 mal gebaut, mit gleichem Inhalt. See TODO.txt.

target_include_directories(
posix-mock-test PRIVATE ${PROJECT_SOURCE_DIR}/include)
target_link_libraries(posix-mock-test gtest)
Expand All @@ -159,15 +165,15 @@ if (FMT_PEDANTIC)
check_cxx_compiler_flag(-fno-exceptions HAVE_FNO_EXCEPTIONS_FLAG)
endif ()
if (HAVE_FNO_EXCEPTIONS_FLAG)
add_library(noexception-test ../src/format.cc noexception-test.cc)
add_library(noexception-test ${PROJECT_SOURCE_DIR}/src/format.cc noexception-test.cc)
target_include_directories(
noexception-test PRIVATE ${PROJECT_SOURCE_DIR}/include)
target_compile_options(noexception-test PRIVATE -fno-exceptions)
target_compile_options(noexception-test PRIVATE ${PEDANTIC_COMPILE_FLAGS})
endif ()

# Test that the library compiles without locale.
add_library(nolocale-test ../src/format.cc)
add_library(nolocale-test ${PROJECT_SOURCE_DIR}/src/format.cc)
target_include_directories(
nolocale-test PRIVATE ${PROJECT_SOURCE_DIR}/include)
target_compile_definitions(
Expand Down