Skip to content

Commit

Permalink
Update µnit to latest version.
Browse files Browse the repository at this point in the history
This version is a bit more robust when it comes to linking against
librt for clock_gettime.  If we can't find clock_gettime we don't
use it, even if the headers advertise it.  If we do manage to find
clock_gettime, we explicitly define a preprocessor symbol so the code
knows it is available.
  • Loading branch information
nemequ committed Jun 21, 2016
1 parent d818124 commit bf2d2fe
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 15 deletions.
33 changes: 26 additions & 7 deletions cmake/FindClockGettime.cmake
Original file line number Diff line number Diff line change
@@ -1,9 +1,28 @@
include (CheckFunctionExists)

set (CMAKE_REQUIRED_LIBRARIES_orig ${CMAKE_REQUIRED_LIBRARIES})
check_function_exists (clock_gettime res)
if (NOT res EQUAL 1)
set (CMAKE_REQUIRED_LIBRARIES rt)
check_function_exists (clock_gettime CLOCK_GETTIME_REQUIRES_RT)
endif ()
set (CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_orig})
set(CLOCK_GETTIME_LIBRARIES "")
set(CMAKE_REQUIRED_LIBRARIES_orig ${CMAKE_REQUIRED_LIBRARIES})
check_function_exists(clock_gettime CLOCK_GETTIME_FOUND)
if(CLOCK_GETTIME_FOUND)
set(CLOCK_GETTIME_LIBRARIES)
else()
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_orig} rt)
check_function_exists(clock_gettime CLOCK_GETTIME_FOUND)
if(CLOCK_GETTIME_FOUND)
set(CLOCK_GETTIME_LIBRARIES rt)
else()
# mingw puts clock_gettime in pthreads
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_orig} pthread)
check_function_exists(clock_gettime CLOCK_GETTIME_FOUND)
if(CLOCK_GETTIME_FOUND)
set(CLOCK_GETTIME_LIBRARIES pthread)
endif()
endif()
endif()

set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_orig})
unset(CMAKE_REQUIRED_LIBRARIES_orig)

set(CLOCK_GETTIME_FOULD "${CLOCK_GETTIME_FOUND}" PARENT_SCOPE)
set(CLOCK_GETTIME_LIBRARIES "${CLOCK_GETTIME_LIBRARIES}" PARENT_SCOPE)
mark_as_advanced(CLOCK_GETTIME_FOUND CLOCK_GETTIME_LIBRARIES)
8 changes: 1 addition & 7 deletions squash/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,7 @@ set (CMAKE_REQUIRED_DEFINITIONS ${orig_required_definitions})

check_prototype_exists ("_vscwprintf" "wchar.h;stdio.h" "HAVE__VSCWPRINTF")

if (WIN32)
else ()
include (FindClockGettime)
if (${CLOCK_GETTIME_REQUIRES_RT})
target_link_libraries (squash${SQUASH_VERSION_API} rt)
endif ()

if (NOT WIN32)
target_link_libraries (squash${SQUASH_VERSION_API} ${CMAKE_DL_LIBS})

include (FindIconv)
Expand Down
6 changes: 6 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ set_compiler_specific_flags(
VARIABLE extra_compiler_flags
INTEL -wd3179)

find_package(ClockGettime)
if(CLOCK_GETTIME_FOUND)
add_definitions(-DMUNIT_ALLOW_CLOCK_GETTIME)
link_libraries(test-squash ${CLOCK_GETTIME_LIBRARIES})
endif()

add_executable (test-squash ${SQUASH_TEST_SOURCES})
set_property(TARGET test-squash
APPEND PROPERTY COMPILE_DEFINITIONS "SQUASH_TEST_PLUGIN_DIR=\"${CMAKE_BINARY_DIR}/plugins\"")
Expand Down
2 changes: 1 addition & 1 deletion tests/munit
Submodule munit updated 1 files
+29 −3 munit.c

0 comments on commit bf2d2fe

Please sign in to comment.