Skip to content

Commit

Permalink
Cleanup libcheck related code
Browse files Browse the repository at this point in the history
- Ref twitter#202, twitter/pelikan@14fcd34
- Replace CHECK_WORKING with CHECK_FOUND
  • Loading branch information
michalbiesek committed Sep 9, 2019
1 parent 683bc1a commit 0b94e43
Show file tree
Hide file tree
Showing 16 changed files with 27 additions and 51 deletions.
62 changes: 27 additions & 35 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,28 +63,6 @@ if(HAVE_RUST)
option(RUST_VERBOSE_BUILD "pass -vv to cargo compilation" OFF)
endif()

if(BUILD_AND_INSTALL_CHECK)
# (simms) What follows is a crime against build systems as we run the build/install
# for the check library up front, during the planning phase.

set(LIBCHECK_PREFIX "${CMAKE_BINARY_DIR}/check")

# check for a local install of check
if(NOT EXISTS "${LIBCHECK_PREFIX}")
# (simms) This is terrible and I did it this way to ensure this gets built
# before the rest of the 'check' tests run. This should be rewritten so that
# the other dependencies know that there's a target that can build check
execute_process(
COMMAND "bash" "${PROJECT_SOURCE_DIR}/ci/install-check.sh" "${LIBCHECK_PREFIX}"
TIMEOUT 300 # if this doesn't build in 5 minutes something is hosed
)
endif()

set(CHECK_ROOT_DIR "${LIBCHECK_PREFIX}")
set(CMAKE_REQUIRED_INCLUDES "${CHECK_ROOT_DIR}/include") # these make check link correctly in ccommon and pelikan
set(CMAKE_REQUIRED_LIBRARIES "${CHECK_ROOT_DIR}/lib")
endif()

include(CheckIncludeFiles)
if(OS_PLATFORM STREQUAL "OS_LINUX")
check_include_files(linux/time64.h HAVE_TIME64)
Expand Down Expand Up @@ -155,16 +133,28 @@ endif(COVERAGE)
include(FindPackageHandleStandardArgs)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake")

if(BUILD_AND_INSTALL_CHECK)
# (simms) What follows is a crime against build systems as we run the build/install
# for the check library up front, during the planning phase.

set(LIBCHECK_PREFIX "${CMAKE_BINARY_DIR}/check")

# check for a local install of check
if(NOT EXISTS "${LIBCHECK_PREFIX}")
# (simms) This is terrible and I did it this way to ensure this gets built
# before the rest of the 'check' tests run. This should be rewritten so that
# the other dependencies know that there's a target that can build check
execute_process(
COMMAND "bash" "${PROJECT_SOURCE_DIR}/ci/install-check.sh" "${LIBCHECK_PREFIX}"
TIMEOUT 300 # if this doesn't build in 5 minutes something is hosed
)
endif()

set(CHECK_ROOT_DIR "${LIBCHECK_PREFIX}")
set(CMAKE_REQUIRED_INCLUDES "${CHECK_ROOT_DIR}/include") # these make check link correctly in ccommon and pelikan
set(CMAKE_REQUIRED_LIBRARIES "${CHECK_ROOT_DIR}/lib")
endif()
find_package(Check)
if(NOT CHECK_FOUND)
message(WARNING "Check is required to build and run tests")
endif(NOT CHECK_FOUND)
if(CHECK_FOUND)
check_symbol_exists(ck_assert_int_eq check.h CHECK_WORKING)
if(NOT CHECK_WORKING)
message(WARNING "Check version too old to build tests")
endif(NOT CHECK_WORKING)
endif(CHECK_FOUND)

if (HAVE_ITT_INSTRUMENTATION)
if(PKG_CONFIG_FOUND)
Expand Down Expand Up @@ -192,10 +182,12 @@ include_directories(

add_subdirectory(src)

if(CHECK_WORKING)
include_directories(${include_directories} "${CHECK_INCLUDES}")
if(CHECK_FOUND)
include_directories(${CHECK_INCLUDE_DIRS})
link_directories(${CHECK_LIBRARY_DIRS})
link_libraries(${CHECK_LIBRARIES})
add_subdirectory(test)
endif(CHECK_WORKING)
endif(CHECK_FOUND)


if(HAVE_RUST)
Expand All @@ -221,4 +213,4 @@ message(STATUS "HAVE_SIGNAME: " ${HAVE_SIGNAME})

message(STATUS "HAVE_BACKTRACE: " ${HAVE_BACKTRACE})

message(STATUS "CHECK_WORKING: " ${CHECK_WORKING})
message(STATUS "CHECK_FOUND: " ${CHECK_FOUND})
2 changes: 0 additions & 2 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
include_directories(${include_directories} CHECK_INCLUDES)

add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND})

add_subdirectory(array)
add_subdirectory(bstring)
add_subdirectory(buffer)
Expand Down
1 change: 0 additions & 1 deletion test/array/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ set(source check_${suite}.c)
add_executable(${test_name} ${source})
target_link_libraries(${test_name} ccommon-static ${CHECK_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} m)

add_dependencies(check ${test_name})
add_test(${test_name} ${test_name})
1 change: 0 additions & 1 deletion test/bstring/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ set(source check_${suite}.c)
add_executable(${test_name} ${source})
target_link_libraries(${test_name} ccommon-static ${CHECK_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} m)

add_dependencies(check ${test_name})
add_test(${test_name} ${test_name})
1 change: 0 additions & 1 deletion test/buffer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ set(source check_${suite}.c)
add_executable(${test_name} ${source})
target_link_libraries(${test_name} ccommon-static ${CHECK_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} m)

add_dependencies(check ${test_name})
add_test(${test_name} ${test_name})
1 change: 0 additions & 1 deletion test/channel/pipe/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ set(source check_${suite}.c)
add_executable(${test_name} ${source})
target_link_libraries(${test_name} ccommon-static ${CHECK_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} m)

add_dependencies(check ${test_name})
add_test(${test_name} ${test_name})
1 change: 0 additions & 1 deletion test/channel/tcp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ set(source check_${suite}.c)
add_executable(${test_name} ${source})
target_link_libraries(${test_name} ccommon-static ${CHECK_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} m)

add_dependencies(check ${test_name})
add_test(${test_name} ${test_name})
1 change: 0 additions & 1 deletion test/event/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ set(source check_${suite}.c)
add_executable(${test_name} ${source})
target_link_libraries(${test_name} ccommon-static ${CHECK_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} m)

add_dependencies(check ${test_name})
add_test(${test_name} ${test_name})
1 change: 0 additions & 1 deletion test/log/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,4 @@ if(OS_PLATFORM STREQUAL "OS_DARWIN")
set_target_properties(${test_name} PROPERTIES LINK_FLAGS "-Wl,-F/System/Library/Frameworks")
endif()

add_dependencies(check ${test_name} ccommon-static)
add_test(${test_name} ${test_name})
1 change: 0 additions & 1 deletion test/metric/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ set(source check_${suite}.c)
add_executable(${test_name} ${source})
target_link_libraries(${test_name} ccommon-static ${CHECK_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} m)

add_dependencies(check ${test_name})
add_test(${test_name} ${test_name})
1 change: 0 additions & 1 deletion test/option/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ set(source check_${suite}.c)
add_executable(${test_name} ${source})
target_link_libraries(${test_name} ccommon-static ${CHECK_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} m)

add_dependencies(check ${test_name})
add_test(${test_name} ${test_name})
1 change: 0 additions & 1 deletion test/pool/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ set(source check_${suite}.c)
add_executable(${test_name} ${source})
target_link_libraries(${test_name} ccommon-static ${CHECK_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} m)

add_dependencies(check ${test_name})
add_test(${test_name} ${test_name})
1 change: 0 additions & 1 deletion test/rbuf/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ set(source check_${suite}.c)
add_executable(${test_name} ${source})
target_link_libraries(${test_name} ccommon-static ${CHECK_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} m)

add_dependencies(check ${test_name})
add_test(${test_name} ${test_name})
1 change: 0 additions & 1 deletion test/ring_array/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ set(source check_${suite}.c)
add_executable(${test_name} ${source})
target_link_libraries(${test_name} ccommon-static ${CHECK_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} m)

add_dependencies(check ${test_name})
add_test(${test_name} ${test_name})
1 change: 0 additions & 1 deletion test/time/timer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ set(source check_${suite}.c)
add_executable(${test_name} ${source})
target_link_libraries(${test_name} ccommon-static ${CHECK_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} m)

add_dependencies(check ${test_name})
add_test(${test_name} ${test_name})
1 change: 0 additions & 1 deletion test/time/wheel/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ set(source check_${suite}.c)
add_executable(${test_name} ${source})
target_link_libraries(${test_name} ccommon-static ${CHECK_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} m)

add_dependencies(check ${test_name})
add_test(${test_name} ${test_name})

0 comments on commit 0b94e43

Please sign in to comment.