Skip to content

Commit

Permalink
Add telldir and seekdir functions #50
Browse files Browse the repository at this point in the history
  • Loading branch information
tronkko committed Jul 9, 2022
1 parent bcc8f9e commit 588c14e
Show file tree
Hide file tree
Showing 7 changed files with 442 additions and 90 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
/t-cplusplus
/t-unicode
/t-strverscmp
/t-telldir
/t-utf8
/updatedb
/*.filters
Expand Down
73 changes: 37 additions & 36 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,63 +1,64 @@
cmake_minimum_required (VERSION 2.8.12)
project (dirent LANGUAGES C CXX)
cmake_minimum_required(VERSION 2.8.12)
project(dirent LANGUAGES C CXX)

# User options
option(DIRENT_BUILD_TESTS "Build bundled tests" ON)
message(STATUS "Build test and example programs: ${DIRENT_BUILD_TESTS}")

# Initialize C and C++ compilers
enable_language (C CXX)
enable_language(C CXX)

# Compile in debug mode by default
if (NOT CMAKE_BUILD_TYPE)
set (CMAKE_BUILD_TYPE Debug
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug
CACHE STRING
"Type of build: None Debug Release RelWithDebInfo MinSizeRel."
FORCE
)
endif (NOT CMAKE_BUILD_TYPE)
endif(NOT CMAKE_BUILD_TYPE)

# Use the include directory only on Windows
if (WIN32)
include_directories (${CMAKE_SOURCE_DIR}/include)
endif (WIN32)
if(WIN32)
include_directories(${CMAKE_SOURCE_DIR}/include)
endif(WIN32)

# Install dirent.h
if (WIN32)
install (FILES include/dirent.h DESTINATION include)
endif (WIN32)
if(WIN32)
install(FILES include/dirent.h DESTINATION include)
endif(WIN32)

# Add distclean target
add_custom_target (distclean
add_custom_target(distclean
COMMAND ${CMAKE_BUILD_TOOL} clean
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_SOURCE_DIR}/distclean.cmake
)

# Build example programs
if(DIRENT_BUILD_TESTS)
add_executable (find examples/find.c)
add_executable (ls examples/ls.c)
add_executable (locate examples/locate.c)
add_executable (updatedb examples/updatedb.c)
add_executable (scandir examples/scandir.c)
add_executable (cat examples/cat.c)
add_executable (dirls examples/dirls.c)
add_executable (du examples/du.c)
add_executable(find examples/find.c)
add_executable(ls examples/ls.c)
add_executable(locate examples/locate.c)
add_executable(updatedb examples/updatedb.c)
add_executable(scandir examples/scandir.c)
add_executable(cat examples/cat.c)
add_executable(dirls examples/dirls.c)
add_executable(du examples/du.c)

# Build test programs
include (CTest)
add_custom_target (check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C ${CMAKE_CFG_INTDIR})
function (add_test_executable TEST_NAME)
add_executable (${TEST_NAME} EXCLUDE_FROM_ALL ${ARGN})
add_test (NAME ${TEST_NAME} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} COMMAND $<TARGET_FILE:${TEST_NAME}>)
add_dependencies (check ${TEST_NAME})
endfunction (add_test_executable)

add_test_executable (t-compile tests/t-compile.c)
add_test_executable (t-dirent tests/t-dirent.c)
add_test_executable (t-scandir tests/t-scandir.c)
add_test_executable (t-unicode tests/t-unicode.c)
add_test_executable (t-cplusplus tests/t-cplusplus.cpp)
add_test_executable (t-strverscmp tests/t-strverscmp.c)
add_test_executable (t-utf8 tests/t-utf8.c)
include(CTest)
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C ${CMAKE_CFG_INTDIR})
function(add_test_executable TEST_NAME)
add_executable(${TEST_NAME} EXCLUDE_FROM_ALL ${ARGN})
add_test(NAME ${TEST_NAME} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} COMMAND $<TARGET_FILE:${TEST_NAME}>)
add_dependencies(check ${TEST_NAME})
endfunction(add_test_executable)

add_test_executable(t-compile tests/t-compile.c)
add_test_executable(t-dirent tests/t-dirent.c)
add_test_executable(t-scandir tests/t-scandir.c)
add_test_executable(t-unicode tests/t-unicode.c)
add_test_executable(t-cplusplus tests/t-cplusplus.cpp)
add_test_executable(t-telldir tests/t-telldir.c)
add_test_executable(t-strverscmp tests/t-strverscmp.c)
add_test_executable(t-utf8 tests/t-utf8.c)
endif(DIRENT_BUILD_TESTS)
Loading

0 comments on commit 588c14e

Please sign in to comment.