Skip to content

Commit

Permalink
Merge branch 'release/4.2.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
lmoellendorf committed Jun 13, 2024
2 parents 864599b + d8d8b4c commit c4c95e3
Show file tree
Hide file tree
Showing 11 changed files with 971 additions and 1,312 deletions.
22 changes: 14 additions & 8 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ build:
- tree -a .
artifacts:
paths:
- install/*
- build/html/*
- install/
- build/

pages:
stage: doc
Expand All @@ -41,8 +41,8 @@ test:
script:
- pwd
- ls -l
- cd install/bin
- ./testrun
- cd build/
- ctest --verbose
dependencies:
- build

Expand All @@ -51,8 +51,8 @@ memcheck:
script:
- pwd
- ls -l
- cd install/bin
- valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes --error-exitcode=255 ./testrun
- cd build/
- valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes --error-exitcode=255 ctest --verbose
dependencies:
- build

Expand Down Expand Up @@ -95,11 +95,17 @@ win-build:
- .shared_windows_runners
stage: win
script:
- git clone https://github.com/tronkko/dirent.git
- mkdir build
- cd build
- cmake -DCMAKE_INSTALL_PREFIX=..\install -DBUILD_DOCS=OFF -DBUILD_EXAMPLES=ON ..
- cmake -DCMAKE_INCLUDE_PATH="../dirent/include" -DBUILD_DOCS=OFF -DBUILD_TESTING=ON -DBUILD_EXAMPLES=ON ..
- cmake --build .
# due to the long provisioning time of the Windows runner, tests are
# executed in the same stage as the build
- ctest -C Debug --verbose
artifacts:
paths:
- install
- install/
- build/
dependencies: []

40 changes: 3 additions & 37 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.12)
cmake_minimum_required(VERSION 3.18)

project(iniparser VERSION 4.2.2)
project(iniparser VERSION 4.2.3)

include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
Expand Down Expand Up @@ -117,42 +117,8 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)

if(BUILD_TESTING)
set(TEST_NAME testrun)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/AllTests.c
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/test/test_dictionary.c
${CMAKE_CURRENT_SOURCE_DIR}/test/test_iniparser.c
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/test/make-tests.sh >
${CMAKE_CURRENT_BINARY_DIR}/AllTests.c
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/test/)

add_executable(
${TEST_NAME}
${CMAKE_CURRENT_BINARY_DIR}/AllTests.c
${CMAKE_CURRENT_SOURCE_DIR}/test/CuTest.c
${CMAKE_CURRENT_SOURCE_DIR}/test/test_dictionary.c
${CMAKE_CURRENT_SOURCE_DIR}/test/test_iniparser.c)

foreach(TARGET_TYPE ${TARGET_TYPES})
# if BUILD_STATIC_LIBS=ON shared takes precedence
target_link_libraries(${TEST_NAME} "${PROJECT_NAME}-${TARGET_TYPE}")
endforeach()

target_include_directories(
${TEST_NAME}
PRIVATE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/test>
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/src/>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}>)

install(TARGETS ${TEST_NAME})
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/test/ressources
DESTINATION ${CMAKE_INSTALL_BINDIR})

enable_testing()
add_test(
NAME testsuite
COMMAND ${TEST_NAME}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/test)
add_subdirectory(test)
endif()

option(BUILD_EXAMPLES "Build and install examples")
Expand Down
6 changes: 3 additions & 3 deletions cmake/pc.in
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
prefix=${pcfiledir}/../..
prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=${prefix}
includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@
includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@/@PROJECT_NAME@
libdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@

Name: @PROJECT_NAME@
Description: @PROJECT_NAME@ library
Description: Simple C library offering ini file parsing services
Version: @PROJECT_VERSION@
Libs: -L${libdir} -l@PROJECT_NAME@
Cflags: -I${includedir}
91 changes: 91 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
include(FetchContent)
include(CTest)

find_program(
RUBY_EXECUTABLE
NAME
ruby
PATHS ENV
PATH
REQUIRED)

if(MSVC)
message(STATUS "MSVC environment")
find_file(
MSVC_DIRENT
"dirent.h"
REQUIRED)
message(STATUS "MSVC_DIRENT: ${MSVC_DIRENT}")
get_filename_component(
MSVC_DIRENT_INCLUDE_DIR
${MSVC_DIRENT}
DIRECTORY)
message(STATUS "MSVC_DIRENT_INCLUDE_DIR: ${MSVC_DIRENT_INCLUDE_DIR}")
include_directories(${MSVC_DIRENT_INCLUDE_DIR})
endif()

set(FETCHCONTENT_QUIET OFF)

FetchContent_Declare(
unity
GIT_REPOSITORY "https://github.com/throwtheswitch/unity.git"
GIT_PROGRESS TRUE
PATCH_COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_CURRENT_LIST_DIR}/unity_config.h ./src/)

FetchContent_MakeAvailable(unity)
target_compile_definitions(unity PUBLIC UNITY_INCLUDE_CONFIG_H)

function(create_test_runner)
set(options)
set(oneValueArgs NAME)
set(multiValueArgs)
cmake_parse_arguments(
TEST_RUNNER
"${options}"
"${oneValueArgs}"
"${multiValueArgs}"
${ARGN})

message(STATUS "Creating test_${TEST_RUNNER_NAME}")
add_custom_command(
OUTPUT test_${TEST_RUNNER_NAME}_runner.c
COMMAND
${RUBY_EXECUTABLE} ${unity_SOURCE_DIR}/auto/generate_test_runner.rb
${CMAKE_CURRENT_SOURCE_DIR}/test_${TEST_RUNNER_NAME}.c
test_${TEST_RUNNER_NAME}_runner.c
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/test_${TEST_RUNNER_NAME}.c
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
BYPRODUCTS test_${TEST_RUNNER_NAME}_runner.c)

add_executable(test_${TEST_RUNNER_NAME} test_${TEST_RUNNER_NAME}.c
test_${TEST_RUNNER_NAME}_runner.c)
# Prevent MSVC from creating Debug or Release subdirectories for test
# executables
set_target_properties(
test_${TEST_RUNNER_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY
${CMAKE_CURRENT_BINARY_DIR}/$<0:>)
foreach(TARGET_TYPE ${TARGET_TYPES})
# if BUILD_STATIC_LIBS=ON shared takes precedence
target_link_libraries(
test_${TEST_RUNNER_NAME}
${PROJECT_NAME}-${TARGET_TYPE}
unity)
endforeach()
endfunction()

file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/ressources
DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
create_test_runner(NAME ${PROJECT_NAME})
message(STATUS "Adding test test_${PROJECT_NAME}")
add_test(
NAME test_${PROJECT_NAME}
COMMAND test_${PROJECT_NAME}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})

create_test_runner(NAME dictionary)
message(STATUS "Adding test test_dictionary")
add_test(
NAME test_dictionary
COMMAND test_dictionary
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
Loading

0 comments on commit c4c95e3

Please sign in to comment.