cmake: Define large file support for tests
authorAndreas Schneider <asn@samba.org>
Tue, 9 May 2023 07:09:01 +0000 (09:09 +0200)
committerAndreas Schneider <asn@samba.org>
Tue, 20 Jun 2023 11:38:40 +0000 (13:38 +0200)
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
src/CMakeLists.txt
tests/CMakeLists.txt

index a1dbfafa27d7e481619b12a8e3336202939502c3..19e0d268390f10d3f3461fe6f8c195a575f3b857 100644 (file)
@@ -8,6 +8,12 @@ target_compile_options(socket_wrapper
                        PRIVATE
                           ${DEFAULT_C_COMPILE_FLAGS}
                           -D_GNU_SOURCE)
+if (CMAKE_SIZEOF_VOID_P EQUAL 4)
+    target_compile_options(socket_wrapper
+                           PRIVATE
+                           -D_LARGEFILE64_SOURCE)
+endif()
+
 target_link_libraries(socket_wrapper
                       PRIVATE ${SWRAP_REQUIRED_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
 
index e35c2581ff5ea0492bcbc656ca1b9134a8a9a427..17d8d3ceb5c6d0010115fec4b144b00515f55187 100644 (file)
@@ -127,10 +127,15 @@ function(ADD_CMOCKA_TEST_ENVIRONMENT _TEST_NAME)
                     ENVIRONMENT "${TORTURE_ENVIRONMENT}")
 endfunction()
 
+if (CMAKE_SIZEOF_VOID_P EQUAL 4)
+    message(STATUS "Enabling large file support for tests")
+    set(LFS_CFLAGS "-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64")
+endif()
+
 foreach(_SWRAP_TEST ${SWRAP_TESTS})
     add_cmocka_test(${_SWRAP_TEST}
                     SOURCES ${_SWRAP_TEST}.c
-                    COMPILE_OPTIONS ${DEFAULT_C_COMPILE_FLAGS} -D_GNU_SOURCE
+                    COMPILE_OPTIONS ${DEFAULT_C_COMPILE_FLAGS} -D_GNU_SOURCE ${LFS_CFLAGS}
                     LINK_LIBRARIES ${TORTURE_LIBRARY} socket_wrapper_noop
                     LINK_OPTIONS ${DEFAULT_LINK_FLAGS})
     add_cmocka_test_environment(${_SWRAP_TEST})